I am writing a game in which I am using jMonkeyEngine and JavaFx. I have a launcher written in JavaFx that can launch a new thread and run jMonkeyEngine on that thread. When it does so, it calls Platform.exit() such that the game's process ends when the jMonkeyEngine threads end.
This works exactly as it should, except when the game crashes. In this scenario, I would like to restart JavaFx to provide a crash dialog to the user. My first thought was to create a separate CrashDialoge class that extends Application, but this isn't practical because the static launch method creates a new instance of the CrashDialoge class, thus making passing of a Throwable object containing the crash information impossible. I know I can use a static variable to circumvent this, but this would break if for some reason more than one CrashDialoge is being created. I can get around this with Locks, but I am wondering if there is a better way to pass the Throwable object to the new application, perhaps by launching JavaFx with an existing Application object.