-
Enhancement
-
Resolution: Fixed
-
P4
-
1.1, 1.1.2, 1.1.6
-
beta
-
generic, sparc
-
generic, solaris_2.5.1, solaris_10
In certain circumstance you will want to use the uncaughtException method in
the ThreadGroup class to deal with all uncaught exceptions
However, the AWT event dispatch code appears to deal with all uncaught
exceptions originating from the AWT event dispatch thread and thereby
stops them from propogating upto the ThreadGroup uncaughtException method.
The critical section of the awt is in src/java/awt/EventDispatchThread.java
class EventDispatchThread extends Thread {
...
try {
...process events off the AWT event queue inside a
try/catch block...
} catch (Throwable e) {
System.err.println(
"Exception occurred during event dispatching:");
e.printStackTrace();
}
If you have a event handler method such as a listner any exeption raised
in the users code which then generates an exception will be propergated
to the EventDispatchThread exception handler and not the ThreadGroup
handler.
In most cases this is acceptable behaviour however where someone wants
that bit more control and error recovery the awt routine gets in the way.
For a real world example in the attachments called DemoApp.java which is
a standalone application that creates a thread group and a thread creates
a frame with a textarea and button.
The Thread is run and then I've included a simple class to output the
thread stack when the button is pressed. Here is an example of the
output
Thread Group: system Max Priority: 10
Thread: Clock Priority: 12 Daemon
Thread: Idle thread Priority: 0 Daemon
Thread: Async Garbage Collector Priority: 1 Daemon
Thread: Finalizer thread Priority: 1 Daemon
Thread: AWT-Finalizer Priority: 9 Daemon
Thread Group: main Max Priority: 10
Thread: main Priority: 5
Thread: Screen Updater Priority: 4
Thread Group: DemoApp Main ThreadGroup Max Priority: 10
Thread: AWT-EventQueue-0 Priority: 5
Thread: AWT-Input Priority: 5
Thread: AWT-Motif Priority: 5
Notice that the thread group "DemoApp Main ThreadGroup" is the parent of
the AWT- threads so it would be possible to have exceptions propergate
upwards.
- duplicates
-
JDK-4244774 ThreadGroup.uncaughtException isn't sufficient
-
- Closed
-
-
JDK-4158296 need pluggable handler for unchecked exceptions on EventDispatchThread
-
- Closed
-
- relates to
-
JDK-4499199 Modal dialog doesn't handle exceptions correctly
-
- Resolved
-
-
JDK-6727884 Some Uncaught Exceptions are no longer getting sent to the Uncaught Exception Handlers
-
- Closed
-