Skip to content

Commit

Permalink
Update ASM to 9.6 to support newer Java versions
Browse files Browse the repository at this point in the history
Update ASM from 9.0 to 9.6, the latest version. According to https://asm.ow2.io/versions.html,
this version should work with Java up to 22.

For testing, I tried a sample project using Gradle's `jvmToolchain`:

```
kotlin {
  jvmToolchain(20)
}
```

And installed different versions of OpenJDK separately.

It works with OpenJDK 19 and 20.0.2, but not 21.0.1, the latest stable version
(https://jdk.java.net/archive/).

Here's the error message:

```
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':app:androidJdkImage'.
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: /usr/local/google/home/kuanyingchou/Android/Sdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /usr/local/google/home/kuanyingchou/downloads/jdk-21.0.1/bin/jlink with arguments {--module-path /usr/local/google/home/kuanyingchou/.gradle/caches/transforms-3/b52ba5074efe1b01da421b426c4b2680/transformed/output/temp/jmod --add-modules java.base --output /usr/local/google/home/kuanyingchou/.gradle/caches/transforms-3/b52ba5074efe1b01da421b426c4b2680/transformed/output/jdkImage --disable-plugin system-modules}
```

It could be that AGP doesn't yet support JDK 21. From Gradle's release note
(https://docs.gradle.org/8.4/release-notes.html), it seems that Kotiln doesn't
support JDK 21 either:

```
Currently, you cannot run Gradle on Java 21 because Kotlin lacks support for JDK 21.
However, support for running Gradle with Java 21 is expected in future versions.
```

So the highest JDK version Hilt Gradle Plugin supports after this CL should be 20.

RELNOTES=N/A
PiperOrigin-RevId: 584641218
  • Loading branch information
kuanyingchou authored and Dagger Team committed Nov 22, 2023
1 parent 95f2afb commit 4c75892
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion java/dagger/hilt/android/plugin/main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies {
compileOnly "com.android.tools.build:gradle:$agp_version"
compileOnly "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
compileOnly "com.google.devtools.ksp:symbol-processing-gradle-plugin:$ksp_version"
implementation 'org.ow2.asm:asm:9.0'
implementation 'org.ow2.asm:asm:9.6'
implementation "com.squareup:javapoet:1.13.0"

testImplementation gradleTestKit()
Expand Down

0 comments on commit 4c75892

Please sign in to comment.