commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Roberts (JIRA)" <j...@apache.org>
Subject [jira] [Created] (BCEL-194) LocalVariableGen hashCode() function is incorrrect.
Date Wed, 04 Feb 2015 21:08:35 GMT
Mark Roberts created BCEL-194:
---------------------------------

             Summary: LocalVariableGen hashCode() function is incorrrect.
                 Key: BCEL-194
                 URL: https://issues.apache.org/jira/browse/BCEL-194
             Project: Commons BCEL
          Issue Type: Bug
            Reporter: Mark Roberts


The BCEL API allows a user to change the location of a local variable.  Thus, using 'index'
as part of the hash function is incorrect.

(don't see how to attach a diff so I include it here until I figure out how to use jira -
sorry)

Index: LocalVariableGen.java
===================================================================
--- LocalVariableGen.java       (revision 1651903)
+++ LocalVariableGen.java       (working copy)
@@ -178,5 +178,6 @@
     public int hashCode() {
         //If the user changes the name or type, problems with the targeter hashmap will occur
-        int hc = index ^ name.hashCode() ^ type.hashCode();
+        // Note: index cannot be part of hash as it may be changed by the user.  (markro)
+        int hc = name.hashCode() ^ type.hashCode();
         return hc;
     }




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

Mime
View raw message