I'm using dirtyJOE to edit a method of a class file.

The original class file had some encryption method calls and such. I've changed the byte-code of the method ldc (byte-code: 12 1E) to load true and return(byte-code: 12 1E)

apparently, Java's verifier is upset with my changes and it complains of verification error:

java.lang.VerifyError: Expecting a stack map frame in method [methodName] at offset 2 at.. at..

I was wondering if there is a way to fool the jvm to think that there is a stack map frame?

thank you

  • Could you post the classfile you're trying to edit please?
    – Antimony
    Mar 4, 2014 at 21:42

1 Answer 1


If the original class was not using StackMapTables, then there should be no problem, assuming you modified the bytecode correctly. Even if it is using them, it is usually possible to just remove them and revert to the old behavior. Assuming that the class does not use invokedynamic, you can just change the version back to 49.0 and delete the StackMapTable attributes.

Unfortunately, version 51.0 mandates usage of StackMapTable, which is a pain to create when manually editing bytecode. If your class actually is making use of 51.0 features (i.e. invokedynamic) then your only option is to create the appropriate stack frames. In a simple case like this, you could do it by hand, but in general you're best off using a tool to generate the stack frames automatically.

  • Could you please reference me to ways of achieving what you mentioned?.(Changing the version and creating stack frames)
    – aclowkay
    Mar 6, 2014 at 5:37
  • @user Well that depends on how you're editing the files of course. I'm not familiar with DirtyJOE, but I could tell you how to do it in Krakatau. I imagine DirtyJOE has similar features.
    – Antimony
    Mar 6, 2014 at 14:03
  • Yes, I would like to know how to do that with Krakatau
    – aclowkay
    Mar 29, 2014 at 17:43
  • @user The easiest way is to disassemble it, change the version number at the top of the assembly file to 49 0 and then reassemble. If you want to preserve debugging information, you also need to comment out lines 273-274 of disassembler.py. If you want to remove stack frames as well as changing the version, add the line return {} to the top of the getStackMapTable function.
    – Antimony
    Mar 29, 2014 at 20:29
  • Sorry for very late response. but it worked. thanks
    – aclowkay
    Jun 3, 2014 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.