Skip to content

build: upgrade Kotlin to 2.4.0 and R8 to 9.1.31#160

Merged
OmarAlJarrah merged 2 commits into
mainfrom
build/bump-kotlin-2.4.0
Jun 20, 2026
Merged

build: upgrade Kotlin to 2.4.0 and R8 to 9.1.31#160
OmarAlJarrah merged 2 commits into
mainfrom
build/bump-kotlin-2.4.0

Conversation

@OmarAlJarrah

@OmarAlJarrah OmarAlJarrah commented Jun 20, 2026

Copy link
Copy Markdown
Member

What

Upgrades Kotlin from 2.3.21 to 2.4.0 across all modules, plus two supporting build changes the bump requires.

Changes

Kotlin 2.4.0 — the version lives once in gradle/libs.versions.toml and drives both the kotlin("jvm") plugin and kotlin-reflect, so the single catalog change applies to every module.

org.jetbrains:annotations 26.0.2 (compile-only) — added to every Kotlin module next to slf4j-api. kotlin-stdlib transitively pins the ancient org.jetbrains:annotations:13.0, which predates @UnknownNullability. On 2.4.0 the toolchain materialises inferred platform types using that annotation, and resolving it against 13.0 fails with "type annotation class org.jetbrains.annotations.UnknownNullability of the inferred type is inaccessible" (most visibly in the IDE on Java-interop call sites). Forcing a modern annotations version onto the compile classpath (13.0 -> 26.0.2) resolves it. Compile-only scope keeps it out of the published POM and the binary-compat ABI snapshots.

R8 8.9.35 → 9.1.31 — the test-only sdk-shrink-test module runs R8 over the SDK's Kotlin output to prove it survives consumer-side shrinking. Older R8 releases only understand older Kotlin metadata versions, so R8 is kept current (9.1.31 is the latest release) alongside the compiler bump. R8 enters no published artifact.

Verification

Full ./gradlew build is green — ktlint, detekt, allWarningsAsErrors, explicit-API strict, apiCheck, the 80% Kover floor, and the R8 shrink-survival guard (JDK 11 toolchain + R8 from Google Maven) all pass.

Bump the Kotlin version in the catalog from 2.3.21 to 2.4.0. The version is the
single source of truth for the kotlin("jvm") plugin and kotlin-reflect, so the
one change applies to every module.

Add org.jetbrains:annotations 26.0.2 as a compile-only dependency on every Kotlin
module (alongside slf4j-api). kotlin-stdlib transitively pins the ancient
annotations 13.0, which predates @UnknownNullability; the 2.4.0 toolchain
materialises inferred platform types with that annotation, and resolving it
against 13.0 fails ("type annotation class ... is inaccessible"). Keeping it
compile-only keeps it out of the published POM and the binary-compat ABI snapshots.
The test-only sdk-shrink-test module runs R8 over the SDK's Kotlin 2.4.0 output to
prove it survives consumer-side shrinking. Older R8 releases only understand older
Kotlin metadata versions, so keep R8 current (8.9.35 -> 9.1.31, the latest release)
alongside the compiler bump. R8 enters no published artifact; it is fetched from
Google's Maven repo solely for this guard.
@OmarAlJarrah OmarAlJarrah force-pushed the build/bump-kotlin-2.4.0 branch from 82cb56a to 4d36f63 Compare June 20, 2026 13:31
@OmarAlJarrah OmarAlJarrah changed the title build: upgrade Kotlin to 2.4.0 build: upgrade Kotlin to 2.4.0 and R8 to 9.1.31 Jun 20, 2026
@OmarAlJarrah OmarAlJarrah merged commit c8e31ae into main Jun 20, 2026
1 check passed
@OmarAlJarrah OmarAlJarrah deleted the build/bump-kotlin-2.4.0 branch June 20, 2026 13:42
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