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

FXCanvas initialization causes error when using multiple classloaders

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
      9
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      os.arch: amd64, Windows 10, OpenJDK 11, OpenJFX 11 SDK

      A DESCRIPTION OF THE PROBLEM :
      The error occurs if you have embedded JavaFX e.g. in a Eclipse application where each plugin has it's own classloader. When FXPanels are initialized in different Eclipse plugins (classloaders) the following error occurs:

      Caused by: java.lang.IllegalStateException: Toolkit already initialized
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:182)
      at javafx.graphics/javafx.application.Platform.startup(Platform.java:101)
      at javafx.embed.swt.FXCanvas.lambda$initFx$4(FXCanvas.java:354)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:429)
      at javafx.embed.swt.FXCanvas.initFx(FXCanvas.java:353)
      at javafx.embed.swt.FXCanvas.<clinit>(FXCanvas.java:271)
      ... 154 more

      The Problems was already analysed in the OpenJFX mailing list by Kevin Rushforth. A possible solution was posted, too, see:

      http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-October/022610.html

      REGRESSION : Last worked in version 11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JavaFX application (e.g. a Eclipse RCP) with different classloaders (e.g. Eclipse plugins) and in the different context initialize a JavaFX panel

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An exception will be thrown that the toolkit was already initialized.


      ACTUAL -
      Here the error message of the initialization:

      Caused by: java.lang.IllegalStateException: Toolkit already initialized
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:182)
      at javafx.graphics/javafx.application.Platform.startup(Platform.java:101)
      at javafx.embed.swt.FXCanvas.lambda$initFx$4(FXCanvas.java:354)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:429)
      at javafx.embed.swt.FXCanvas.initFx(FXCanvas.java:353)
      at javafx.embed.swt.FXCanvas.<clinit>(FXCanvas.java:271)
      ... 154 more

      CUSTOMER SUBMITTED WORKAROUND :
      The Problems was already analysed in the OpenJFX mailing list by Kevin Rushforth. A possible solution was posted, too, see:

      http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-October/022610.html

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              tschindl Tom Schindl
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated: