United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4634385 : JDK DisplayMode code doesn't respect contract for equals and hashCode

Details
Type:
Bug
Submit Date:
2002-02-07
Status:
Resolved
Updated Date:
2003-09-29
Project Name:
JDK
Resolved Date:
2003-09-29
Component:
client-libs
OS:
generic,windows_2000
Sub-Component:
2d
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
5.0 (tiger)

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
The following problem was originally reported in 4634068.

There are a number of classes that do not respect the
implied contract for equals and hashCode. See, for example,
Joshua Bloch's book "Effective Java", items 7-8.

java.awt.DisplayMode defines
  equals(java.awt.DisplayMode) but doesn't redefine
  equals(Object)

Problems found by applying automatic tools to JDK
libraries. However, manual inspectation of the classes
reveals the same problems.

-- iag@sfbay 2002-02-06

                                    

Comments
EVALUATION

This seems not to be a specific subcategory, but all of the JDK.
###@###.### 2002-02-07

This bug is for the specific class java.awt.DisplayMode.  As stated in the 
evaluation for bug 4634068, all other problems detected in the jdk have been
broken down into bugs for individual areas.  If you do not own 
java.awt.DisplayMode, please pass this bug along to the group that does.

Thanks,
-- iag@sfbay 2002-02-07

Simple solution: just add equals(Object) to DisplayMode.  If the object
is instanceof DisplayMode, call the existing equals(DisplayMode) method,
otherwise return false.

Note that there is also a bug in the current equals() method that should
be fixed: we do not correctly check for a null parameter to equals(DisplayMode) and will throw a NullPointerException if the argument is null (see bug 4529353 for more information on this).  We should fix this at the same time as we are
fixing the API issue.

note also that we do not need to do anything about hashcode() since that
method already exists (and does the right thing) in DisplayMode

###@###.### 2003-09-11

The infinite recursion bug mentioned in the JDC comments has been filed as a new bug (4977139), which has been fixed and will hopefully be in the 1.5 Beta2 release.

###@###.### 2004-01-14
                                     
2004-01-14
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b22


                                     
2004-06-14



Hardware and Software, Engineered to Work Together