8

Configuration : Java : 16
Gradle : 7.2
Jacoco : 0.8.4

When I upgraded my project from openJDK8 to openJDk16 I see the following issues :

"Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 60"

And also the below issue :
java.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/security/ec/SunEC$1. at org.jacoco.agent.rt.internal_035b120.CoverageTransformer.transform(CoverageTransformer.java:93) at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244

Ramu Smartguy
  • 103
  • 1
  • 7
  • The error actually means that the class was compiled with higher java version (16) but run with lower one (8). Check gradle JVM version by the command: `./gradlew -version` and make sure that gradle uses `16` (check `JAVA_HOME` in environment variables) – J-Alex Oct 13 '21 at 10:59
  • 1
    Does this answer your question? [How to fix "unsupported class file major version 60" in IntelliJ?](https://stackoverflow.com/questions/67079327/how-to-fix-unsupported-class-file-major-version-60-in-intellij) – Martin Zeitler Oct 13 '21 at 12:20

2 Answers2

3

I had similar problem when upgrading my project to use JDK17 ( i.e., Unsupported class file major version 61 ).

The solution was to upgrade jacoco maven plugin to version 0.8.8 in my pom

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.8</version>
            ...

this github thread is also related: https://github.com/mapstruct/mapstruct/issues/2835

pref
  • 1,651
  • 14
  • 24
1

I had a similar problem and fix it by chaining Gradle JVM settings in my preferred IDE which is IntelliJ (should be possible with others too):

  1. In the Settings/Preferences dialog, go to Build, Execution, Deployment | Build Tools | Gradle.

  2. Under the Gradle section, change the Gradle JVM option.

If you are using Intellij you can see more on this topic here

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197