Java Reference
In-Depth Information
the exception is not caught, the thread of execution terminates, after
giving the thread's
UncaughtExceptionHandler
a chance to handle the ex-
ceptionsee "
Threads and Exceptions
"
on page
379
.
Once an exception occurs, actions after the point at which the exception
occurred do not take place. If evaluation of a left-operand causes an ex-
ception then no part of the right-operand is evaluated; if evaluation of
a left argument expression results in an exception, then no argument to
the right is evaluated. The next action to occur will be in either a
finally
block, or a
catch
block that catches the exception.
12.2.2. Asynchronous Exceptions
A
tHRow
statement results in a
synchronous
exception, as does, say,
a divide-by-zero arithmetic exceptionthe exception occurs directly as a
result of executing a particular instruction; either the
throw
or dividing
by zero. In contrast an
asynchronous
exception is one that can occur at
any time, regardless of the instructions being executed.
Asynchronous exceptions can occur in only two specific ways. The first
is an internal error in the Java virtual machinesuch exceptions are con-
sidered asynchronous because they are caused by the execution of in-
structions in the virtual machine, not the instructions of the program.
Needless to say, there is little that you can do about an internal error.
The second mechanism is the use of the deprecated
Thread.stop
meth-
ods, or the related, and not deprecated,
stopThread
methods of the JVM
™
Tool Interface (
JVMTI
)a native code interface to the virtual machine that
allows for the inspection, and control of, a running application. These
methods allow an asynchronous exception of any kind (checked or un-
checked) to be thrown at any point during the execution of the target
thread. Such a mechanism is inherently dangerous, which is why it has