I am in the process of upgrading an old (JDK 8) JavaFX application to JDK 17 plus all of its dependencies. So far the process went okay, but now I am stuck on something that I can't seem to figure out. If I run the JavaFX application without the gluonFX plugin, it seems to work. However, I want to package it and distribute it to other parties, which is why I am using the gluonfx-maven-plugin. However, trying to run gluonfx-run results in the following stack trace:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected javafx.collections.ObservableList javafx.scene.Parent.getChildren() accessible: module javafx.graphics does not "opens javafx.scene" to unnamed module @7ac9b2c5
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.jacpfx.rcp.util.FXUtil.getChildren(FXUtil.java:99)
at org.jacpfx.rcp.util.WorkerUtil.handleAdd(WorkerUtil.java:130)
at org.jacpfx.rcp.util.WorkerUtil.addComponentByType(WorkerUtil.java:117)
at org.jacpfx.rcp.worker.FXComponentInitWorker.lambda$executePostHandleAndAddComponent$119(FXComponentInitWorker.java:222)
at org.jacpfx.rcp.util.WorkerUtil.lambda$invokeOnFXThreadAndWait$34(WorkerUtil.java:79)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
So far I have tried to add the following JVM arguments:
--module-path /Users/macuser/.sdkman/candidates/javafx/javafx-sdk-17.0.9/lib --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics --add-opens javafx.graphics/javafx.scene=ALL-UNNAMED
This does not seem to work. Still gives me the same issue. I'm not sure if the module-path is necessary, as I am using Maven to include these dependencies.
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${openjfx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${openjfx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${openjfx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${openjfx.version}</version>
</dependency>
I really want to make this work with GraalVM to run the application natively. Can anyone point me in the right direction?