-
Enhancement
-
Resolution: Fixed
-
P4
-
1.4.0, 5.0
-
b49
-
generic, x86
-
generic, windows_2000
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)
======================================================================
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)
======================================================================
- relates to
-
JDK-8065960 [TEST_BUG] Several tests still depending on sun.awt.exception.handler should be rewritten
- Open
-
JDK-6727884 Some Uncaught Exceptions are no longer getting sent to the Uncaught Exception Handlers
- Closed