commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Bourg (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (BCEL-114) Error in method search() defined in org.apache.bcel.util.InstructionFinder
Date Thu, 24 Apr 2014 09:13:15 GMT

     [ https://issues.apache.org/jira/browse/BCEL-114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Emmanuel Bourg updated BCEL-114:
--------------------------------

         Priority: Major
      Environment:     (was: Operating System: Windows XP
Platform: Other)
    Fix Version/s: 6.0
         Priority:   (was: P2)
         Severity:   (was: normal)

> Error in method search() defined in org.apache.bcel.util.InstructionFinder
> --------------------------------------------------------------------------
>
>                 Key: BCEL-114
>                 URL: https://issues.apache.org/jira/browse/BCEL-114
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 5.2
>            Reporter: Chen Yue
>            Assignee: Apache Commons Developers
>             Fix For: 6.0
>
>         Attachments: ErrorUseCase.rar
>
>
> 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, what’s 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, we’ll 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;”.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message