You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Nathan Beyer (JIRA)" <ji...@apache.org> on 2006/06/04 20:11:30 UTC

[jira] Commented: (HARMONY-403) HashMap hashcode ignores values in entries

    [ http://issues.apache.org/jira/browse/HARMONY-403?page=comments#action_12414657 ] 

Nathan Beyer commented on HARMONY-403:
--------------------------------------

According to the Object.hashCode() specification this is not a guaranteed property [1].

# It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables. 

Is there some behavior you've found that requires this to be true?

> HashMap hashcode ignores values in entries
> ------------------------------------------
>
>          Key: HARMONY-403
>          URL: http://issues.apache.org/jira/browse/HARMONY-403
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Mark Hindess
>     Priority: Minor
>  Attachments: fix.hashmap.hashcode.diff, hashmap.hashcodes.should.differ.diff
>
> While it is obviously trivial to create different HashMaps with identical hashCodes, I'd still expect the following test code to pass:
>   HashMap map1 = new HashMap(10);
>   HashMap map2 = new HashMap(10);
>   map1.put("key", "1");
>   map2.put("key", "2");
>   assertFalse(map1.hashCode() == map2.hashCode());
> That is, I'd expect the 'value' associated with "key" to have some impact on the hashCode.  It passes on the reference implementations I tested.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira