Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jacoco java.lang.instrument.IllegalClassFormatException: Error while instrumenting Class

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?

like image 708
LMaker Avatar asked Sep 02 '25 17:09

LMaker


2 Answers

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.

like image 73
Godin Avatar answered Sep 05 '25 07:09

Godin


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>
like image 35
kpgan8204 Avatar answered Sep 05 '25 08:09

kpgan8204