-
Bug
-
Resolution: Fixed
-
P4
-
1.1
-
None
-
1.1.1
-
generic
-
generic
If a class is loaded within the AWT-Event Queue thread, and if that
class' initializer throws an exception, then the AWT-Event thread will
be killed. This happens because a
java.lang.ExceptionInInitializerError gets thrown. This is an Error, and not an
Exception, so the try block in java.awt.EventDispatchThread.run() doesn't catch
it.
IMHO, the problem here is than an exception in an initializer is considered an
"Error". Error means "something that we expect will never happen", but
exceptions get thrown in initializers all the time (well, at least there's
nothing to prevent a programmer from throwing such an exception.) It's
also quite easy to do by mistake: Invoke a method that throws
a RuntimeException.
Here's the stack backtrace, as of this writing:
java.lang.ExceptionInInitializerError
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java)
at
at java.awt.Button.processActionEvent(Button.java)
at java.awt.Button.processEvent(Button.java)
at java.awt.Component.dispatchEvent(Component.java)
at java.awt.EventDispatchThread.run(EventDispatchThread.java)
To reproduce, run HotJava on file:///home/billf/bugs/hostile/hostile.html
class' initializer throws an exception, then the AWT-Event thread will
be killed. This happens because a
java.lang.ExceptionInInitializerError gets thrown. This is an Error, and not an
Exception, so the try block in java.awt.EventDispatchThread.run() doesn't catch
it.
IMHO, the problem here is than an exception in an initializer is considered an
"Error". Error means "something that we expect will never happen", but
exceptions get thrown in initializers all the time (well, at least there's
nothing to prevent a programmer from throwing such an exception.) It's
also quite easy to do by mistake: Invoke a method that throws
a RuntimeException.
Here's the stack backtrace, as of this writing:
java.lang.ExceptionInInitializerError
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java)
at
at java.awt.Button.processActionEvent(Button.java)
at java.awt.Button.processEvent(Button.java)
at java.awt.Component.dispatchEvent(Component.java)
at java.awt.EventDispatchThread.run(EventDispatchThread.java)
To reproduce, run HotJava on file:///home/billf/bugs/hostile/hostile.html
- relates to
-
JDK-4931413 Regression-test java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html
-
- Closed
-