-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b57
-
x86
-
windows_2000, windows_xp
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)
======================================================================