Hi,
As the title says, I think all the CallSub... methods don't accept JavaObject Parameters. Is is normal?
This code:
returns this error:
Thanks
Jmon.
As the title says, I think all the CallSub... methods don't accept JavaObject Parameters. Is is normal?
This code:
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Pane1 As Pane
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
MainForm.Show
Log($"Line 1 worked: ${getPaneInfo(Pane1)}"$)
Log($"Line 2 works: ${writeStuff($"YES IT WORKS"$)}"$)
Log($"Line 3 doesn't work: ${CallSub2(Me, "writeStuff", $"NO IT DOESN'T WORK"$)}"$)
Log($"Line 4 doesn't work: ${CallSub2(Me, "getPaneInfo", Pane1)}"$)
End Sub
Sub writeStuff(s As JavaObject) As String
Log(s)
Return s
End Sub
Sub getPaneInfo(p As JavaObject) As Double
Return p.RunMethod("getPrefWidth", Null)
End Sub
returns this error:
Waiting for debugger to connect...
Program started.
Line 1 worked: 200.0
(String) YES IT WORKS
Line 2 works: (String) YES IT WORKS
public static java.lang.String b4j.example.main._writestuff(anywheresoftware.b4j.object.JavaObject) throws java.lang.Exception
Error occurred on line: 20 (Main)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:435)
at b4j.example.main._appstart(main.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub writeStuff signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:126)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:78)
... 30 more
Caused by: java.lang.Exception: Sub writeStuff signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:111)
... 31 more
Thanks
Jmon.