--- old/src/java.desktop/share/classes/java/awt/image/ColorModel.java 2016-06-03 14:50:14.676923999 +0530 +++ new/src/java.desktop/share/classes/java/awt/image/ColorModel.java 2016-06-03 14:50:14.468923999 +0530 @@ -31,10 +31,11 @@ import sun.java2d.cmm.CMSManager; import sun.java2d.cmm.ColorTransform; import sun.java2d.cmm.PCMM; -import java.awt.Toolkit; +import java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; +import java.util.Objects; /** * The {@code ColorModel} abstract class encapsulates the @@ -170,6 +171,7 @@ int colorSpaceType = ColorSpace.TYPE_RGB; int maxBits; boolean is_sRGB = true; + private volatile int hashCode; /** * Data type of the array used to represent pixel values. @@ -362,7 +364,14 @@ this.transparency = transparency; } - nBits = bits.clone(); + /* + * We need significant bits value only for the length + * of number of components, so we truncate remaining part. + * It also helps in hashCode calculation since bits[] can contain + * different values after the length of number of components between + * two ColorModels. + */ + nBits = Arrays.copyOf(bits, numComponents); this.pixel_bits = pixel_bits; if (pixel_bits <= 0) { throw new IllegalArgumentException("Number of pixel bits must "+ @@ -1441,28 +1450,33 @@ } /** - * Tests if the specified {@code Object} is an instance of - * {@code ColorModel} and if it equals this + * Tests if the specified {@code Object} equals this * {@code ColorModel}. + * In order to protect the symmetry property of + * {@code (a.equals(b) == b.equals(a))}, + * the target object must be the same class(and not a subclass) + * as this object to evaluate as {equals}. * @param obj the {@code Object} to test for equality * @return {@code true} if the specified {@code Object} - * is an instance of {@code ColorModel} and equals this - * {@code ColorModel}; {@code false} otherwise. + * equals this {@code ColorModel}; {@code false} otherwise. */ + @Override public boolean equals(Object obj) { - if (!(obj instanceof ColorModel)) { + if (this == obj) { + return true; + } + if ((obj == null) || (obj.getClass() != getClass())) { return false; } - ColorModel cm = (ColorModel) obj; - if (this == cm) { - return true; - } + ColorModel cm = (ColorModel) obj; if (supportsAlpha != cm.hasAlpha() || isAlphaPremultiplied != cm.isAlphaPremultiplied() || pixel_bits != cm.getPixelSize() || transparency != cm.getTransparency() || - numComponents != cm.getNumComponents()) + numComponents != cm.getNumComponents() || + (!(colorSpace.equals(cm.colorSpace))) || + transferType != cm.transferType) { return false; } @@ -1487,22 +1501,21 @@ * * @return a hash code for this ColorModel. */ + @Override public int hashCode() { - - int result = 0; - - result = (supportsAlpha ? 2 : 3) + - (isAlphaPremultiplied ? 4 : 5) + - pixel_bits * 6 + - transparency * 7 + - numComponents * 8; - - if (nBits != null) { - for (int i = 0; i < numComponents; i++) { - result = result + nBits[i] * (i + 9); - } + int result = hashCode; + if (result == 0) { + result = 7; + result = 89 * result + this.pixel_bits; + result = 89 * result + Arrays.hashCode(this.nBits); + result = 89 * result + this.transparency; + result = 89 * result + (this.supportsAlpha ? 1 : 0); + result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0); + result = 89 * result + this.numComponents; + result = 89 * result + Objects.hashCode(this.colorSpace); + result = 89 * result + this.transferType; + hashCode = result; } - return result; } --- old/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java 2016-06-03 14:50:15.340923999 +0530 +++ new/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java 2016-06-03 14:50:15.088923999 +0530 @@ -28,6 +28,8 @@ import java.awt.Transparency; import java.awt.color.ColorSpace; import java.math.BigInteger; +import java.util.Arrays; +import java.util.Objects; /** * The {@code IndexColorModel} class is a {@code ColorModel} @@ -129,6 +131,7 @@ private int transparent_index = -1; private boolean allgrayopaque; private BigInteger validBits; + private volatile int hashCode; private sun.awt.image.BufImgSurfaceData.ICMColorData colorData = null; @@ -1532,4 +1535,80 @@ + " isAlphaPre = "+isAlphaPremultiplied ); } + + /** + * Tests if the specified {@code Object} equals this + * {@code IndexColorModel}. + * In order to protect the symmetry property of + * {@code (a.equals(b) == b.equals(a))}, + * the target object must be the same class(and not a subclass) + * as this object to evaluate as {equals}. + * @param obj the {@code Object} to test for equality + * @return {@code true} if the specified {@code Object} + * equals this {@code IndexColorModel}; {@code false} otherwise. + */ + @Override + public boolean equals(Object obj) { + /* + * We verify the type of argument obj in super.equals() where we check + * for equality of class name. + */ + if (!super.equals(obj)) { + return false; + } + + IndexColorModel cm = (IndexColorModel) obj; + if (map_size != cm.map_size || + transparent_index != cm.transparent_index) + { + return false; + } + + // verify whether we have to check equality of all bits in validBits + boolean testValidBits; + if (validBits == cm.validBits) { + testValidBits = false; + } else if (validBits == null || cm.validBits == null) { + return false; + } else if (validBits.equals(cm.validBits)) { + testValidBits = false; + } else { + testValidBits = true; + } + + if (testValidBits) { + for (int i = 0; i < map_size; i++) { + if (rgb[i] != cm.rgb[i] || + validBits.testBit(i) != cm.validBits.testBit(i)) + { + return false; + } + } + } else { + for (int i = 0; i < map_size; i++) { + if (rgb[i] != cm.rgb[i]) { + return false; + } + } + } + return true; + } + + /** + * Returns the hash code for IndexColorModel. + * + * @return a hash code for IndexColorModel + */ + @Override + public int hashCode() { + int result = hashCode; + if (result == 0) { + result = super.hashCode(); + result = 43 * result + Arrays.hashCode(this.rgb); + result = 43 * result + this.map_size; + result = 43 * result + this.transparent_index; + hashCode = result; + } + return result; + } } --- old/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java 2016-06-03 14:50:16.192923999 +0530 +++ new/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java 2016-06-03 14:50:15.872923999 +0530 @@ -27,6 +27,7 @@ import java.awt.Transparency; import java.awt.color.ColorSpace; +import java.util.Arrays; /** * The {@code PackedColorModel} class is an abstract @@ -88,6 +89,7 @@ int[] maskArray; int[] maskOffsets; float[] scaleFactors; + private volatile int hashCode; /** * Constructs a {@code PackedColorModel} from a color mask array, @@ -385,19 +387,22 @@ } /** - * Tests if the specified {@code Object} is an instance - * of {@code PackedColorModel} and equals this + * Tests if the specified {@code Object} equals this * {@code PackedColorModel}. + * In order to protect the symmetry property of + * {@code (a.equals(b) == b.equals(a))}, + * the target object must be the same class(and not a subclass) + * as this object to evaluate as {equals}. * @param obj the {@code Object} to test for equality * @return {@code true} if the specified {@code Object} - * is an instance of {@code PackedColorModel} and equals this - * {@code PackedColorModel}; {@code false} otherwise. + * equals this {@code PackedColorModel}; {@code false} otherwise. */ + @Override public boolean equals(Object obj) { - if (!(obj instanceof PackedColorModel)) { - return false; - } - + /* + * We verify the type of argument obj in super.equals() where we check + * for equality of class name. + */ if (!super.equals(obj)) { return false; } @@ -412,6 +417,22 @@ return true; } + /** + * Returns the hash code for this PackedColorModel. + * + * @return a hash code for this PackedColorModel. + */ + @Override + public int hashCode() { + int result = hashCode; + if (result == 0) { + result = super.hashCode(); + result = 89 * result + Arrays.hashCode(this.maskArray); + hashCode = result; + } + return result; + } + private static final int[] createBitsArray(int[]colorMaskArray, int alphaMask) { int numColors = colorMaskArray.length; --- old/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java 2016-06-03 14:50:16.788923999 +0530 +++ new/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java 2016-06-03 14:50:16.624923999 +0530 @@ -2925,24 +2925,4 @@ raster.getHeight(), x, y, band); } - - /** - * Compares this color model with another for equality. - * - * @param obj The object to compare with this color model. - * @return {@code true} if the color model objects are equal, - * {@code false} if they are not. - */ - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - - if (obj.getClass() != getClass()) { - return false; - } - - return true; - } - } --- /dev/null 2016-06-03 14:30:46.346512000 +0530 +++ new/test/java/awt/image/IndexColorModel/IndexColorModelEqualsTest.java 2016-06-03 14:50:17.144923999 +0530 @@ -0,0 +1,328 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7107905 + * @summary Test verifies whether equals() and hashCode() methods in + * IndexColorModel works properly for IndexColorModel unique + * properties. + * @run main IndexColorModelEqualsTest + */ + +import java.awt.image.DataBuffer; +import java.awt.image.IndexColorModel; +import java.math.BigInteger; + +public class IndexColorModelEqualsTest { + + private static void testColorMapEquality() { + // test with different cmap values. + 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}, + 0, true, -1, DataBuffer.TYPE_BYTE); + if (model1.equals(model2)) { + throw new RuntimeException("equals() method is determining" + + " ColorMap equality improperly"); + } + if (model2.equals(model1)) { + throw new RuntimeException("equals() method is determining" + + " ColorMap equality improperly"); + } + } + + private static void testSizeEquality() { + // test with different size for cmap. + IndexColorModel model1 = new IndexColorModel(8, 4, + new int[] {1, 2, 3, 4}, + 0, true, -1, DataBuffer.TYPE_BYTE); + IndexColorModel model2 = new IndexColorModel(8, 3, + new int[] {1, 2, 3}, + 0, true, -1, DataBuffer.TYPE_BYTE); + if (model1.equals(model2)) { + throw new RuntimeException("equals() method is determining" + + " Map size equality improperly"); + } + if (model2.equals(model1)) { + throw new RuntimeException("equals() method is determining" + + " Map size equality improperly"); + } + } + + private static void testTransparentIndexEquality() { + // test with different values for transparent_index. + 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[] {1, 2, 3}, + 0, true, 2, DataBuffer.TYPE_BYTE); + if (model1.equals(model2)) { + throw new RuntimeException("equals() method is determining" + + " TransparentIndex equality improperly"); + } + if (model2.equals(model1)) { + throw new RuntimeException("equals() method is determining" + + " TransparentIndex equality improperly"); + } + } + + private static void testValidPixelsEquality() { + // test with different valid pixels. + /* + * In setRGBs() function of IndexColorModel we override + * transparent_index value to map to pixel value if alpha is 0x00 + * so we should have atleast minimum alpha value to verify + * equality of validBits thats why we have color value as + * 16777216(2 ^ 24). + */ + int color = 16777216; + IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {color, + color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("1")); + IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {color, + color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("2")); + if (model1.equals(model2)) { + throw new RuntimeException("equals() method is determining" + + " Valid pixels equality improperly"); + } + if (model2.equals(model1)) { + throw new RuntimeException("equals() method is determining" + + " Valid pixels equality improperly"); + } + } + + private static void testConstructor1() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b) + */ + IndexColorModel model1 = new IndexColorModel(8, 2, + new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2}); + IndexColorModel model2 = new IndexColorModel(8, 2, + new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2}); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testConstructor2() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, + * byte[] a) + */ + IndexColorModel model1 = new IndexColorModel(8, 2, new byte[] {1, 2}, + new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2}); + IndexColorModel model2 = new IndexColorModel(8, 2, new byte[] {1, 2}, + new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2}); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testConstructor3() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, + * int trans) + */ + IndexColorModel model1 = new IndexColorModel(8, 2, new byte[] {1, 2}, + new byte[] {1, 2}, new byte[] {1, 2}, 1); + IndexColorModel model2 = new IndexColorModel(8, 2, new byte[] {1, 2}, + new byte[] {1, 2}, new byte[] {1, 2}, 1); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testConstructor4() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, byte[] cmap, int start, + * boolean hasalpha) + */ + IndexColorModel model1 = new IndexColorModel(8, 1, + new byte[] {1, 2, 3, 4}, 0, true); + IndexColorModel model2 = new IndexColorModel(8, 1, + new byte[] {1, 2, 3, 4}, 0, true); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testConstructor5() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, byte[] cmap, int start, + * boolean hasalpha, int trans) + */ + IndexColorModel model1 = new IndexColorModel(8, 1, + new byte[] {1, 2, 3, 4}, 0, true, 0); + IndexColorModel model2 = new IndexColorModel(8, 1, + new byte[] {1, 2, 3, 4}, 0, true, 0); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testConstructor6() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, int[] cmap, int start, + * boolean hasalpha, int trans, int transferType) + */ + 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[] {1, 2, 3}, + 0, true, -1, DataBuffer.TYPE_BYTE); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testConstructor7() { + /* + * verify equality with constructor + * IndexColorModel(int bits, int size, int[] cmap, int start, + * int transferType, BigInteger validBits) + */ + /* + * In setRGBs() function of IndexColorModel we override + * transparent_index value to map to pixel value if alpha is 0x00 + * so we should have atleast minimum alpha value to keep + * both model1 and model2 same. + */ + int color = 16777216; + IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {color, + color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("1")); + IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {color, + color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("1")); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " IndexColorModels"); + } + } + + private static void testSameIndexColorModel() { + testConstructor1(); + testConstructor2(); + testConstructor3(); + testConstructor4(); + testConstructor5(); + testConstructor6(); + testConstructor7(); + } + public static void main(String[] args) { + /* test whether equals() method works properly for parameters + * unique to IndexColorModel. + */ + testColorMapEquality(); + testSizeEquality(); + testTransparentIndexEquality(); + testValidPixelsEquality(); + // verify same IndexColorModel equality using different constructors. + testSameIndexColorModel(); + } +} --- /dev/null 2016-06-03 14:30:46.346512000 +0530 +++ new/test/java/awt/image/PackedColorModel/PackedColorModelEqualsTest.java 2016-06-03 14:50:17.656923999 +0530 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8153943 + * @summary Test verifies whether equals() and hashCode() methods in + * PackedColorModel works properly. + * @run main PackedColorModelEqualsTest + */ + +import java.awt.color.ColorSpace; +import java.awt.image.DataBuffer; +import java.awt.image.DirectColorModel; + +public class PackedColorModelEqualsTest { + + private static void testMaskArrayEquality() { + /* + * Test with different maskArray values, since PackedColorModel + * is abstract we use subclass DirectColorModel. + */ + DirectColorModel model1 = + new DirectColorModel(24, 0x00FF0000, 0x0000FF00, 0x000000FF); + DirectColorModel model2 = + new DirectColorModel(24, 0x000000FF, 0x0000FF00, 0x00FF0000); + if (model1.equals(model2)) { + throw new RuntimeException("equals() method is determining" + + " ColorMap equality improperly"); + } + if (model2.equals(model1)) { + throw new RuntimeException("equals() method is determining" + + " ColorMap equality improperly"); + } + } + + private static void testConstructor1() { + /* + * verify equality with constructor + * DirectColorModel(int bits, int rmask, int gmask, int bmask, + * int amask) + */ + DirectColorModel model1 = + new DirectColorModel(32, 0xFF000000, 0x00FF0000, + 0x0000FF00, 0x000000FF); + DirectColorModel model2 = + new DirectColorModel(32, 0xFF000000, 0x00FF0000, + 0x0000FF00, 0x000000FF); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " PackedColorModels"); + } + } + + private static void testConstructor2() { + /* + * verify equality with constructor + * DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, + * int bmask, int amask, boolean isAlphaPremultiplied, int transferType) + */ + DirectColorModel model1 = + new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, + false, DataBuffer.TYPE_BYTE); + DirectColorModel model2 = + new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, + false, DataBuffer.TYPE_BYTE); + if (model1.equals(null)) { + throw new RuntimeException("equals(null) returns true"); + } + if (!(model1.equals(model2))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (!(model2.equals(model1))) { + throw new RuntimeException("equals() method is not working" + + " properly"); + } + if (model1.hashCode() != model2.hashCode()) { + throw new RuntimeException("HashCode is not same for same" + + " PackedColorModels"); + } + } + + private static void testSamePackedColorModel() { + testConstructor1(); + testConstructor2(); + } + public static void main(String[] args) { + // test with different mask array. + testMaskArrayEquality(); + // verify PackedColorModel equality using different constructors. + testSamePackedColorModel(); + } +} \ No newline at end of file