JDK-4634385 : JDK DisplayMode code doesn't respect contract for equals and hashCode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_2000
  • CPU: generic,x86
  • Submitted: 2002-02-07
  • Updated: 2017-05-16
  • Resolved: 2003-09-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
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
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b22
14-06-2004

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
14-01-2004