Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8100937

Allow application to catch exceptions thrown by FX application thread with an UncaughtExceptionHandler

    Details

      Description

      Some applications would like the ability to catch uncaught exceptions in the JavaFX Event Dispatcher, either as the result of an input event handler, and animation pulse, or as the result of an exception in a Platform.runLater Runnable.Before this can be considered, we would need internal modification to the Toolkit and Glass to support this. Part of this is underway (RT-14073), but it will not provide the complete support needed for 2.0. Until it is ready, we must catch all exceptions in the dispatch loop so that exceptions in user code don't cause the FX app thread to die. Even if that were to be done, there is still the issue of how that ties in to the application life-cycle model (init/start/stop).

      RT-13560 has a brief description of the issue. The relevant piece in included here:

      ----- BEGIN comment from Randahl Fink Isaksen -----

      If that is the case, I think we have spotted a design problem. All kinds of applications need to take special care of unhandled exceptions. In our app, for instance, we wish to present the user with a dialog window, telling the user that we are sorry for the inconvenience, and that a bug report has been filed, and we expect to look at the error shortly.

      As you know, unhandled exceptions can be a symptom of an application moving from a stable to an unstable state, which is why certain critical applications will have to shut down, if an unhandled exception occurs. They can only do so, if there is a way to detect unhandled exceptions.

      Java has had the Thread.UncaughtExceptionHandler class since 2004, and it has worked with Swing for years both with the Swing UI thread and any other program threads. Changing this API is definitely not something I would recommend, and I do not think there is any good alternative but to support this standard approach. Of course, you could introduce a new way for developers to hook in to the stream of unhandled exceptions, but is that not a bit like reinventing the wheel? I strongly recommend you consider this carefully.

      ----- END comment from Randahl Fink Isaksen -----

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                art Artem Ananiev
                Reporter:
                kcr Kevin Rushforth
              • Votes:
                8 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: