Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-403

HashMap hashcode ignores values in entries

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None
    • Estimated Complexity:
      Moderate

      Description

      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.

        Attachments

        1. fix.hashmap.hashcode.diff
          0.7 kB
          Mark Hindess
        2. hashmap.hashcodes.should.differ.diff
          1 kB
          Mark Hindess

          Issue Links

            Activity

              People

              • Assignee:
                nbeyer Nathan Beyer
                Reporter:
                hindessm Mark Hindess
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: