B4J Question [SOLVED] Maddening list bug

JackKirk

Well-Known Member
Licensed User
Longtime User
I've tried everything I can think of to fix this - last resort: post a question...

Here is the code:
B4X:
Log(xxxx.Size)
Log(xxxx.IsInitialized)
        'For each ticket web request file...
        For wrk_ptr = 0 To xxxx.Size - 1                        '<<<<< this is line 631
wrk_ptr is an Int

Here is the log:
Waiting for debugger to connect...
Program started.
0
true
Error occurred on line: 631 (Main)
java.lang.RuntimeException: Object should first be initialized (List).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
at anywheresoftware.b4a.objects.collections.List.getSize(List.java:134)
at b4j.example.main$ResumableSub_Event_obj_check_web_backlog_timer_Tick.resume(main.java:2217)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
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.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
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:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:153)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:102)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1103)
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)
I have tried everything including cleaning the project, shutting down the PC etc but still it persists.

I know I'm doing something stupid but what...
 
Solution
I found it!!!

The code that was producing the error was a modification of code I have had running for 3 years.

So I went back to the archived earlier copy and went slowly thru the modifications I had made.

In the subroutine that was bombing I had made a change that potentially resulted in another totally unrelated list being referenced before it was initialized.

For some totally bizarre reason, this was causing the reference to the other list (that was initialized) to bomb - before the bad reference was even executed.

So moral is: if you get a list bombing on you as "uninitialised" and you can't work out why - check all other lists in the same routine.

I'm guessing this may apply to maps also?

Does this qualify as a bug? - see...

JackKirk

Well-Known Member
Licensed User
Longtime User
I've check the example you've uploaded and I don't see any issue.
Erel, in the example I have provided at post #35, the error is reported as on line 34 but is actually on line 38

And is reported properly when the sleep statement is removed - in my real life case I had resumable subs in this "location".

I should add that I tried it with maps too - with the same problem.
 
Last edited:
Upvote 0
Top