Open GoogleCodeExporter opened 9 years ago
I forgot to say that, to isolate the problem, I made a really dummy class being
this:
public class TestA {
public static void main(String[] args) throws NotFoundException {
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());
}
}
}
And under Java 7, it runs fine without the powermock agent, as soon as I add
the VM argument: -javaagent:powermock-module-javaagent-1.6.0.jar
it fails with the same error. So there is something wrong between javassist and
the powermock javaagent under Java 7, or maybe I doing something wrong :)
Original comment by gdel...@gmail.com
on 2 Dec 2014 at 5:28
Output with a JRE 7 SUN 32 bits is the following:
Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 57 Exception Details: Location: TestA.main([Ljava/lang/String;)V @31: goto Reason: Expected stackmap frame at this location. Bytecode: 0000000: b800 154c 2b12 17b6 001b 4d2c b600 214e 0000010: 2db6 0027 3a04 1904 b900 2d01 003a 06a7 0000020: 001a 1906 b900 3301 00c0 0035 3a05 b200 0000030: 3b19 05b6 003f b600 4519 06b9 0049 0100 0000040: 9aff e2b2 003b 124b b600 45b1
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Original comment by gdel...@gmail.com
on 18 Dec 2014 at 12:34
The problem seems to come from the transformer class
org.powermock.modules.agent.DefinalizingClassTransformer which rewrites the
bytecode of class when loading. I guess there is something wrong in the
rewriting from the ClassWriter or PowerMockClassVisitor classes but for now I
don't have enough knowledge nor time to tell where is the problem.
Original comment by gdel...@gmail.com
on 19 Dec 2014 at 10:32
Also for the moment I found a workaround/fix (don't know if there is a way to
fix the agent to make it work without the flag). I explain here
(http://www.notonlyanecmplace.com/java-7-enforces-bytecode-verification/) but
basically you can just disable the bytecode verification on IBM JRE or fallback
to the old one on SUN JRE. I'll try to see if there is a better fix so it
passes the verification, but help from the author would be nice because it is a
bit too much for me now :)
Original comment by gdel...@gmail.com
on 19 Dec 2014 at 10:36
Original issue reported on code.google.com by
gdel...@gmail.com
on 2 Dec 2014 at 5:23