B4J Question RichViewfx CodeArea release mode error.

Alejandro Moyano

Member
Licensed User
Hi, i was trying to use the @stevel05 RichViewfx CodeArea control and can't make it work on release mode.

The behavior it's a quite strange as in release mode the app crashes showing this log:


B4X:
main._appstart (java line: 56)
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:138)
    at anywheresoftware.b4j.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:85)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:110)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:101)
    at b4j.example.main._appstart(main.java:56)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:37)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    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:834)
Caused by: java.lang.ExceptionInInitializerError
    at org.fxmisc.richtext.ParagraphBox.<init>(ParagraphBox.java:96)
    at org.fxmisc.richtext.GenericStyledArea.createCell(GenericStyledArea.java:1368)
    at org.fxmisc.richtext.GenericStyledArea.lambda$new$11(GenericStyledArea.java:724)
    at org.fxmisc.flowless.CellPool.getCell(CellPool.java:28)
    at org.fxmisc.flowless.CellListManager.cellForItem(CellListManager.java:86)
    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:69)
    at org.fxmisc.flowless.CellPositioner.getSizedCell(CellPositioner.java:217)
    at org.fxmisc.flowless.CellPositioner.placeStartAt(CellPositioner.java:127)
    at org.fxmisc.flowless.Navigator.placeStartAtMayCrop(Navigator.java:201)
    at org.fxmisc.flowless.Navigator.visit(Navigator.java:129)
    at org.fxmisc.flowless.StartOffStart.accept(TargetPosition.java:85)
    at org.fxmisc.flowless.Navigator.layoutChildren(Navigator.java:78)
    at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1204)
    at org.fxmisc.flowless.VirtualFlow.layoutChildren(VirtualFlow.java:257)
    at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1204)
    at org.fxmisc.flowless.VirtualFlow.visibleCells(VirtualFlow.java:230)
    at org.fxmisc.richtext.GenericStyledArea.<init>(GenericStyledArea.java:760)
    at org.fxmisc.richtext.StyledTextArea.<init>(StyledTextArea.java:33)
    at org.fxmisc.richtext.StyledTextArea.<init>(StyledTextArea.java:45)
    at org.fxmisc.richtext.StyleClassedTextArea.<init>(StyleClassedTextArea.java:18)
    at org.fxmisc.richtext.StyleClassedTextArea.<init>(StyleClassedTextArea.java:31)
    at org.fxmisc.richtext.CodeArea.<init>(CodeArea.java:36)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.lang.Class.newInstance(Class.java:584)
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:86)
    at b4j.example.codearea._designercreateview(codearea.java:194)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    ... 20 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make com.sun.javafx.scene.text.TextLayout javafx.scene.text.TextFlow.getTextLayout() accessible: module javafx.graphics does not "opens javafx.scene.text" to unnamed module @14732793
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
    at org.fxmisc.richtext.TextFlowExt.<clinit>(TextFlowExt.java:34)
    ... 56 more

But when i run as debug mode it's works:

1640096670135.png


I currently looking for a code editor for my DSL, any B4J idea?
 

stevel05

Expert
Licensed User
Longtime User
Experimentation and investigation shows that an export is required as well.

This works for me:

B4X:
#VirtualMachineArgs: --add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED  --add-exports javafx.graphics/com.sun.javafx.text=ALL-UNNAMED
#PackagerProperty: VMArgs = --add-opens javafx.graphics/javafx.scene.text=b4j --add-exports javafx.graphics/com.sun.javafx.text=b4j

Note this is for java > 8 only, so I won't be adding it to the released library demo for now.
 
Last edited:
Upvote 0

Alejandro Moyano

Member
Licensed User
Thanks @stevel05, @Erel it's working now, i will try to add an sidebar.

It will replace this regular textarea:

1640286923006.png


do you know how easy could be add autocompletion? did u atempt it?
 

Attachments

  • RichTextView - Fixed.zip
    10.4 KB · Views: 259
Upvote 0

stevel05

Expert
Licensed User
Longtime User
No, I didn't try that. It's been a long time since I looked at it at all.
 
Upvote 0
Top