I find bytecode VerifyErrors
notoriously hard to debug. The JVM gives very little feedback, typically just the current class and sometimes the method.
Some examples of errors I typically encounter when manually engineering bytecode through ASM or Jasmin:
Stack size too large
Unable to pop operand off an empty stack
Falling off the end of the code
Expecting to find object/array on stack
Incompatible object argument for function call
Inconsistent stack height 4 != 2
(To be clear; I know what all of these mean, I'm interested in tools or techniques to debug the cause of them.)
My Question: Is there any tool out there that gives detailed feedback on these types of errors? I would for instance appreciate information such as
javap
-like outputI think you can use CheckClassAdapter(http://asm.ow2.org/asm40/javadoc/user/org/objectweb/asm/util/CheckClassAdapter.html) provided by ASM. It provide more detailed information about verify error.
The Kraktau project I've written is useful for debugging verification errors. It is capable of giving the bytecode offsets where the error occurs, and the stack and local type information for every instruction. It even correctly handles flags and mask information for subroutines. It is capable of catching virtually all errors.
There isn't a specific interface for printing out verification information yet, but if you still me what kind of functionality you want, I can add one. In the meantime, attempting to decompile your class with Krakatau will print out an error message with information about the verification error and the type information of the instruction where it occurred.
Update: Krakatau no longer performs verification due to performance issues. If you want to do verfication, you'll need to checkout commit 3724c05ba11ff6913c01ecdfe4fde6a0f246e5db.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With