JDK-4714232 : RFE: replace sun.awt.exception.handler system property with official API
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_2000
  • CPU: generic,x86
  • Submitted: 2002-07-12
  • Updated: 2017-05-16
  • Resolved: 2009-05-06
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 7
7 b49Fixed
Related Reports
Relates :  
Relates :  
Description
Name: jk109818			Date: 07/12/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

any OS

A DESCRIPTION OF THE PROBLEM :
java.awt.EventDispatchThread's default behaviour for
uncaught exceptions during event processing (dump a stack
trace to the console) is inappropriate for professional
level applications, since usually the system console is not
even visible to the user. Instead, the application should
record the exception in a logfile or present a dialog box to
the user.

Sun has thus taken a step in the right direction and
provided the system property "sun.awt.exception.handler" to
override the default exception handling behaviour of the
event dispatch thread.

However, this is not part of the official API. Quote from
the sourcecode:
This method is a temporary hack to work around the absence
of a real API that provides the ability to replace the
event-dispatch thread.  The magic
"sun.awt.exception.handler" property will be removed in a
future release.

I don't want to replace the event-dispatch thread, all I'm
asking for is some API that lets me install an exception
handler and that is guaranteed to work in future releases of
Java.

  



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
One solution would be to add a method

  public void setExceptionHandler(AWTExceptionHandler handler)

to EventDispatchThread, where AWTExceptionHandler is defined as follows:

  public interface AWTExceptionHandler
  {
    void handle(Throwable t);
  }
---------- END SOURCE ----------
(Review ID: 159187) 
======================================================================

Comments
EVALUATION Expected to be fixed with 6727884. See 6727884 for evaluation and suggested fix.
27-08-2008