DO NOT REPLY [Bug 43732] New: - Error in method search() defined in org.apache.bcel.util.InstructionFinder
[email protected] Tue, 30 Oct 2007 00:40:57 -0700 (PDT)
| Newsgroups | gmane.comp.jakarta.bcel.devel |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43732>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=43732
Summary: Error in method search() defined in
org.apache.bcel.util.InstructionFinder
Product: BCEL
Version: 5.2
Platform: Other
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Main
AssignedTo: [email protected]
ReportedBy: [email protected]
While Peephole.java is a small program in the manual to remove NOP
instructions in any class file, it uses the method search() defined in
org.apache.bcel.util.InstructionFinder with string pattern NOP+ to locate the
NOP instructions in the instructionList. After several tests, I found the
search() method will always find one more instruction after the expected
instructions, whats more, it will raise a
java.lang.ArrayIndexOutOfBoundsException if the expected instruction is at the
end of the method.
After reading the source-code of org.apache.bcel.util.InstructionFinder, I found
there is something wrong when we calculate the length of the match[] array.
In the codes of how to get the match[] array. The startExpr is the first index
of the NOP instruction, and the endExpr is the first index of the non-NOP
instruction. So the real length of the match[] should be endExpr-startExpr. But
we use endExpr-startExpr+1 as the length of the array. So instead of getting the
expected match[] array, well get an one-instruction-longer match[] in the
instructionList incorrectly.
As a result, I guess if the statement int lenExpr = (endExpr - startExpr) + 1;
should be replaced by int lenExpr =endExpr - startExpr;.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.