Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.