-
Bug
-
Resolution: Not an Issue
-
P4
-
7u6
-
x86
-
linux_2.6
JAVA VERSION:
1.7.0_07 32bit Oracle Corporation
OS VERSION :
Linux 2.6.33.3-mac i386 (but issue is os independent)
A DESCRIPTION OF THE PROBLEM :
this is a bug in "javax.swing.LayoutComparator.compare". At least the code in there is not fail safe.
The API method called is "java.awt.Windows.isFocusableWindow()", where nothing is stated about thread safety or restriction to be called in EDT. There is a raise condition:
* all child components of the window are enumerated in a list
* when sorting this list there is a <null> component or a component which isn't in any window hierarchy
In this case " javax.swing.LayoutComparator.compare" throws a ClassCastException, which is inanely hilarious. <null> or components not 'on' the window should be sorted just to the last position.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a window with many components, listeners, etc. and call "isFocusableWindow" on it.
Start VM with jdk.map.althashing.threshold to 0.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No ClassCastException
ACTUAL -
java.lang.ClassCastException
ERROR MESSAGES/STACK TRACES THAT OCCUR :
JDK=1.7.0_07 32bit Oracle Corporation;OS=Linux
2.6.33.3-mac i386;Date=30.10.2012 15:35:27
java.lang.ClassCastException
at javax.swing.LayoutComparator.compare(LayoutComparator.java:75)
at javax.swing.LayoutComparator.compare(LayoutComparator.java:42)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:329)
at java.util.TimSort.sort(TimSort.java:189)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycle(SortingFocusTraversalPolicy.java:136)
at
javax.swing.SortingFocusTraversalPolicy.getFocusTraversalCycle(SortingFocusTraversalPolicy.java:110)
at
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocusTraversalPolicy.java:435)
at
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusTraversalPolicy.java:166)
at
javax.swing.SortingFocusTraversalPolicy.getDefaultComponent(SortingFocusTraversalPolicy.java:515)
at java.awt.Window.isFocusableWindow(Window.java:2476)
REPRODUCIBILITY :
This bug can be reproduced occasionally.
CUSTOMER SUBMITTED WORKAROUND :
disable tim sort