Bug 24258 - Mistake in "Peephole optimizer" example at http://jakarta.apache.org/bcel/manual.html
Summary: Mistake in "Peephole optimizer" example at http://jakarta.apache.org/bcel/man...
Status: RESOLVED FIXED
Alias: None
Product: BCEL - Now in Jira
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.1
Hardware: Other other
: P4 normal
Target Milestone: ---
Assignee: issues@commons.apache.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-30 16:28 UTC by Thai Ha
Modified: 2007-03-10 07:41 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thai Ha 2003-10-30 16:28:27 UTC
The example "Peephole optimizer" (at 
http://jakarta.apache.org/bcel/manual.html) has the following code:

 InstructionHandle[] match = (InstructionHandle[])e.next();

 This is wrong. The variable "e" should be written as "i". In other words, it 
should be changed to:

 InstructionHandle[] match = (InstructionHandle[])i.next();
Comment 1 Thai Ha 2003-10-30 16:39:11 UTC
 Please ignore my previous comment. This class have some other mistakes also. 
Please fix all the bugs and try to compile it.
Comment 2 Torsten Curdt 2006-01-27 14:13:33 UTC
I know this was literally years ago ...but do you remember what you meant with "This class have some 
other mistakes also"
Comment 3 Thai Ha 2006-02-03 03:44:49 UTC
I meant if we change 
InstructionHandle[] match = (InstructionHandle[])e.next();
to
InstructionHandle[] match = (InstructionHandle[])i.next();

we still have another error "Duplicate Parameter e" at the line
      } catch(TargetLostException e) {

So we should change that variable name to something else (e.g. "it")
    for (Iterator it = f.search(pat); it.hasNext();) {
      InstructionHandle[] match = (InstructionHandle[]) it.next();