ClassCastException in LayoutFocusTraversalPolicy

Elmar Frerichs java at devonfrosch.eu
Sun Oct 24 16:18:04 UTC 2021


Hello,

I am new to the whole process of java development and bug reporting, and 
I hope this is the right place for my request - if not please tell me :-)

A project I am currently working on uses custom implementations of 
ButtonModel as a model for javax.swing.JToggleButton. Until JRE 
8u301-b09, this worked fine, but with the latest version (JRE 8u311-b11, 
especially the build by java.com for Windows x64) the app in some 
occasions crashes with a ClassCastException. I dug through the source 
code and the OpenJDK bug tracker to find out more about it, and found 
the following bug report:

https://bugs.openjdk.java.net/browse/JDK-8182577

As it turns out, the stack trace matches the one of my project, and the 
Snippet for reproducing the bug now also fails in JRE 8u311-b11.

If I understood the connections correctly, the bug of JDK-8182577 was 
introduced to JRE 9 by the fix from JDK-8154043 
(https://bugs.openjdk.java.net/browse/JDK-8154043). This bug has a 
backport ticket for JDK 8u311, but without a hg changeset attached 
(https://bugs.openjdk.java.net/browse/JDK-8268519).

I am a bit confused that the source code in hg for 
LayoutFocusTraversalPolicy.java 
(http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/00cd9dc3c2b5/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java) 
does not mention the ToggleButtonModel at all - it seems that at least 
in hg the backport was never applied? Or is hg out of date here? Or did 
I miss a switch somewhere?

Anyways, I would appreciate any feedback on whether others can reproduce 
the bug with the snippet of JDK-8182577 in JRE 8u311-b11 as well or if I 
might have done something else wrong.

Thanks,
Elmar



More information about the jdk8u-dev mailing list