United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-5061402 REGRESSION: SwingUtilities.getAncestorOfClass generics problem
JDK-5061402 : REGRESSION: SwingUtilities.getAncestorOfClass generics problem

Details
Type:
Bug
Submit Date:
2004-06-10
Status:
Resolved
Updated Date:
2004-06-22
Project Name:
JDK
Resolved Date:
2004-06-22
Component:
client-libs
OS:
windows_xp,windows_2000
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (b57)

Related Reports

Sub Tasks

Description

Name: rmT116609			Date: 06/10/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
In Java 1.5 the API for SwingUtilities.getAncestorOfClass changed to make use of generics.  The class type to search for now must be a subclass of Container where previously it could be an interface.

This did work in 1.4 and earlier as the class passed into the method had no effect on the requirements of the returned class.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the following:

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compile.
ACTUAL -
Compilation error.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:11: <T>getAncestorOfClass(java.lang.Class<T>,java.awt.Component) in javax.swing.SwingUtilities cannot be applied to (java.lang.Class<Test.TestInterface>,javax.swing.JButton)
    TestInterface ti = (TestInterface)SwingUtilities.getAncestorOfClass( TestInterface.class, b );
                                                    ^
1 error

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import javax.swing.JButton;
import javax.swing.SwingUtilities;
public class Test
{

  public void test()
  {
    JButton b = new JButton();
    // ... do something to build a complex gui where
    //     something implementing TestInterface is a parent of b.
    TestInterface ti = (TestInterface)SwingUtilities.getAncestorOfClass( TestInterface.class, b );
  }

  private interface TestInterface
  {
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None.  Since the class object passed in MUST be for something that subclasses Container no workaround is possible.

Release Regression From : 1.4.2_04
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 277051) 
======================================================================

                                    

Comments
EVALUATION

A valid complaint. We need to relax the constraint on the type of class that can be passed to this method.
###@###.### 2004-06-10
                                     
2004-06-10
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-rc

FIXED IN:
tiger-rc

INTEGRATED IN:
tiger-b57
tiger-rc


                                     
2004-06-25



Hardware and Software, Engineered to Work Together