drponciano Active Member Licensed User Longtime User Feb 9, 2021 #1 My program works fine with no warnings if I complie with JDK from Oracle but, if I compile with OpenJDK 11, I get the "Illegal reflective..." warning after a few iterations. That is not a problem when I'm running the app from Java "java -jar myapp.jar" but, if I use B4J Packager, when running the EXE, the program stops after the warning. Any idea how can I avoid the warning or what is causing it?
My program works fine with no warnings if I complie with JDK from Oracle but, if I compile with OpenJDK 11, I get the "Illegal reflective..." warning after a few iterations. That is not a problem when I'm running the app from Java "java -jar myapp.jar" but, if I use B4J Packager, when running the EXE, the program stops after the warning. Any idea how can I avoid the warning or what is causing it?
Erel B4X founder Staff member Licensed User Longtime User Feb 10, 2021 #2 Please post the full output from run_debug.bat. Upvote 0
drponciano Active Member Licensed User Longtime User Feb 10, 2021 #3 Running from B4J UI the warning is also present in the log area but the program keeps working fine. Not the case with the EXE. Here is the output from run_debug.bat: Recibo RED 63 PROM 1 Fin de Newdata RED IRR Instantáneo 154 main._beep (java line: -1) java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject (in module b4j) cannot access class sun.awt.windows.WToolkit (in module java.desktop) because module java.desktop does not export sun.awt.windows to module b4j at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Unknown Source) at java.base/java.lang.reflect.AccessibleObject.checkAccess(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at b4j/anywheresoftware.b4j.object.JavaObject.RunMethod(Unknown Source) at b4j/b4j.example.main._beep(Unknown Source) at b4j/b4j.example.main._timer_principal_tick(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source) at b4j/anywheresoftware.b4a.objects.Timer$TickTack$1.run(Unknown Source) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) C:\Fuentes\Basic4Mac\ZiECG_JV\Objects\temp\build\bin>pause Presione una tecla para continuar . . . Last edited: Feb 10, 2021 Upvote 0
Running from B4J UI the warning is also present in the log area but the program keeps working fine. Not the case with the EXE. Here is the output from run_debug.bat: Recibo RED 63 PROM 1 Fin de Newdata RED IRR Instantáneo 154 main._beep (java line: -1) java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject (in module b4j) cannot access class sun.awt.windows.WToolkit (in module java.desktop) because module java.desktop does not export sun.awt.windows to module b4j at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Unknown Source) at java.base/java.lang.reflect.AccessibleObject.checkAccess(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at b4j/anywheresoftware.b4j.object.JavaObject.RunMethod(Unknown Source) at b4j/b4j.example.main._beep(Unknown Source) at b4j/b4j.example.main._timer_principal_tick(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source) at b4j/anywheresoftware.b4a.objects.Timer$TickTack$1.run(Unknown Source) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) C:\Fuentes\Basic4Mac\ZiECG_JV\Objects\temp\build\bin>pause Presione una tecla para continuar . . .
Erel B4X founder Staff member Licensed User Longtime User Feb 11, 2021 #4 Best to upload a small project that demonstrates it. Upvote 0
drponciano Active Member Licensed User Longtime User Feb 11, 2021 #5 I found the problem! Now, is there a solution? The warning is issued the first time the beep routine is called: B4X: Copy Sub Beep Dim jo As JavaObject jo.InitializeStatic("java.awt.Toolkit") Dim toolkit As JavaObject = jo.RunMethod("getDefaultToolkit", Null) toolkit.RunMethod("beep", Null) End Sub Upvote 0
I found the problem! Now, is there a solution? The warning is issued the first time the beep routine is called: B4X: Copy Sub Beep Dim jo As JavaObject jo.InitializeStatic("java.awt.Toolkit") Dim toolkit As JavaObject = jo.RunMethod("getDefaultToolkit", Null) toolkit.RunMethod("beep", Null) End Sub
NikB4x Member Licensed User Longtime User Feb 11, 2021 #6 drponciano said: I found the problem! Now, is there a solution? The warning is issued the first time the beep routine is called: B4X: Copy Sub Beep Dim jo As JavaObject jo.InitializeStatic("java.awt.Toolkit") Dim toolkit As JavaObject = jo.RunMethod("getDefaultToolkit", Null) toolkit.RunMethod("beep", Null) End Sub Click to expand... Hi @drponciano, just a curiosity of mine ... why are you using the toolkit's beep method to reproduce the sound? Upvote 0
drponciano said: I found the problem! Now, is there a solution? The warning is issued the first time the beep routine is called: B4X: Copy Sub Beep Dim jo As JavaObject jo.InitializeStatic("java.awt.Toolkit") Dim toolkit As JavaObject = jo.RunMethod("getDefaultToolkit", Null) toolkit.RunMethod("beep", Null) End Sub Click to expand... Hi @drponciano, just a curiosity of mine ... why are you using the toolkit's beep method to reproduce the sound?
drponciano Active Member Licensed User Longtime User Feb 11, 2021 #7 Nicola Ciaramellano said: Hi @drponciano, just a curiosity of mine ... why are you using the toolkit's beep method to reproduce the sound? Click to expand... Yes, thas was one method sugested by Erel long time ago ?. It's working fine, but now... Any suggestion? Upvote 0
Nicola Ciaramellano said: Hi @drponciano, just a curiosity of mine ... why are you using the toolkit's beep method to reproduce the sound? Click to expand... Yes, thas was one method sugested by Erel long time ago ?. It's working fine, but now... Any suggestion?
NikB4x Member Licensed User Longtime User Feb 11, 2021 #8 If you don't want use mediaplayer, have you tried this: http://stackoverflow.com/questions/30377129/playing-audio-on-raspberry-pi-with-java also suggested by Erel Upvote 0
If you don't want use mediaplayer, have you tried this: http://stackoverflow.com/questions/30377129/playing-audio-on-raspberry-pi-with-java also suggested by Erel
Erel B4X founder Staff member Licensed User Longtime User Feb 14, 2021 #9 Change your code to: Code: Copy Sub Beep Dim jo As JavaObject = Me jo.RunMethod("beep", Null) End Sub #if Java public static void beep() { java.awt.Toolkit.getDefaultToolkit().beep(); } #End If Upvote 0
Change your code to: Code: Copy Sub Beep Dim jo As JavaObject = Me jo.RunMethod("beep", Null) End Sub #if Java public static void beep() { java.awt.Toolkit.getDefaultToolkit().beep(); } #End If
agraham Expert Licensed User Longtime User Feb 14, 2021 #10 Just out of curiosity why does the inline Java work when the apparently identical JavaObject code doesn't? Something not public or am I missing the obvious? Upvote 0
Just out of curiosity why does the inline Java work when the apparently identical JavaObject code doesn't? Something not public or am I missing the obvious?
Erel B4X founder Staff member Licensed User Longtime User Feb 14, 2021 #11 Nothing obvious here. It is related to getDefaultTookit returning sun.awt.windows.WToolkit which is public by itself but is from a closed module. Upvote 0
Nothing obvious here. It is related to getDefaultTookit returning sun.awt.windows.WToolkit which is public by itself but is from a closed module.