Java Reference
In-Depth Information
for exception handlers (§ 11.2 ) , it is typical to define most new exception classes as
checked exception classes, that is, as subclasses of Exception that are not subclasses of
RuntimeException .
11.1.2. The Causes of Exceptions
An exception is thrown for one of three reasons:
• A throw statement (§ 14.18 ) was executed.
• An abnormal execution condition was synchronously detected by the Java Virtual
Machine, namely:
♦ evaluation of an expression violates the normal semantics of the Java program-
ming language (§ 15.6 ) , such as an integer divide by zero.
♦ an error occurs while loading, linking, or initializing part of the program
12.2 , § 12.3 , § 12.4 ) ; in this case, an instance of a subclass of LinkageError is
thrown.
♦ an internal error or resource limitation prevents the Java Virtual Machine from
implementing the semantics of the Java programming language; in this case,
an instance of a subclass of VirtualMethodError is thrown.
These exceptions are not thrown at an arbitrary point in the program, but rather at a
point where they are specified as a possible result of an expression evaluation or
statement execution.
• An asynchronous exception occurred (§ 11.1.3 ) .
11.1.3. Asynchronous Exceptions
Most exceptions occur synchronously as a result of an action by the thread in which they
occur, and at a point in the program that is specified to possibly result in such an exception.
An asynchronous exception is, by contrast, an exception that can potentially occur at any
point in the execution of a program.
Asynchronous exceptions occur only as a result of:
• An invocation of the (deprecated) stop method of class Thread or ThreadGroup .
The (deprecated) stop methods may be invoked by one thread to affect another
thread or all the threads in a specified thread group. They are asynchronous be-
cause they may occur at any point in the execution of the other thread or threads.
• An internal error or resource limitation in the Java Virtual Machine that prevents it
from implementing the semantics of the Java programming language. In this case,
Search WWH ::




Custom Search