Skip to content

javaagent/java 7 and custom javassist not working together: stack shape inconsistent #549

@johanhaleby

Description

@johanhaleby

From gdel...@gmail.com on December 02, 2014 18:23:18

What steps will reproduce the problem? 1. Write an empty test with a before class method
2. add as content of the beforeClass method this:
ClassPool cp = ClassPool.getDefault();
CtClass cc = cp.get("java.lang.String");
ClassFile cf = cc.getClassFile();
List methods = cf.getMethods();
for (MethodInfo m : methods) {
System.out.println(m.getName());
}
3. Add the javaagent to the VM argument : -javaagent:powermock-module-javaagent-1.6.0.jar, in the run classpath, set the javaagent jar first
4. Make sure to set the compliance of the project to 1.7 (using a JRE 7)
4. Launch test with the standard JUnit4 runner What is the expected output? What do you see instead? I expect the test to pass as with Java 6, instead I get:
java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=TestPSC, method=beforeClass()V, pc=29
at java.lang.J9VMInternals.prepareClassImpl(Native Method)
at java.lang.J9VMInternals.prepare(J9VMInternals.java:430)
at java.lang.Class.getMethod(Class.java:1061)
at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:18)
at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) What version of the product are you using? On what operating system? JUnit 4.11, Powermock 1.6.0, javassist 3.18.2-GA Please provide any additional information below. Launching with a compliance 1.6 works perfectly fine, launching with 1.7 fails. I have also tried to add the option -XX:-UseSplitVerifier. And the javaagent jar is first in the classpath.

Any ideas?

Thank you!

Guillaume

The class is:

@Rule
public PowerMockRule rule = new PowerMockRule ();

static { PowerMockAgent .initializeIfNeeded();
}

@BeforeClass
public static void beforeClass() throws NotFoundException, CannotCompileException {
    ClassPool cp = ClassPool.getDefault();
    CtClass cc = cp.get("java.lang.String");
    ClassFile cf = cc.getClassFile();
    List<MethodInfo> methods = cf.getMethods();
    for (MethodInfo m : methods) {
        System.out.println(m.getName());
    }
}

@Test
public void test() throws Exception {
}

Original issue: http://code.google.com/p/powermock/issues/detail?id=529

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions