B4J Question BBCodeView crashes in Debug, works fine in Release

Sandman

Expert
Licensed User
Longtime User
I have a project in B4J that contains a layout with a BBCodeView. I wanted that layout in another B4J project, so I made a new layout in the new project and did the copy/paste thing from the old project using the Designer.

The first project (that I copied from) works just fine in debug and release. The strange thing is that I can't get the new project to work in debug after pasting the layout as described. In release it works just fine, but in debug I get this error:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 61 (BBCodeView)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getNodeObject(B4XViewWrapper.java:121)
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:117)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getTag(B4XViewWrapper.java:700)
    at b4j.example.bbcodeview._designercreateview(bbcodeview.java:537)
    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:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    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:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4j.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:79)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:110)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:101)
    at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:506)
    at b4j.example.testrunner._initialize(testrunner.java:100)
    at b4j.example.b4xmainpage._b4xpage_created(b4xmainpage.java:53)
    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.debug.Debug.CallSub4(Debug.java:115)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81)
    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.keywords.Common.CallSubDebug2(Common.java:487)
    at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:874)
    at b4j.example.b4xpagesmanager._showpage(b4xpagesmanager.java:353)
    at b4j.example.b4xpagesmanager._addpage(b4xpagesmanager.java:174)
    at b4j.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:188)
    at b4j.example.b4xpagesmanager._initialize(b4xpagesmanager.java:124)
    at b4j.example.main._appstart(main.java:88)
    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:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    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:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    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)
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.

I have verified that I have identical libraries enabled in the two projects. I have also made sure to save and re-save the layout several times. And I have changed the Root.LoadLayout("test_layout") parameter back and forth to force the IDE reload the layout and parse everything in it.

I've also verified that if I remove the BBCodeView from the layout everything works. I've then tried doing a new copy/paste of just that, but that didn't help. I've also tried simply deleting the BBCodeView and manually recreating it in the new layout.

I've also cleaned the project numerous times.

Nothing seems to improve the situation. Any ideas?
 

stevel05

Expert
Licensed User
Longtime User
Is the Global variable name for the BBCodeView the same in both projects?
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Ah... So I have code module called "base", and there are some b4xlibs that use that exact name within them and then the compiler doesn't know if the lib code means the code module, or the variable in the lib? (In php this wouldn't happen, because we use $this->base, so there's never a question about what's being referred to.)

But why on earth does this work when I compile release? Shouldn't that also produce an error?

It seems the compiler should be able to produce better output for this. I have posted a Wish:

Thanks for taking a look and finding the problem, appreciated
 
Last edited:
Upvote 0
Top