13

I recently moved to another computer and needed to reset all my environment.

So, this tests was working before.

But I didnt remember which version of Java/JDK I was using before.

Well, the problem is:

java.lang.instrument.IllegalClassFormatException: Error while instrumenting path/to/class

I'm using Jacoco "0.8.1"

java --version
openjdk 17.0.1 2021-10-19

and JDK 1.8

Can anyone know how to handle with it?

LMaker
  • 1,444
  • 3
  • 25
  • 38

3 Answers3

16

Strange to see statement

and JDK 1.8

together with

java --version
openjdk 17.0.1 2021-10-19

from the last one seems that actually you're using JDK 17

I'm using Jacoco "0.8.1"

We (developers of JaCoCo) advice to always use latest released version as new versions come with fixes and improvements (IMO updating versions of your dependencies and tools - is a very good practice also in general), so please try this - as of today latest released JaCoCo version is 0.8.7, and exactly in this version JDK 17 support was added.

Godin
  • 9,801
  • 2
  • 39
  • 76
8

Java 17 need jacoco 0.8.8 and above. reload pom.xml and it works

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.8</version>
</plugin>
kpgan8204
  • 91
  • 1
  • 3
3

While I was Testing my build in cmd using the command mvnw test, i got "Build Erorr" java.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo.

Step to perform:

1.Where to analyse the error. Always check for build error or any test report under project folder /target/surefire-reports. As this a build erorr checkin the dump file Check for error message . In this particular scenario the error message is "Jacocojava.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo"

2.Investigate what is causing this error. The java version i had is 17 and Jacoco version i had is 0.8.5. So check your java verison and Jacoco verison

3.Checking java version Cmd enter java - version : it will display the version example C:\Automation\projectJenkins\jgsu-spring-petclinic>java -version java version "17.0.6" 2023-01-17 LTS

4.For java 15 and above the jococ version compatable is 0.8.7. Open the pom file of your project and update jococ version. check under Generic properties . Update you version as 0.8.7

example:

<jacoco.version>0.8.7</jacoco.version>

save the file

  1. last step. test your build. cmd run MVNW test . The issue was reolved and succesfull build was built.