-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.5
-
Verified
Name: dfC67450 Date: 06/29/98
java.text.FieldPosition.hashCode() returns different results on the equal objects.
This behaviour is inconsistent with the specification.
JLS 1.0 item 20.1.4 says:
If two objects are equal according to the equals method (20.1.3),
then calling the hashCode method on each of the two objects must
produce the same integer result.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
public class Test {
public static void main (String args[]){
FieldPosition c1 = new FieldPosition(0);
FieldPosition c2 = new FieldPosition(0);
int hc1 = c1.hashCode();
int hc2 = c2.hashCode();
if (c1.equals(c2) & hc1 != hc2) {
System.out.println("Test failed");
System.out.println(" hashCode1: " + hc1);
System.out.println(" hashCode2: " + hc2);
} else {
System.out.println("Test passed");
}
}
}
---------Output from the test---------------------
Test failed
hashCode1: 825574528
hashCode2: 822690944
-------------------------------------------------
======================================================================