DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19784>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19784
StackMapType.printIndex fails if index is -1
Summary: StackMapType.printIndex fails if index is -1
Product: BCEL
Version: unspecified
Platform: All
URL: http://cvs.apache.org/viewcvs/jakarta-
bcel/src/java/org/apache/bcel/classfile/StackMapType.jav
a?rev=1.2&content-type=text/vnd.viewcvs-markup
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Main
AssignedTo: [email protected]
ReportedBy: [email protected]
There are circumstances where a StackMapType might have an index of -1.
Unfortunately, the printIndex method in StackMapType has problems with this.
The fix is simple:
Original code:
private String printIndex() {
if(type == Constants.ITEM_Object)
return ", class=" + constant_pool.constantToString(index,
Constants.CONSTANT_Class);
else if(type == Constants.ITEM_NewObject)
return ", offset=" + index;
else
return "";
}
Proposed fix:
private String printIndex() {
if(type == Constants.ITEM_Object) {
if(index == -1) {
return ", class=<unknown>";
} else {
return ", class=" + constant_pool.constantToString(index,
Constants.CONSTANT_Class) + "(" + index + ")";
}
} else if(type == Constants.ITEM_NewObject) {
if(index == -1) {
return ", offset=<unknown>";
} else {
return ", offset=" + index;
}
} else {
return "";
}
}
One could also argue that the ConstantPool.constantToString methods should be
fixed as well, though it could also be argued that such cases should fail. In
the case of StackMapType.printIndex, the case is much clearer.
P.S. While I'm at this, Bugzilla for BCEL doesn't have an option to select
version 5.1 of BCEL. This particular bug is in both 5.0 and 5.1.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.