B4J Question Project containing bugs: debug and release behavior.

LucaMs

Expert
Licensed User
Longtime User
Running a project containing bug(s), in debug mode it logs the error and crashes. If you run it in release mode (of course even if you run the jar) no crashes happens.
(I'm attaching a test project. Press on button "Error" and then on button "Toast").

Two questions:

  1. is this a design choice? (I believe that any sw for Windows - and other OSs - would crash if it contained a "serious" bug);
  2. is this due to the Resumables?
 

Attachments

  • BugTest.zip
    2.2 KB · Views: 197

Magma

Expert
Licensed User
Longtime User
Upvote 0

agraham

Expert
Licensed User
Longtime User
I don't even know if it is due to the Resumables or not.
It is. Just simplify the code and call DoIt directly without the Wait and, importantly, the Sleep so btnErr_Click is no longer a Resumable Sub and it will crash as expected. I agree it seems odd and unintuitive so I looked at the generated code.

Java:
    public void start (javafx.stage.Stage stage) {
        try {
            if (!false)
                System.setProperty("prism.lcdtext", "false");
            anywheresoftware.b4j.objects.FxBA.application = this;
            anywheresoftware.b4a.keywords.Common.setDensity(javafx.stage.Screen.getPrimary().getDpi());
            anywheresoftware.b4a.keywords.Common.LogDebug("Program started.");
            initializeProcessGlobals();
            anywheresoftware.b4j.objects.Form frm = new anywheresoftware.b4j.objects.Form();
            frm.initWithStage(ba, stage, 600, 600);
            ba.raiseEvent(null, "appstart", frm, (String[])getParameters().getRaw().toArray(new String[0]));
        } catch (Throwable t) {
            BA.printException(t, true);
            System.exit(1);
        }
    }
The error is trapped by the 'start' method which starts the program. When the error occurs it prints the exception, which I can see in the logs, and calls System.exit which should stop the program - but it doesn't seem to if the error is in a Resumable Sub. o_O One for Erel I think!
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
It is. Just simplify the code and call DoIt directly without the Wait and, importantly, the Sleep so btnErr_Click is no longer a Resumable Sub and it will crash as expected.
I can no longer live without Resumables, Wait For, Sleep :( :)


More concretely, I can no longer live without money, so you will soon get rid of this crazy member ?:confused:
I think I will soon publish a begging app on GP.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Could it be a design choice for B4J server projects?
I doubt it. Swallowing a runtime error without notification can never be a good idea unless it is explicitly coded with a try...catch. I am intrigued by this behaviour as System.exit should shut down the JVM immediately - the corollary is probably that the error is not propagated to the try...catch in start if it occurs in the contaxt of a Resumable Sub so System.exit is never actually called - though I can't at the moment see anything in the code or decompiled jar that might explain this.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
this method catches exceptions internally.
That seems to be a rather unfortunate limitation to say the least, and a possibly suspect design decision in the implementation of JavaJX. I'm guessing that even a try...catch in a Resumable Sub will not detect any failure as the exception will be swallowed at a lower level. I'm not impressed :(
 
Upvote 0
Top