JDK-8100937 : Allow application to catch exceptions thrown by FX application thread with an UncaughtExceptionHandler
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: application-lifecycle
  • Affected Version: fx2.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2011-07-26
  • Updated: 2015-09-04
  • Resolved: 2013-05-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
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 -----

Comments
RT-30239 is likely just a duplicate of this one.
13-05-2013