IllegalClassFormatException: Error while instrumenting class XYZ

5,366 views
Skip to first unread message

DK

unread,
Oct 1, 2013, 10:32:42 AM10/1/13
to jac...@googlegroups.com
Hi,

What are the potential causes for below exceptions?

I am running this command:

mvn jacoco:prepare-agent test jacoco:report


java.lang.instrument.IllegalClassFormatException: Error while instrumenting class XYZ
        at org.jacoco.agent.rt_kqcpih.CoverageTransformer.transform(CoverageTransformer.java:91)
        at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
        at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        at com.avaya.ingensg.wa.common.rpallocator.entries.MappedRPEntryTest.testForSetters(MappedRPEntryTest.java:66)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.IllegalStateException: Class XYZ is already instrumented.
        at org.jacoco.agent.rt_kqcpih.core.internal.instr.ClassInstrumenter.assertNotInstrumented(ClassInstrumenter.java:133)
        at org.jacoco.agent.rt_kqcpih.core.internal.instr.ClassInstrumenter.visitField(ClassInstrumenter.java:81)
        at org.jacoco.agent.rt_kqcpih.asm.ClassVisitor.visitField(Unknown Source)
        at org.jacoco.agent.rt_kqcpih.asm.ClassReader.accept(Unknown Source)
        at org.jacoco.agent.rt_kqcpih.asm.ClassReader.accept(Unknown Source)
        at org.jacoco.agent.rt_kqcpih.core.instr.Instrumenter.instrument(Instrumenter.java:69)
        at org.jacoco.agent.rt_kqcpih.core.instr.Instrumenter.instrument(Instrumenter.java:82)
        at org.jacoco.agent.rt_kqcpih.CoverageTransformer.transform(CoverageTransformer.java:89)
        ... 38 more

 I read elsewhere it maybe caused by AspectJ or Maven surefire running agent twice but I don't believe either of these are the cause.

Marc Hoffmann

unread,
Oct 1, 2013, 11:04:43 AM10/1/13
to jac...@googlegroups.com
Hi,

typically this happens with the following configuration problems:

1) Two JaCoCo agents (you can verify the command line used by surefire
with the -X option)
2) Classes have also been offline instrumented, which cannot be combined
with the agent unless you include those classes in the agent.

Best regards,
-marc
> --
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out [1].
>
>
> Links:
> ------
> [1] https://groups.google.com/groups/opt_out
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages