[ 
https://issues.apache.org/jira/browse/BCEL-195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14717742#comment-14717742
 ] 

Sebb commented on BCEL-195:
---------------------------

URL: http://svn.apache.org/r1698243
Log:
BCEL-195 addition of hashCode() to generic/Instruction.java breaks Targeters. 
Never make distinct BranchInstructions compare equal

Modified:
    commons/proper/bcel/trunk/src/changes/changes.xml
    
commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionComparator.java
    
commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/generic/InstructionHandleTestCase.java

I thought better of the equality short-cut check  (added as an afterthought).
Although that check would make sense for ordinary HashSet usage, the conditions 
here are different.
The test still passed, but I suspect it would cause problems.

[We could still add the equality check after rejecting BIs]

URL: http://svn.apache.org/r1698244
Log:
BCEL-195 addition of hashCode() to generic/Instruction.java breaks Targeters. 
Never make BranchInstructions compare equal
Revert short-cut equality check because that would allow a single BI to be 
shared.

Modified:
    
commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionComparator.java


> addition of hashCode() to generic/Instruction.java breaks Targeters
> -------------------------------------------------------------------
>
>                 Key: BCEL-195
>                 URL: https://issues.apache.org/jira/browse/BCEL-195
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 6.0
>            Reporter: Mark Roberts
>         Attachments: compare.diff, select-init.diff
>
>
> [Revision 1532198|http://svn.apache.org/r1532198] added a {{hashCode()}} 
> function to the Instruction class.  Unfortunately, this breaks the 
> Instruction targeting mechanism. I understand the goal of trying to reuse 
> instructions - an 'iadd' is the same as any other 'iadd'.  However,  one 
> 'goto 50' is not the same as another 'goto 50' due to the way Targeters are 
> implemented.  If branch instructions are reused, then only one entry gets put 
> on the Targeter list.  So when some api is used to modify the instruction 
> list and location 50 becomes location 52 ONLY ONE of the branches gets 
> updated. A very bad thing.  So unless you modify the hash to special case 
> branch instructions (and there might be other instructions needing special 
> treatment as well) its broken.  We fixed it by simply commenting the hash out 
> to make things like they used to be and all works great.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to