Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
5.2
-
None
Description
Methods visitLDC() and visitLDC_W() push no values in the stack frame when the
constant type is a class literal, as can happen with Java 1.5 bytecode. This
leads to a false stack underflow exception happening to a subsequent
instruction:
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.remove(ArrayList.java:390)
at
org.apache.bcel.verifier.structurals.OperandStack.pop(OperandStack.java:135)
at
org.apache.bcel.verifier.structurals.ExecutionVisitor.visitPUTFIELD(ExecutionVisitor.java:1059)
at org.apache.bcel.generic.PUTFIELD.accept(PUTFIELD.java:78)
Moreover, it would be desired to throw an exception when an unknown constant
type is encountered, rather than doing nothing at all.
This bug arises while running JiST/SWANS, a network simulator that relies on
rewriting Java bytecode to implement simulation time. To be more specific, it
arises when running the example UDP test application, launching
jist.runtime.Main with arguments "jist.swans.Main driver.udp".
I've attached a possible patch against its HEAD revision (411573).
Enrico