Possible bug in FieldInstruction:getFieldSize(). Max stack depth exceeded.
Peter Piela <[email protected]> Wed, 21 Oct 2009 18:21:04 -0400
| Newsgroups | gmane.comp.jakarta.bcel.devel |
|---|---|
| Message-ID | <[email protected]> |
I am running into a possible bug in the BCEL FieldInstruction class. I am w=
orking with an up to date copy of the trunk source code, and am getting a J=
ava 1.5 runtime verification error complaining that the maximum stack depth=
of a method in a BCEL modified class is being exceeded. I traced the behav=
ior to an incorrect "consume" value for a PUTFIELD Lobject; instruction in =
the constructor. The consume value is calculated using the getFieldSize fun=
ction below. Based on the comment (and usage) the getFieldSize function sho=
uld return a value of 1 or 2 words for the size of the value associated wit=
h the instruction. In this case the value should be 1 for an object referen=
ce. However, the Type.getTypeSize() function returns an encoded integer tha=
t contains the type size, and in this case the position of the closing ';'.=
Using this value directly results in an incorrect stack depth.=20
I have been testing a proposed modification to the getFieldSize method (sho=
wn below) that appears to fix the problem. Any feedback would be appreciate=
d.
Thanks. Peter=20
/** @return size of field (1 or 2)
*/
protected int getFieldSize( ConstantPoolGen cpg ) {
// return Type.getTypeSize(getSignature(cpg)); // original code
return Type.getType(getSignature(cpg)).getSize(); // proposed modific=
ation
}
Peter Piela
Director of Development
[email protected]
One Indian Head Plaza
Nashua, NH 03060 USA
Tel: 603.459.2416
Cell: 781.254.4153
ASG | www.asg.com=20
Beyond BSM(tm)=20