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

ColorModel subclasses are missing hashCode() or equals() or both methods

    XMLWordPrintable

Details

    • 2d
    • b158
    • x86
    • linux

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.7.0_01"
        Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
        Java HotSpot(TM) Server VM (build 21.1-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux 3.0.0-12-generic #20-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        IndexColorModel has no specific implementation of "equals", relying on ColorModel's equals method instead. The latter does not check the extra state in IndexColorModel. Hence, the equals behavior of IndexColorModel is incorrect.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create two IndexColorModel instances with different colors and compare them using their equals methods.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The instances should not be equal.
        ACTUAL -
        The instances are reported to be equal.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
          public static void main( String[] args ) {
            IndexColorModel model1 = new IndexColorModel( 8, 3,
                                                          new int[] { 1, 2, 3 },
                                                          0, true, -1, DataBuffer.TYPE_BYTE
                                                          );
            IndexColorModel model2 = new IndexColorModel( 8, 3,
                                                          new int[] { 4, 5, 6 }, // different colors!
                                                          0, true,-1, DataBuffer.TYPE_BYTE
                                                          );
            System.out.println( model1.equals( model2 )); // should return false
          }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Override the equals method and add the necessary checks yourself.

        Attachments

          Issue Links

            Activity

              People

                jdv Jayathirth D V
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: