Question

I tried to build a profiler using http://www.ibm.com/developerworks/java/library/j-jip/

One of my java applications when executed in command prompt

java -jar abc.jar 

gives required output, but when using a javaagent to profile the same application gives error

java -javaagent:profiler.jar -jar abc.jar 

gives the following error

Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at
branch target 20 in method 
()V at offset 12
        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)

But there are also some swing applications which is running fine with the above javaagent method.

Was it helpful?

Solution

Are you sure you are running your target JVM on JDK6? JDK 7 tightened up the checks performed on stack map frames and this can lead to such VerifyError exceptions when the bytecode has been modified by tools unaware of these changes.

Double check the target JVM and if you find you are using JDK 7 you can either switch to JDK 6 or use "-XX:-UseSplitVerifier" switch to change the verifier back to JDK 6 version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top