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?
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.