Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage: in standalone mode can get TestRun$1 class missing #233

wknorr opened this issue Oct 30, 2015 · 2 comments

Code coverage: in standalone mode can get TestRun$1 class missing #233

wknorr opened this issue Oct 30, 2015 · 2 comments


Copy link

@wknorr wknorr commented Oct 30, 2015

When running the code coverage tool in standalone mode, for some applications I get an error saying mockit/internal/state/TestRun$1 cannot be found.

It quite possibly is related to two classes referencing each other.

Code coverage is still generated but I believe the classes that caused the error do not get any data associated with them.

If I add the following to the coverage/pom.xml file it takes care of the error, but I assume these files are not meant to be needed:


Also, strangely, if I compile my project with a target of 1.6, I do not get the error. (With 1.7 or 1.8 I do.) i.e.


Steps to reproduce

  1. Compile the project: "mvn install".
  2. Run the application from the command line with the following command (with the paths corrected to match your own system):
    "C:\Program Files\Java\jdk1.8.0_60\bin\java.exe" -classpath ./target/TestApp-1.0-SNAPSHOT.jar -javaagent:C\jmockit121\jmockit1-master\coverage\target\jmockit-coverage-1.21.jar -Dcoverage-outputDir=./CodeCoverageReports* -Dcoverage-metrics=line -Dcoverage-output=html-nocp

*The error is printed to the console immediately.

jmockit-coverage: 1.21 (GitHub 4e9bdf3) (compiled from source as per the instructions on GitHub)
Maven: 3.3.3
Java: JDK 1.8.0 u60

Stack trace

 [java] java.lang.NoClassDefFoundError: mockit/internal/state/TestRun$1
 [java]     at mockit.internal.util.ClassLoad.loadClass(
 [java]     at mockit.internal.util.ClassLoad.loadByInternalName(
 [java]     at mockit.internal.util.ClassLoad.getSuperClass(
 [java]     at mockit.internal.util.ClassLoad.actualSuperClass(
 [java]     at mockit.internal.util.ClassLoad.whichIsSuperClass(
 [java]     at mockit.external.asm.ClassWriter.getCommonSuperClass(
 [java]     at mockit.external.asm.ClassWriter.getMergedType(
 [java]     at mockit.external.asm.Frame.merge(
 [java]     at mockit.external.asm.Frame.merge(
 [java]     at mockit.external.asm.MethodWriter.visitMaxs(
 [java]     at mockit.external.asm.MethodVisitor.visitMaxs(
 [java]     at mockit.external.asm.ClassReader.readCode(
 [java]     at mockit.external.asm.ClassReader.readMethod(
 [java]     at mockit.external.asm.ClassReader.accept(
 [java]     at mockit.external.asm.ClassReader.accept(
 [java]     at mockit.coverage.modification.ClassModification.modifyClassForCoverage(
 [java]     at mockit.coverage.modification.ClassModification.modifyClassForCoverage(
 [java]     at mockit.coverage.modification.ClassModification.modifyClass(
 [java]     at mockit.coverage.CodeCoverage.transform(
 [java]     at sun.instrument.TransformerManager.transform(
 [java]     at sun.instrument.InstrumentationImpl.transform(
 [java]     at java.lang.ClassLoader.defineClass1(Native Method)
 [java]     at java.lang.ClassLoader.defineClass(
 [java]     at
 [java]     at
 [java]     at$100(
 [java]     at$
 [java]     at$
 [java]     at Method)
 [java]     at
 [java]     at java.lang.ClassLoader.loadClass(
 [java]     at sun.misc.Launcher$AppClassLoader.loadClass(
 [java]     at java.lang.ClassLoader.loadClass(
 [java]     at
 [java] Caused by: java.lang.ClassNotFoundException: mockit.internal.state.TestRun$1
 [java]     at
 [java]     at java.lang.ClassLoader.loadClass(
 [java]     at sun.misc.Launcher$AppClassLoader.loadClass(
 [java]     at java.lang.ClassLoader.loadClass(
 [java]     ... 34 more
 [java] JMockit: Coverage report written to C:\QA\SVNWorkingCopy\accuro-2015.03\TestApp\CodeCoverageReports

Source Code
I have used a simplified application with three classes.


import java.util.Scanner

public class TestApp {

    public static void main( String[] args ) {

        System.out.println( "Press enter." );

        UserManager um = new UserManager();

        Scanner keyboard = new Scanner( );




public class UserManager {

    public void checkPassword() {
        try {
            PasswordManager pm = new PasswordManager();
        } catch ( IllegalStateException e ) {
            System.err.println( "Problem." );

    public static String getImportantUser() {
        return "Bob";



public class PasswordManager {

    public PasswordManager() {

        String bestUser;
        bestUser = UserManager.getImportantUser();




<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

@rliesenfeld rliesenfeld self-assigned this Oct 30, 2015
Copy link

@rliesenfeld rliesenfeld commented Oct 30, 2015

Thanks! TestRun$1.class is needed, but is indeed missing from jmockit-coverage.jar.

Copy link

@alexanderjohn alexanderjohn commented Dec 21, 2015

I am also receiving this issue. Will this be fixed in the 1.21 release on Dec 27?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

No branches or pull requests

3 participants