Skip to content

Commit bd51fe5

Browse files
runningcodeclaude
andauthored
build: Compile the SDK for Java 11 (#6459)
* build(android): Compile the Android modules for Java 11 AGP 9 defaults compileOptions to Java 11. The published Android libraries now emit Java 11 bytecode for both Java and Kotlin instead of Java 8. The JVM modules, sentry included, keep publishing Java 8 bytecode so that Java 8 backends can still use them. Fixes JAVA-660 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * changelog * build: Compile the JVM modules for Java 11 Extend the Java 11 target to the JVM modules, so every published module now emits Java 11 bytecode and the SDK no longer runs on Java 8. Modules that already targeted Java 17 are unchanged. The samples that pinned Java 8 move to Java 11 with the SDK. Refs JAVA-660 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * changelog * build: Drop the Java 8 API signature check With Java 11 as the minimum, the Java 8 signature only blocked APIs the SDK may now use. javac's release flag and Kotlin's -Xjdk-release already limit main code to the Java 11 API, so the JVM-only modules no longer apply animal sniffer. The modules that Android apps also use keep checking against the Android API 21 signature. Refs JAVA-660 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * changelog --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7803c61 commit bd51fe5

59 files changed

Lines changed: 87 additions & 122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.cursor/BUGBOT.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ rule file in [`.cursor/rules/`](rules) for the area the diff touches (`api`, `op
5858

5959
## Java and Android specifics
6060

61-
- The core `sentry` module is Java 8 and must not reference Android or JVM-only APIs. Reach optional
61+
- The core `sentry` module is Java 11 and must not reference Android or JVM-only APIs. Reach optional
6262
platform code through `Platform`, `LoadClass`, or a separate module.
6363
- Android code calling an API newer than `minSdk` must be guarded by
6464
`BuildInfoProvider.getSdkInfoVersion()`.

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ The repository is organized into multiple modules:
123123
## Development Guidelines
124124

125125
### Code Style
126-
- **Languages**: Java 8+ and Kotlin
126+
- **Languages**: Java 11+ and Kotlin
127127
- **Formatting**: Enforced via Spotless
128128
- **API Compatibility**: Binary compatibility is enforced. `.api` files are generated, never hand-edited
129129

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Breaking Changes
66

7+
- The SDK is now compiled for Java 11 instead of Java 8. JVM applications need Java 11 or newer ([#6459](https://github.com/getsentry/sentry-java/pull/6459))
78
- Default trace context status to `ok` when an active span has no explicit status ([#6418](https://github.com/getsentry/sentry-java/pull/6418))
89
- Remove the deprecated user feedback APIs ([#6337](https://github.com/getsentry/sentry-java/pull/6337))
910
- `UserFeedback` and `Sentry.captureUserFeedback(...)`: use `Sentry.feedback().capture(...)` with `io.sentry.protocol.Feedback` instead

‎build-logic/build.gradle.kts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ gradlePlugin {
1616
id = "io.sentry.jdk-target"
1717
implementationClass = "io.sentry.gradle.JdkTargetConvention"
1818
}
19-
register("sentryAnimalSniffer") {
20-
id = "io.sentry.animalsniffer"
21-
implementationClass = "io.sentry.gradle.SentryAnimalSnifferPlugin"
22-
}
2319
register("sentryAnimalSnifferAndroid") {
2420
id = "io.sentry.animalsniffer.android"
2521
implementationClass = "io.sentry.gradle.SentryAnimalSnifferAndroidPlugin"

‎build-logic/src/main/kotlin/io/sentry/gradle/JdkTargetConvention.kt‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
2020
/** The JDK every module compiles and tests with, whatever JDK runs Gradle. */
2121
private val BUILD_JDK = JavaLanguageVersion.of(21)
2222

23-
/** The level the SDK publishes, so that Java 8 consumers can still use it. */
24-
private val PUBLISHED_JAVA_VERSION = JavaVersion.VERSION_1_8
23+
/** The level the SDK publishes. */
24+
private val PUBLISHED_JAVA_VERSION = JavaVersion.VERSION_11
2525

2626
/**
2727
* Holds every toolchain, bytecode level decision and compilation option of a module. It does the
2828
* following
2929
* - sample apps target the build JDK (21)
3030
* - unit test code will target the build JDK (21) (required for Mockito 5)
31-
* - published JVM modules main code pins the Java 1.8 release, for Java and for Kotlin
31+
* - published JVM modules main code pins the Java 11 release, for Java and for Kotlin
3232
* - published modules Java code drops the MethodParameters attribute javac 21 adds, and their
3333
* archives are checked for it
34-
* - published Android modules main code targets Java 1.8
34+
* - published Android modules main code targets Java 11
3535
* - minSdk is set for Android libraries
3636
*/
3737
class JdkTargetConvention : Plugin<Project> {
@@ -75,7 +75,7 @@ class JdkTargetConvention : Plugin<Project> {
7575
}
7676
}
7777
// -Xjdk-release is the Kotlin counterpart of release: without it Kotlin resolves against the
78-
// build JDK and happily compiles e.g. Files.readString() into Java 8 bytecode. The version
78+
// build JDK and happily compiles e.g. Stream.toList() into Java 11 bytecode. The version
7979
// follows jvmTarget, which the modules that publish a higher level set themselves.
8080
project.plugins.withId("org.jetbrains.kotlin.jvm") {
8181
project.tasks.named("compileKotlin", KotlinJvmCompile::class.java) {
@@ -110,8 +110,8 @@ class JdkTargetConvention : Plugin<Project> {
110110
.toInt()
111111

112112
/**
113-
* Mockito 5 and mockito-kotlin 6 are built for Java 11, so test code - which is never published -
114-
* cannot share the Java 8 target of the main code. AGP has no per variant compileOptions, so this
113+
* Test code - which is never published - targets the build JDK, as it does in the JVM modules,
114+
* instead of the Java 11 target of the main code. AGP has no per variant compileOptions, so this
115115
* goes through the Kotlin compilations: their compile task providers are configured after AGP
116116
* wrote its own compileOptions, which an apply time configureEach would lose against.
117117
*/

‎build-logic/src/main/kotlin/io/sentry/gradle/SentryAnimalSnifferPlugin.kt‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ abstract class SentryAnimalSnifferExtension {
2020
}
2121
}
2222

23-
class SentryAnimalSnifferPlugin : Plugin<Project> {
23+
/**
24+
* Checks the main code of the JVM modules that Android apps also use against the Android API 21
25+
* signature. The JVM API needs no signature: javac's release flag and Kotlin's -Xjdk-release
26+
* already limit main code to the published Java version, see JdkTargetConvention.
27+
*/
28+
class SentryAnimalSnifferAndroidPlugin : Plugin<Project> {
2429
override fun apply(project: Project) {
2530
project.pluginManager.apply("ru.vyarus.animalsniffer")
2631

2732
val extension =
2833
project.extensions.create("sentryAnimalSniffer", SentryAnimalSnifferExtension::class.java)
2934

30-
project.addSignatureDependency("java8-signature")
35+
project.addSignatureDependency("gummy-bears-api21")
3136

3237
project.tasks.named("animalsnifferMain", AnimalSniffer::class.java).configure {
3338
ignoreClasses = ignoreClasses + extension.ignoredClasses.get()
@@ -38,14 +43,6 @@ class SentryAnimalSnifferPlugin : Plugin<Project> {
3843
}
3944
}
4045

41-
class SentryAnimalSnifferAndroidPlugin : Plugin<Project> {
42-
override fun apply(project: Project) {
43-
project.pluginManager.apply(SentryAnimalSnifferPlugin::class.java)
44-
45-
project.addSignatureDependency("gummy-bears-api21")
46-
}
47-
}
48-
4946
private fun Project.addSignatureDependency(libraryName: String) {
5047
val libs = extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
5148
dependencies.add("signature", signatureNotation(libs.findLibrary(libraryName).get().get()))

‎gradle/libs.versions.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ coroutines = "1.6.1"
1313
espresso = "3.7.0"
1414
feign = "11.6"
1515
gummyBears = "0.12.0"
16-
java8Signature = "1.0"
1716
jackson = "2.18.3"
1817
jetbrainsCompose = "1.6.11"
1918
kotlin = "2.3.21"
@@ -252,7 +251,6 @@ timber = { module = "com.jakewharton.timber:timber", version = "4.7.1" }
252251

253252
# Animalsniffer signature
254253
gummy-bears-api21 = { module = "com.toasttab.android:gummy-bears-api-21", version.ref = "gummyBears" }
255-
java8-signature = { module = "org.codehaus.mojo.signature:java18", version.ref = "java8Signature" }
256254

257255
# tomcat libraries
258256
tomcat-catalina = { module = "org.apache.tomcat:tomcat-catalina", version = "9.0.108" }

‎sentry-android-core/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import net.ltgt.gradle.errorprone.errorprone
22
import org.jetbrains.kotlin.config.KotlinCompilerVersion
3-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
44

55
plugins {
66
id("com.android.library")
@@ -39,7 +39,7 @@ android {
3939
// disabled, so unit tests must target release to run at all.
4040
testBuildType = "release"
4141

42-
kotlin { compilerOptions.jvmTarget = JVM_1_8 }
42+
kotlin { compilerOptions.jvmTarget = JVM_11 }
4343

4444
testOptions {
4545
animationsDisabled = true

‎sentry-android-distribution/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11
22
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
33

44
plugins {
@@ -28,7 +28,7 @@ android {
2828
}
2929

3030
kotlin {
31-
compilerOptions.jvmTarget = JVM_1_8
31+
compilerOptions.jvmTarget = JVM_11
3232
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
3333
explicitApi()
3434
}

‎sentry-android-fragment/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ android {
3131
testBuildType = "release"
3232

3333
kotlin {
34-
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
34+
compilerOptions.jvmTarget = JvmTarget.JVM_11
3535
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
3636
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
3737
}
@@ -75,5 +75,5 @@ dependencies {
7575

7676
tasks.withType<Detekt>().configureEach {
7777
// Target version of the generated JVM bytecode. It is used for type resolution.
78-
jvmTarget = JavaVersion.VERSION_1_8.toString()
78+
jvmTarget = JavaVersion.VERSION_11.toString()
7979
}

0 commit comments

Comments
 (0)