Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4170619

Many classes violate Object.hashCode contract

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.0
    • client-libs
    • None
    • generic
    • generic

          The AffineTransform, Dimension, Insets, ColorModel, ComponentColorModel, PackedColorModel, AlphaComposite and BasicStroke classes override Object.equals but not Object.hashCode. This violates the restriction that:

      a.equals(b) ==> a.hashCode()==b.hashCode()

      If our customers use objects of any of these classes as keys in Hashtables or
      HashMaps, or elements in HashSets, the basic invariants of the collections will
      be corrupted, leading to erratic behavior.

            lbunnisunw Lara Bunni (Inactive)
            jjb Josh Bloch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: