-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
x86
-
solaris_10
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0-rc-b95)
ADDITIONAL OS VERSION INFORMATION :
this goes for any OS
A DESCRIPTION OF THE PROBLEM :
The UI delegates can install client properties but in some cases they do not uninstall the client properties they have put in place. An example would be the BasicComboBoxUI. It adds client properties but never takes them away. This would be a leak if a JComboBox uses a basic derivative at one point but during later sessions based off of deserialization does not use a basic UI derivative. Of course, this assumes that basic is not loaded if its not used.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this test, see that once the UI is set to null the UI set key of "doNotCancelPopup" persists.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect only "AncestorNotifier" to remain
ACTUAL -
doNotCancelPopup persists
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
public class ShowUIClientPropertyProblem implements Runnable{
public void run(){
JComboBox jcb = new JComboBox();
Object[] table = getClientProperties(jcb);
System.out.println(Arrays.deepToString(table));
System.out.println(jcb.getUI());
jcb.setUI(null); //uninstalled, client property should be cleared out
table = getClientProperties(jcb);
System.out.println(Arrays.deepToString(table));
System.out.println(jcb.getUI());
}
Object[] getClientProperties(JComponent jc){
try{
Class c = JComponent.class;
Method m = c.getDeclaredMethod("getClientProperties");
m.setAccessible(true);
Object at = m.invoke(jc);
Class c2 = at.getClass();
Method m2 = c2.getDeclaredMethod("getKeys", Object[].class);
m2.setAccessible(true);
Object[] rv = (Object[])m2.invoke(at, new Object[]{null});
return rv;
} catch(Exception x){ x.printStackTrace(); }
return null;
}
public static void main(String ... args){
SwingUtilities.invokeLater(new ShowUIClientPropertyProblem());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
unknown, it may be difficult for the user to programmatically determine which properties need ot be nulled out. In some cases it may be impossible if the key is private and unique one.
Java(TM) SE Runtime Environment (build 1.6.0-rc-b95)
ADDITIONAL OS VERSION INFORMATION :
this goes for any OS
A DESCRIPTION OF THE PROBLEM :
The UI delegates can install client properties but in some cases they do not uninstall the client properties they have put in place. An example would be the BasicComboBoxUI. It adds client properties but never takes them away. This would be a leak if a JComboBox uses a basic derivative at one point but during later sessions based off of deserialization does not use a basic UI derivative. Of course, this assumes that basic is not loaded if its not used.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this test, see that once the UI is set to null the UI set key of "doNotCancelPopup" persists.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect only "AncestorNotifier" to remain
ACTUAL -
doNotCancelPopup persists
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
public class ShowUIClientPropertyProblem implements Runnable{
public void run(){
JComboBox jcb = new JComboBox();
Object[] table = getClientProperties(jcb);
System.out.println(Arrays.deepToString(table));
System.out.println(jcb.getUI());
jcb.setUI(null); //uninstalled, client property should be cleared out
table = getClientProperties(jcb);
System.out.println(Arrays.deepToString(table));
System.out.println(jcb.getUI());
}
Object[] getClientProperties(JComponent jc){
try{
Class c = JComponent.class;
Method m = c.getDeclaredMethod("getClientProperties");
m.setAccessible(true);
Object at = m.invoke(jc);
Class c2 = at.getClass();
Method m2 = c2.getDeclaredMethod("getKeys", Object[].class);
m2.setAccessible(true);
Object[] rv = (Object[])m2.invoke(at, new Object[]{null});
return rv;
} catch(Exception x){ x.printStackTrace(); }
return null;
}
public static void main(String ... args){
SwingUtilities.invokeLater(new ShowUIClientPropertyProblem());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
unknown, it may be difficult for the user to programmatically determine which properties need ot be nulled out. In some cases it may be impossible if the key is private and unique one.
- duplicates
-
JDK-6448691 Swing component defaults should be re-initialized with UI switches
-
- Open
-