I created a class that has a method inside which is resumable sub.
If I insert the class code on one of my applications it works perfectly. If I compile it as a library and insert it into the same Application it generates this error
httputils2service._submitjob (java line: 147)
java.lang.NullPointerException
at b4j.example.httputils2service._submitjob(httputils2service.java:147)
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:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:504)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:484)
at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:558)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(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$152(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
My app source is the same and calls the class in the same way
[CODE lang="b4x" highlight="3,4"]Private Sub ButtonConnect_Click
MyClient.Initialize
Wait For (MyClient.Connect(TextField1.Text,TextField2.Text,TextField3.Text,TextField4.Text,MyBoolean)) Complete (Success As Boolean)
Here it generates the error without even entering the sub. I put a log at the beginning of the sub and it doesn't even appear.
log(Success)
End Sub[/CODE]
This is roughly the content of the method
[CODE lang="b4x" highlight="2"]Public Sub Connect(S1 As String,S2 As String, S3 As String, S4 As String, MyBool As String) As ResumableSub
Log("First") ' This log does not even appear
client.Initialize("",Me)
client.Download("https://www.myserver.xx")
client.GetRequest.SetHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36")
Wait For (client) JobDone(j As HttpJob)
if j.success=False then return False
Log("Second pass")
client.Download("https://www.myserver.xx/second/")
client.GetRequest.SetHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36")
Wait For (client) JobDone(j As HttpJob)
if j.success=False then return False
Return true
End SUb[/CODE]
If instead of as a library I insert it as a class everything works correctly.