views:

257

answers:

3

I'm trying to generate code coverage reports with EMMA using tests of which some use JMockit as a mocking framework. For the most part, it works, but a few of my tests crash with a ClassFormatError, like so:

java.lang.ClassFormatError
    at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
    at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:79)
    at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:138)
    at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:73)
    at mockit.Mockit.setUpMocks(Mockit.java:177)
    at test.my.UnitTest.setUpBeforeClass(UnitTest.java:21)

Any idea what is going on, and whether I can fix the problem? Or are EMMA and JMockit mutually exclusive?

+1  A: 

Seems to be a bug in JMockit: After the class was already instrumented by EMMA, JMockit seems to have issues creating "reentry=true" mock methods.

Removing the "reentry=true" "worked around" the issue.

Epaga
A: 

From where and how to remove this "reentry=true"

it was an annotation on one of the methods. see the JMockit Javadoc for more info
Epaga
A: 

I have the same problem but I don't have any re-entrant methods. Has anybody else found a solution to this problem?

Chris B
I asked the same question elsewhere:http://stackoverflow.com/questions/905052/classformaterror-using-jmockit-with-emmaand received an answer that worked for me. If anybody else has this problem, try setting the javac debuglevel to "lines,source".
Chris B