I have a very old Swing-based java app that ran fine on Java 8 and I'm trying to switch to Java 11. It relies on JavaFX.
I downloaded OpenJDK 11.0.11_9 JRE and the closest corresponding OpenJFX (11.0.2). I run the project with the necessary --add-module additions to avoid NoClassDefFound errors.
The application seems to work fine, but stderr spews many exceptions like this:
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class com.sun.javafx.embed.swing.oldimpl.JFXPanelInteropO (in module javafx.swing) cannot access class sun.awt.SunToolkit (in module java.desktop) because module java.desktop does not export sun.awt to module javafx.swing
at javafx.swing/com.sun.javafx.embed.swing.oldimpl.JFXPanelInteropO.postEvent(JFXPanelInteropO.java:38)
at javafx.swing/javafx.embed.swing.JFXPanel.invokeOnClientEDT(JFXPanel.java:938)
at javafx.swing/javafx.embed.swing.JFXPanel.access$400(JFXPanel.java:135)
at javafx.swing/javafx.embed.swing.JFXPanel$HostContainer.setCursor(JFXPanel.java:1029)
at javafx.graphics/com.sun.javafx.tk.quantum.EmbeddedScene.setCursor(EmbeddedScene.java:427)
at javafx.graphics/javafx.scene.Scene$MouseHandler.updateCursorFrame(Scene.java:3984)
at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2534)
at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:412)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:411)
at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:438)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:519)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:499)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:492)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:320)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Unknown Source)
Presumably there is some mechanism to run legacy code like mine and it is not working in this case?
My project imports a variety of javax.swing.* pacakges and a variety of javafx.* packages.
Is there something I can tweak in the code to fix this? Or does the problem have to do with my JRE setup? I'm hoping to avoid any serious refactoring.