JDK-4977139 : Inifinite loop possible in DisplayMode.equals(Object)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2004-01-13
  • Updated: 2004-01-26
  • Resolved: 2004-01-26
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 b36Fixed
Related Reports
Relates :  
Description
If DisplayMode.equals is called with an Object (versus and actual
DisplayMode) and if that object is actually a DisplayMode, then the
following code will cause infinite recursion:
	if (dm instanceof DisplayMode) {
	    return equals(dm);
        }

The following code demonstrates the problem; when we perform the first equals()
test on a generic Object (dm0.equals(obj0)), the application gets into an infinite loop.

import java.awt.*;

public class DMTest {

    public static void main(String args[]) {
        DisplayMode dm0 = new DisplayMode(1024, 768, 32, 60);
        DisplayMode dm1 = new DisplayMode(1024, 768, 32, 60);
        DisplayMode dm2 = new DisplayMode(1024, 768, 32, 75);
        Object obj0 = (Object)dm0;
        Object obj1 = (Object)dm1;
        Object obj2 = (Object)dm2;
        System.out.println("dm0.equals(dm1) = " + dm0.equals(dm1));
        System.out.println("dm1.equals(dm0) = " + dm1.equals(dm0));
        System.out.println("dm0.equals(dm2) = " + dm0.equals(dm2));
        System.out.println("dm2.equals(dm0) = " + dm2.equals(dm0));
        System.out.println("dm1.equals(dm2) = " + dm1.equals(dm2));
        System.out.println("dm2.equals(dm1) = " + dm2.equals(dm1));
        System.out.println("dm0.equals(obj0) = " + dm0.equals(obj0));
        System.out.println("dm0.equals(obj1) = " + dm0.equals(obj1));
        System.out.println("dm0.equals(obj2) = " + dm0.equals(obj2));
        System.out.println("dm1.equals(obj0) = " + dm1.equals(obj0));
        System.out.println("dm1.equals(obj1) = " + dm1.equals(obj1));
        System.out.println("dm1.equals(obj2) = " + dm1.equals(obj2));
        System.out.println("dm2.equals(obj0) = " + dm2.equals(obj0));
        System.out.println("dm2.equals(obj1) = " + dm2.equals(obj1));
        System.out.println("dm2.equals(obj2) = " + dm2.equals(obj2));
        System.out.println("Passed");
    }
}


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b36 tiger-beta2
14-06-2004

WORK AROUND Casting to DisplayMode prior to calling equals() will work around the bug
11-06-2004

EVALUATION Change current buggy line of code to simply cast dm to (DisplayMode) prior to calling equals: if (dm instanceof DisplayMode) { return equals((DisplayMode)dm); } This calls the other equals() method and avoids the current infinite recursion. ###@###.### 2004-01-12
12-01-2004