2

I am using BCEL for ByteCode generation, I just want to print out (println) before every line in the static methods of the input class. I tried instrumentation using BCEL but it result in different form of errors. It says

Exception in thread "main" java.lang.VerifyError: StackMapTable error: bad offset in method C.max(Ljava/lang/String;II)I

Sometimes it start working if I place some static method call on any instruction and sometime it not. Any help would be really appreciated...

Update: I fixed it. It was not something with the BCEL library, it was JDK version (1.7) which is not verifying my instrumented classes. So if someone encounter such problem either use JDK 1.6 or use the JVM option "-XX:-UseSplitVerifier".

Cheers

Sarmad
  • 21
  • 3

2 Answers2

1

The StackMapTable is a feature introduced in 50.0 and made mandatory in 51.0 that is intended to speed up classfile verification by including metadata about the types at various points in the code. Unfortunately, it is a pain to write or adjust by hand, so unless you're using a tool which will automatically generate it, you're best off just removing it entirely.

In order to omit the StackMapTable, you'll need to change the class to version 50.0 or earlier. But this shouldn't be a real problem, since the only features added in 51.0 are invokedynamic and its relations, which aren't ever used by compiled Java.

Antimony
  • 37,781
  • 10
  • 100
  • 107
0

I have similar problem at the moment using BCEL and I just want to note that JVM -XX:-UseSplitVerifier arg is no longer available in Java 8.

Monika X
  • 322
  • 4
  • 13