JDK-8013775 : ClassCastException at javax.swing.LayoutComparator.compare
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_2.6
  • CPU: x86
  • Submitted: 2013-04-04
  • Updated: 2014-11-17
  • Resolved: 2013-08-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.
JDK 8
8Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
1.7.0_07 32bit Oracle Corporation


ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.33.3-mac i386 (but issue is os independent)

EXTRA RELEVANT SYSTEM CONFIGURATION :
-Djdk.map.althashing.threshold=0

A DESCRIPTION OF THE PROBLEM :
API call java.awt.Window.isFocusableWindow throws unexpected ClassCastException

REGRESSION.  Last worked in version 6u31

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
Comments
Closing it as a duplicate of JDK-7075600.
26-08-2013

There's also another issue with TimSort usage in swing LayoutComparator: JDK-7075600. That issue is hard to resolve with TimSort enabled. In Arrays.java I'm seeing: /** * Old merge sort implementation can be selected (for * compatibility with broken comparators) using a system property. * Cannot be a static boolean in the enclosing class due to * circular dependencies. To be removed in a future release. */ static final class LegacyMergeSort It seems like it's just the case with broken comparators. So, we should switch to legacy merge sort here.
16-05-2013

Unfortunately, there's no way to set the legacy mode for a single sort() invocation. It can be set only initially and globally via a system property. We can't use it this way...
16-05-2013

Moved as an interesting failure case. A better test case would definitely help with this. Closure might occur shortly, and would not be unexpected, but worth having this on-record.
02-05-2013