JDK-6259207 : Reg. ClassCastException thrown in JInternalFrame constructor in headless mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_8
  • CPU: generic,x86
  • Submitted: 2005-04-21
  • Updated: 2012-03-23
  • Resolved: 2005-07-12
Related Reports
Duplicate :  
Description
JInternalFrame constructor throws ClassCastException, in headless mode. This is a regression in mustang b32. The exception is not thrown till b31.

To reproduce, run the code below in headless mode (-Djava.awt.headless=true):

import javax.swing.*;

public class Test {

    public static void main(String[] args) {
        try {
            JInternalFrame jif = new JInternalFrame("TEST");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

The exception thrown is as follows:
java.lang.ClassCastException: sun.awt.HeadlessToolkit cannot be cast to sun.awt.SunToolkit
        at javax.swing.RepaintManager.getPaintManager(RepaintManager.java:1147)
        at javax.swing.RepaintManager.doubleBufferingChanged(RepaintManager.java:1116)
        at javax.swing.JRootPane.setDoubleBuffered(JRootPane.java:329)
        at javax.swing.JRootPane.<init>(JRootPane.java:318)
        at javax.swing.JInternalFrame.createRootPane(JInternalFrame.java:300)
        at javax.swing.JInternalFrame.<init>(JInternalFrame.java:277)
        at javax.swing.JInternalFrame.<init>(JInternalFrame.java:220)

The bug is caught by AWT Headless_BAT testsuite. The full testsuite error log also attached.
###@###.### 2005-04-21 06:57:43 GMT

==============================
Many JCK 1.5a Runtime tests fail in headless mode in the same way.

api/javax_swing/JInternalFrame/JDesktopIcon/AccessibleJDesktopIcon/index.html#AccessibleValue
api/javax_swing/JInternalFrame/AccessibleJInternalFrame/index.html#AccessibleValue
api/javax_swing/JRootPane/index.html#protected
api/javax_swing/JRootPane/RootLayout/index.html#preferred
api/javax_swing/JRootPane/RootLayout/index.html#minimum
api/javax_swing/JRootPane/RootLayout/index.html#maximum
api/javax_swing/JButton/index.html#misc
api/javax_swing/JLayeredPane/descriptions.html#protected
api/javax_swing/JRootPane/index.html#decoration
api/javax_swing/event/InternalFrameEvent/index.html#Ctor
api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame



###@###.### 2005-05-03 00:30:27 GMT

Comments
EVALUATION This will be fixed as part of 6189824, refer to it for details. ###@###.### 2005-07-12 20:51:18 GMT
12-07-2005