Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8088132

[Swing, singleThread] ClassCastException in nested event loop when showing multiple message dialogs in SwingNode

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u31, 8u40
    • Fix Version/s: 10
    • Component/s: javafx
    • Labels:
      None
    • Environment:

      Windows 8

    • Subcomponent:
    • Resolved In Build:
      b29

      Description

      Situation:
      * We have a JavaFx-app containing a SwingNode that has a JTextField and a JButton.
      * The app was started with '-Djavafx.embed.singleThread=true'
      * The text field has a focus-lost-listener that opens a JOptionPane
      * The button has an action listener that opens a JOptionPane
      * The text field is focussed


      When the button is clicked, the following ClassCastException occurs:
      {code}
      Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: java.lang.Thread cannot be cast to java.awt.EventDispatchThread
      at java.awt.SequencedEvent.dispatch(SequencedEvent.java:106)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3$1.run(EventQueue.java:707)
      at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
      at com.sun.javafx.application.PlatformImpl$$Lambda$57/197317074.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
      at com.sun.javafx.application.PlatformImpl$$Lambda$56/1583804921.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
      at com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:128)
      at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
      at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
      at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:593)
      at javafx.embed.swing.SwingFXUtils$FwSecondaryLoop.lambda$enter$63(SwingFXUtils.java:332)
      at javafx.embed.swing.SwingFXUtils$FwSecondaryLoop$$Lambda$152/1201163521.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:317)
      at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:307)
      at javafx.embed.swing.SwingFXUtils$FwSecondaryLoop.enter(SwingFXUtils.java:331)
      at java.awt.Dialog.show(Dialog.java:1084)
      at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:869)
      at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
      at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
      at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:608)
      at JavaFxEDTClassCastException$2.actionPerformed(JavaFxEDTClassCastException.java:67)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.plaf.basic.BasicButtonListener.focusLost(BasicButtonListener.java:198)
      at java.awt.Component.processFocusEvent(Component.java:6417)
      at java.awt.Component.processEvent(Component.java:6281)
      at java.awt.Container.processEvent(Container.java:2234)
      at java.awt.Component.dispatchEventImpl(Component.java:4881)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
      at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:995)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
      at java.awt.Component.dispatchEventImpl(Component.java:4752)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:702)
      at java.awt.EventQueue$3.run(EventQueue.java:696)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
      at java.awt.EventQueue$4.run(EventQueue.java:724)
      at java.awt.EventQueue$4.run(EventQueue.java:722)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
      at java.awt.SentEvent.dispatch(SentEvent.java:70)
      at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:217)
      at java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:244)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:731)
      at java.awt.Component.dispatchEventImpl(Component.java:4752)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Window.dispatchEventImpl(Window.java:2750)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:702)
      at java.awt.EventQueue$3.run(EventQueue.java:696)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
      at java.awt.EventQueue$4.run(EventQueue.java:724)
      at java.awt.EventQueue$4.run(EventQueue.java:722)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
      at java.awt.SentEvent.dispatch(SentEvent.java:70)
      at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(DefaultKeyboardFocusManager.java:217)
      at java.awt.DefaultKeyboardFocusManager.sendMessage(DefaultKeyboardFocusManager.java:244)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:348)
      at java.awt.Component.dispatchEventImpl(Component.java:4752)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Window.dispatchEventImpl(Window.java:2750)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:702)
      at java.awt.EventQueue$3.run(EventQueue.java:696)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
      at java.awt.EventQueue$4.run(EventQueue.java:724)
      at java.awt.EventQueue$4.run(EventQueue.java:722)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
      at java.awt.SequencedEvent.dispatch(SequencedEvent.java:128)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3$1.run(EventQueue.java:707)
      at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
      at com.sun.javafx.application.PlatformImpl$$Lambda$57/197317074.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
      at com.sun.javafx.application.PlatformImpl$$Lambda$56/1583804921.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
      at com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:128)
      at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
      at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
      at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:593)
      at javafx.embed.swing.SwingFXUtils$FwSecondaryLoop.lambda$enter$63(SwingFXUtils.java:332)
      at javafx.embed.swing.SwingFXUtils$FwSecondaryLoop$$Lambda$152/1201163521.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:317)
      at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:307)
      at javafx.embed.swing.SwingFXUtils$FwSecondaryLoop.enter(SwingFXUtils.java:331)
      at java.awt.Dialog.show(Dialog.java:1084)
      at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:869)
      at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
      at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
      at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:608)
      at JavaFxEDTClassCastException$1.focusLost(JavaFxEDTClassCastException.java:56)
      at java.awt.AWTEventMulticaster.focusLost(AWTEventMulticaster.java:230)
      at java.awt.Component.processFocusEvent(Component.java:6417)
      at java.awt.Component.processEvent(Component.java:6281)
      at java.awt.Container.processEvent(Container.java:2234)
      at java.awt.Component.dispatchEventImpl(Component.java:4881)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
      at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:995)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
      at java.awt.Component.dispatchEventImpl(Component.java:4752)
      at java.awt.Container.dispatchEventImpl(Container.java:2292)
      at java.awt.Component.dispatchEvent(Component.java:4703)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3$1.run(EventQueue.java:707)
      at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
      at com.sun.javafx.application.PlatformImpl$$Lambda$57/197317074.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
      at com.sun.javafx.application.PlatformImpl$$Lambda$56/1583804921.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
      at com.sun.glass.ui.win.WinApplication$$Lambda$38/1463642169.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:745)
      {code}

      When the app is started without '-Djavafx.embed.singleThread=true', no exception is thrown (and the two message boxes are shown)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psadhukhan Prasanta Sadhukhan
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: