Skip to content

perf(core): Use build-time class availability - #5875

Merged
romtsn merged 2 commits into
mainfrom
romtsn/feat/java-654-compile-time-checks
Jul 30, 2026
Merged

perf(core): Use build-time class availability#5875
romtsn merged 2 commits into
mainfrom
romtsn/feat/java-654-compile-time-checks

Conversation

@romtsn

@romtsn romtsn commented Jul 30, 2026

Copy link
Copy Markdown
Member

📜 Description

Allow LoadClass.isClassAvailable to use class-availability results supplied by build tooling before falling back to Class.forName. The lookup map is nullable and private, so applications without compatible tooling keep the existing reflection behavior.

💡 Motivation and Context

Android SDK initialization probes optional integrations reflectively. Build tooling already knows whether their owning modules are present, so it can avoid those runtime checks.

Refs JAVA-654

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:test --tests '*LoadClassTest*'
  • Pixel 2 XL microbenchmark: map construction and lookups were about 160× faster than the equivalent absent-heavy 11-class reflection batch.
  • In the absent-heavy startup macrobenchmark, SDK initialization was 1.08% faster and full startup was 0.88% faster, though variance exceeded the measured delta. The representative 10-present/1-absent case showed no measurable improvement.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

getsentry/sentry-android-gradle-plugin#1375 injects the build-time results.

#skip-changelog

Consult class availability data injected by build tooling before falling back to reflection. Keep the map nullable so consumers without supporting tooling preserve current behavior.

Refs JAVA-654
Co-Authored-By: Codex <noreply@openai.com>
@linear-code

linear-code Bot commented Jul 30, 2026

Copy link
Copy Markdown

JAVA-654

@sentry

sentry Bot commented Jul 30, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.51.0 (1) release

⚙️ sentry-android Build Distribution Settings

Allow package-local tests to set class availability without reflection.

Refs LINEAR-JAVA-654

Co-Authored-By: Codex <noreply@openai.com>
@romtsn
romtsn force-pushed the romtsn/feat/java-654-compile-time-checks branch from 8635d0a to 6b596d5 Compare July 30, 2026 13:12
@romtsn
romtsn marked this pull request as ready for review July 30, 2026 14:10

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems simple enough!

@romtsn
romtsn merged commit 1e904b2 into main Jul 30, 2026
71 of 72 checks passed
@romtsn
romtsn deleted the romtsn/feat/java-654-compile-time-checks branch July 30, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants