perf(android): [SDK Overhead Reduction 2] Replace reflective OptionsContainer with direct subclass#5501
Draft
adinauer wants to merge 1 commit into
Conversation
Replace OptionsContainer.create(SentryAndroidOptions.class) which uses getDeclaredConstructor().newInstance() with a direct SentryAndroidOptionsContainer subclass that returns new SentryAndroidOptions() without reflection. Make OptionsContainer non-final (@OPEN) with a protected no-arg constructor so Android can subclass it.
This was referenced Jun 5, 2026
Draft
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (SDK Overhead Reduction)
📜 Description
Replace
OptionsContainer.create(SentryAndroidOptions.class)— which usesgetDeclaredConstructor().newInstance()— with a directSentryAndroidOptionsContainersubclass that returnsnew SentryAndroidOptions()without reflection.To enable subclassing,
OptionsContaineris made non-final (@Open) with aprotectedno-arg constructor. Theclazzfield becomes@Nullablewith a null check increateInstance()for the reflective path (used by non-Android callers).💡 Motivation and Context
Part of the SDK Overhead Reduction stack. Avoids reflective constructor invocation on the Android cold-start path. While the improvement is below the noise floor in isolation (AR-71 in autoresearch report), it removes unnecessary reflection and is a clean, risk-free change.
💚 How did you test it?
./gradlew :sentry:test— all tests pass./gradlew :sentry-android-core:testDebugUnitTest— all tests pass./gradlew spotlessApply apiDump— API change is only the expected non-final + protected ctor📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
More SDK overhead reduction PRs in this stack.
#skip-changelog