Skip to content

build: Suppress obsolete Java 8 option warning under JDK 21+#5664

Draft
runningcode wants to merge 1 commit into
mainfrom
no/fix-build-werror-obsolete-options
Draft

build: Suppress obsolete Java 8 option warning under JDK 21+#5664
runningcode wants to merge 1 commit into
mainfrom
no/fix-build-werror-obsolete-options

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

The root build compiles Java with -Xlint:all -Werror. This PR adds -Xlint:-options to the shared JavaCompile args in build.gradle.kts.

💡 Motivation and Context

The sentry module targets Java 8 (sourceCompatibility/targetCompatibility = 1.8). On JDK 21+, javac flags -source/-target 8 as obsolete:

warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
error: warnings found and -Werror specified

Because the build uses -Werror, that warning becomes a hard error and :sentry:compileJava fails. CI pins Temurin JDK 17 (where the warning does not yet exist), so it never surfaces there — but it breaks any local build or tooling running on a newer JDK. In particular, the Kotlin LSP bundles JDK 25, so its Gradle project import aborts and cross-module / external-library resolution silently stops working.

-Xlint:-options is the exact suppression javac itself recommends when intentionally targeting an older release. It only silences the [options] lint category (obsolete source/target, unset bootstrap classpath) and leaves -Werror in force for everything else.

💚 How did you test it?

Reproduced the failure and confirmed the fix with JDK 25's javac:

  • javac -source 8 -target 8 -Xlint:all -Werror ... → fails (exit 1)
  • same command with -Xlint:-options added → passes (exit 0)

./gradlew spotlessApply is clean.

📝 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.

🔮 Next steps

Longer term, the [options] warning points at the cleaner fix of switching from -source/-target 8 to --release 8 (which also sets the bootstrap classpath), but that is a broader change deferred to a follow-up.

#skip-changelog

The root build compiles Java with -Xlint:all -Werror. On JDK 21+,
javac flags -source/-target 8 as obsolete, and -Werror promotes that
warning to an error, failing :sentry:compileJava. CI pins JDK 17,
where the warning does not exist, so this only breaks local builds and
tooling on newer JDKs (e.g. the Kotlin LSP's bundled JDK 25, whose
Gradle project import aborts and loses cross-module resolution).

Add -Xlint:-options, the suppression javac itself recommends when
intentionally targeting an older release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sentry

sentry Bot commented Jul 1, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

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.

1 participant