dankito / RichTextEditor

Rich text WYSIWYG editor for Android and JavaFX
Apache License 2.0
92 stars 36 forks source link

JavaFXJavaScriptExecutor - Could not access page object #33

Open SKeeneCode opened 4 years ago

SKeeneCode commented 4 years ago

Trying to get this to work in a tornadofx app I'm making. Using the 2.0.14 version, JavaFX 13, JDK 13 and the JDK 10+ branch of TornadoFX. Googling gave zero results so hoping I can find some answers here :)

The project doesn't crash, but the editor also doesn't load.

Stacktrace:

00:45:38.563 [JavaFX Application Thread] ERROR n.d.r.j.fx.JavaFXJavaScriptExecutor - Could not access page object java.lang.reflect.InaccessibleObjectException: Unable to make field private final com.sun.webkit.WebPage javafx.scene.web.WebEngine.page accessible: module javafx.web does not "opens javafx.scene.web" to unnamed module @4bb20186 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:344) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:284) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:176) at java.base/java.lang.reflect.Field.setAccessible(Field.java:170) at net.dankito.richtexteditor.java.fx.JavaFXJavaScriptExecutor.loadEditorHtml(JavaFXJavaScriptExecutor.kt:67) at net.dankito.richtexteditor.java.fx.JavaFXJavaScriptExecutor.access$loadEditorHtml(JavaFXJavaScriptExecutor.kt:20) at net.dankito.richtexteditor.java.fx.JavaFXJavaScriptExecutor$1$$special$$inlined$let$lambda$1.invoke(JavaFXJavaScriptExecutor.kt:49) at net.dankito.richtexteditor.java.fx.JavaFXJavaScriptExecutor$1$$special$$inlined$let$lambda$1.invoke(JavaFXJavaScriptExecutor.kt:20) at tornadofx.AsyncKt$sam$java_lang_Runnable$0.run(Async.kt) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) at java.base/java.lang.Thread.run(Thread.java:830) 00:45:38.755 [JavaFX Application Thread] INFO n.d.r.JavaScriptExecutorBase - RichTextEditor is now loaded

dankito commented 4 years ago

That's one of the reasons one shouldn't use Reflection. But i did it ;).

WebPage instance of WebEngine isn't publicly accessible, so i tried to access it via Reflection. Seems that WebEngine's internals have changed in JDK13.

Just had a look at JavaFX 13's source code. The field still is there.

Guess it's a problem with Java 9's module system (see error message: module javafx.web does not "opens javafx.scene.web" to unnamed module).

Are you familiar with Java 9 module system and know how to solve this?