Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2027105 | 1.4.0 | Jennifer Ball | P4 | Resolved | Fixed | beta2 |
Name: vi73552 Date: 05/18/99
The class java.awt.Point states the following in its
JavaDoc comments for the equals method:
@return "true if the object to be compared is an instance of Point
and has the same values; false otherwise."
But the implementation can sometimes return true if
the object being compared to is NOT an instance of Point,
contrary to what the JavaDoc says.
Example Code:
import java.awt.*;
import java.awt.geom.*;
public class Test {
public static void main(String[] args) {
Point p1 = new Point(10,10);
Point2D p2 = new Point2D.Double(10L,10L);
System.out.println("p1 == p2 --> " + (p1 == p2));
System.out.println("p1.getClass() --> " + p1.getClass());
System.out.println("p2.getClass() --> " + p2.getClass());
System.out.println("p2 instanceof Point --> " +
(p2 instanceof Point));
System.out.println("p1.equals(p2) --> " + p1.equals(p2));
System.out.println("p2.equals(p1) --> " + p2.equals(p1));
}
}
///////////
Output:
D:\temp>java Test
p1 == p2 --> false
p1.getClass() --> class java.awt.Point
p2.getClass() --> class java.awt.geom.Point2D$Double
p2 instanceof Point --> false
p1.equals(p2) --> true
p2.equals(p1) --> true
//////////////////////
D:\temp>java -version
java version "1.2"
HotSpot VM (1.0fcs, mixed mode, build E)
D:\temp>java -fullversion
java full version "JDK-1.2-V"
(Review ID: 83182)
======================================================================
- backported by
-
JDK-2027105 java.awt.Point.equals() implementation does not match spec
-
- Resolved
-