javaswingjava-5jsplitpane

Getting java.lang.ClassCastException: javax.swing.KeyStroke when creating a JSplitPane


I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0_08. Note that this does not occur every time, but about 80% of the time:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke
    at java.util.TreeMap.compare(TreeMap.java:1093)
    at java.util.TreeMap.put(TreeMap.java:465)
    at java.util.TreeSet.add(TreeSet.java:210)
    at javax.swing.plaf.basic.BasicSplitPaneUI.installDefaults(BasicSplitPaneUI.java:364)
    at javax.swing.plaf.basic.BasicSplitPaneUI.installUI(BasicSplitPaneUI.java:300)
    at javax.swing.JComponent.setUI(JComponent.java:652)
    at javax.swing.JSplitPane.setUI(JSplitPane.java:350)
    at javax.swing.JSplitPane.updateUI(JSplitPane.java:378)
    at javax.swing.JSplitPane.<init>(JSplitPane.java:332)
    at javax.swing.JSplitPane.<init>(JSplitPane.java:287)
    ...

Thoughts? I've tried cleaning and rebuilding my project so as to minimize the probability of corrupted class files.

Looking at JDK-6434148 : ClassCastException thrown while running SwingSet2 demo, this seems to be a JDK bug. Any known workarounds? None are listed on the bug entry page.


Solution

  • After doing some searching in the Java Bug Database, this looks like this might be a JDK bug that was only fixed in JDK 6.

    See JDK-6434148 : ClassCastException thrown while running SwingSet2 demo.