B4J Question [SOLVED] B4Xdialog.ShowTemplate - java.lang.reflect.InvocationTargetException

walt61

Active Member
Licensed User
Longtime User
Running the attached (very small) project from the IDE (both Release and Debug modes) works fine (B4J 9.30, OpenJDK 11.0.1). I run it using @agraham 's RunSelfNamedJarJdk11 because I don't need an installer and this keeps the footprint minimal in terms of disc space, as basically it does this (and doesn't need to duplicate the OpenJDK runtime files):
B4X:
C:\java\jdk-11.0.1\bin\java.exe --module-path c:\java\jdk-11.0.1\javafx\lib --add-modules ALL-MODULE-PATH -jar ShowTemplateError.jar

I have tested it with the integrated packager and InnoSetup as well (for the sake of completeness), but then clicking the button has no effect at all. When running it as aforementioned, the below exception is thrown; can anyone tell me what I'm missing/doing wrong?
java.lang.reflect.InvocationTargetException
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.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.customlistview._createlabel(customlistview.java:239)
at b4j.example.customlistview._insertattextitem(customlistview.java:704)
at b4j.example.customlistview._addtextitem(customlistview.java:82)
at b4j.showtemplateerror.b4xlisttemplate$ResumableSub_Show.resume(b4xlisttemplate.java:242)
at b4j.showtemplateerror.b4xlisttemplate._show(b4xlisttemplate.java:179)
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.keywords.Common.CallSub4(Common.java:509)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:464)
at b4j.showtemplateerror.b4xdialog$ResumableSub_ShowTemplate.resume(b4xdialog.java:1132)
at b4j.showtemplateerror.b4xdialog._showtemplate(b4xdialog.java:1098)
at b4j.showtemplateerror.main$ResumableSub_Button1_Click.resume(main.java:133)
at b4j.showtemplateerror.main._button1_click(main.java:94)
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$1.run(BA.java:234)
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.reflect.InaccessibleObjectException: Unable to make public static double com.sun.javafx.scene.control.skin.Utils.computeTextHeight(javafx.scene.text.Font,java.lang.String,double,javafx.scene.text.TextBoundsType) accessible: module javafx.controls does not "exports com.sun.javafx.scene.control.skin" to unnamed module @542f6078
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 b4j.example.customlistview.MeasureMultilineTextHeight(customlistview.java:1082)
... 34 more
 

Attachments

  • ShowtemplateError.zip
    2.8 KB · Views: 198

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have tested it with the integrated packager and InnoSetup as well (for the sake of completeness), but then clicking the button has no effect at all.
It should work with the standalone packager.

I've tested your program and it doesn't work when running from the IDE as well. The button doesn't do anything.
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Oops - it seems I had removed DialogForm.Show and DialogForm.Close, apologies. Attached to this post is the project with those statements included, which indeed runs when packaged.

Could it be that I need to somehow add some (or all) of the things specified in file 'release_java_modules.txt'?

--add-opens java.desktop/sun.awt=b4j --add-opens javafx.controls/com.sun.javafx.scene.control.inputmap=b4j --add-opens javafx.graphics/com.sun.javafx.scene=b4j --add-opens javafx.controls/com.sun.javafx.scene.control.behavior=b4j --add-opens javafx.graphics/com.sun.javafx.scene.traversal=b4j --add-opens javafx.graphics/javafx.scene=b4j --add-opens javafx.base/com.sun.javafx.collections=b4j --add-opens javafx.controls/com.sun.javafx.scene.control=b4j --add-opens javafx.base/com.sun.javafx.event=b4j --add-opens javafx.graphics/com.sun.javafx.css=b4j --add-opens javafx.base/com.sun.javafx.runtime=b4j --add-opens javafx.controls/com.sun.javafx.scene.control.skin=b4j --add-opens javafx.graphics/com.sun.javafx.geom=b4j --add-opens javafx.graphics/javafx.scene.canvas=b4j --add-opens javafx.graphics/com.sun.javafx.geom.transform=b4j --add-modules=b4j,java.base,java.desktop,javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,java.scripting,java.xml,jdk.unsupported,java.datatransfer,jdk.unsupported.desktop,jdk.jsobject,jdk.xml.dom
 

Attachments

  • ShowtemplateError.zip
    2.8 KB · Views: 210
Upvote 0
Top