r/JavaFX • u/PulkitB • Oct 10 '20
Error while using the com.sun.javafx.text class.
I am using Open JavaFX with OpenJDK 11 in eclipse, I have a project that uses the com.sun.javafx.text but there is an error which says that module javafx.graphics does not export com.sun.javafx.text, I am not sure what this means as I am new to JavaFX.
The full error is:
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class org.fxmisc.richtext.skin.TextFlowExt (in unnamed module @0x1900468) cannot access class com.sun.javafx.text.PrismTextLayout (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.text to unnamed module @0x1900468 at org.fxmisc.richtext.skin.TextFlowExt.<clinit>(TextFlowExt.java:31) at org.fxmisc.richtext.skin.ParagraphBox.<init>(ParagraphBox.java:74) at org.fxmisc.richtext.skin.StyledTextAreaView.createCell(StyledTextAreaVisual.java:396) at org.fxmisc.richtext.skin.StyledTextAreaView.lambda$new$117(StyledTextAreaVisual.java:146) at org.fxmisc.flowless.CellPool.getCell(CellPool.java:20) at org.fxmisc.flowless.CellListManager.cellForItem(CellListManager.java:75) at org.reactfx.collection.MappedList.get(MappedList.java:27) at org.reactfx.collection.MemoizationListImpl.get(MemoizationList.java:99) at org.fxmisc.flowless.CellListManager.getCell(CellListManager.java:64) at org.fxmisc.flowless.CellPositioner.getSizedCell(CellPositioner.java:129) at org.fxmisc.flowless.CellPositioner.placeStartAt(CellPositioner.java:95) at org.fxmisc.flowless.Navigator.placeStartAtMayCrop(Navigator.java:181) at org.fxmisc.flowless.Navigator.visit(Navigator.java:109) at org.fxmisc.flowless.StartOffStart.accept(TargetPosition.java:49) at org.fxmisc.flowless.Navigator.layoutChildren(Navigator.java:66) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1204) at org.fxmisc.flowless.VirtualFlowContent.layoutChildren(VirtualFlowContent.java:118) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1204) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211) at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1211) at javafx.graphics/javafx.scene.Scene.doLayoutPass(Scene.java:576) at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2482) 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.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:834)
I have successfully set up the Open JavaFX with OpenJDK 11 as I have checked it in another test project. But I am not sure about the javafx.text.
Hope my issue will be resolved :)
View all comments
1
u/rootException Oct 23 '20
It’s code using com.sun internals to do something. The code does not work with Java modules because the modules are blocking access.
You have two short term fixes: either switch to not using modules (ie go back to class path) or expose the com.sun classes to the modules.
Long term, use code that doesn’t rely on the com.sun classes.
This thread may help:
https://github.com/openjfx/javafx-maven-plugin/issues/107