-
Bug
-
Resolution: Fixed
-
P3
-
7, 8, 9
-
b158
-
x86
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175632 | 10 | Jayathirth D V | P3 | Resolved | Fixed | b02 |
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.
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.
- backported by
-
JDK-8175632 ColorModel subclasses are missing hashCode() or equals() or both methods
-
- Resolved
-
- relates to
-
JDK-6588409 Only one of Object.equals and Object.hashCode overriden
-
- Open
-