ASM issue with plugin and Java 25

Grade version: 9.2.1

JVM: Amazon Corretto JDK 25 (25.0.2+10-LTS)
Architecture: aarch64

We are using the com.vaadin:vaadin-gradle-plugin:25.0.5 on a project. The project is built with Java 25. The Vaading plugin uses ASM against the Java 25 bytecode.

We are getting the following exception

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 69
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:200)
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:180)
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:288)

When the task executes.

The output from ./gradlew :ui:buildEnvironment shows that the vaading plugin depends on asm 9.9.1 (See bottom of the tree below.)

classpath
\--- com.vaadin:vaadin-gradle-plugin:25.0.5
     +--- com.vaadin:hilla-gradle-plugin:25.0.5
     |    \--- com.vaadin:flow-gradle-plugin:25.0.6
     |         \--- com.vaadin:flow-plugin-base:25.0.6
     |              +--- com.vaadin:flow-server:25.0.6
     |              |    +--- com.vaadin:flow-push:25.0.6
     |              |    |    \--- com.vaadin.external.atmosphere:atmosphere-runtime:3.0.5.slf4jvaadin1
     |              |    |         \--- org.slf4j:slf4j-api:1.7.35 -> 2.0.17
     |              |    +--- com.vaadin:signals:25.0.6
     |              |    |    +--- org.slf4j:slf4j-api:2.0.17
     |              |    |    \--- tools.jackson.core:jackson-databind:3.0.4
     |              |    |         +--- com.fasterxml.jackson.core:jackson-annotations:2.20
     |              |    |         +--- tools.jackson.core:jackson-core:3.0.4
     |              |    |         |    \--- tools.jackson:jackson-bom:3.0.4
     |              |    |         |         +--- com.fasterxml.jackson.core:jackson-annotations:2.20 (c)
     |              |    |         |         +--- tools.jackson.core:jackson-core:3.0.4 (c)
     |              |    |         |         \--- tools.jackson.core:jackson-databind:3.0.4 (c)
     |              |    |         \--- tools.jackson:jackson-bom:3.0.4 (*)
     |              |    +--- org.jspecify:jspecify:1.0.0
     |              |    +--- org.slf4j:slf4j-api:2.0.17
     |              |    +--- tools.jackson.core:jackson-core:3.0.4 (*)
     |              |    +--- tools.jackson.core:jackson-databind:3.0.4 (*)
     |              |    +--- org.jsoup:jsoup:1.21.2
     |              |    +--- org.ow2.asm:asm:9.9.1

ASM 9.91 should work with Java 25 however when I add the following task to build.gradle.

tasks.register("printAsmSource") {
    doLast {
        def cr = org.objectweb.asm.ClassReader.class
        def loc = cr.protectionDomain.codeSource?.location
        println "ClassReader loaded from: $loc"
    }
}

And execute it. I see that an earlier asm library is being used.

> Task :ui:printAsmSource
ClassReader loaded from: file:/Users/shutchinson/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/9.7.1/f0ed132a49244b042cd0e15702ab9f2ce3cc8436/asm-9.7.1.jar

My guess is that this version must be coming from Gradle itself.

Could anyone confirm

  1. Is my guess correct
  2. Is there anything I can do to force the correct ASM version for my plugin

What is the string representation of the class loader of that class?

Thanks for the reply @Vampire.

Updated my debug task to

tasks.register("printAsmSource") {
    doLast {
        def cr = org.objectweb.asm.ClassReader.class
        def cl = cr.getClassLoader().toString()

        def loc = cr.protectionDomain.codeSource?.location
        println "ClassReader loaded from: $loc using ClassLoader $cl"
    }
}

Which prints

ClassReader loaded from: file:/Users/shutchinson/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/9.7.1/f0ed132a49244b042cd0e15702ab9f2ce3cc8436/asm-9.7.1.jar 

using ClassLoader InstrumentingVisitableURLClassLoader(ClassLoaderScopeIdentifier.Id{coreAndPlugins:settings[:]:buildSrc[:]:root-project[:](export)})

@Vampire I unzipped the gradle 9.2.1 distribution and it bundles ASM 9.8, so it doesn’t appear to be coming from Gradle

You see that ASM version is coming from the build script classpath of the root build script. The class loader of a project’s build script classpath is the parent class loader of the class loaders of it’s child project’s build script classpath class loaders.

Conflict resolution only happens within one classpath.

So that plugin is applied to project UI and some other plugin brings in the old version in the root project, and the root project class loader wins.

Add your plugin with apply false to the root project build script, then there will be conflict resolution for ASM and the newer version will be used.

1 Like

That was exactly the problem. Many thanks as always @Vampire

1 Like