Java Reference
In-Depth Information
The exception mechanism of the Java SE platform is integrated with its synchronization
model (§ 17.1 ) , so that monitors are unlocked as synchronized statements (§ 14.19 ) and invoc-
ations of synchronized methods (§ 8.4.3.6 , § 15.12 ) complete abruptly.
11.1. The Kinds and Causes of Exceptions
11.1.1. The Kinds of Exceptions
An exception is represented by an instance of the class Throwable (a direct subclass of Object )
or one of its subclasses.
Throwable and all its subclasses are, collectively, the exception classes .
Note that a subclass of Throwable must not be generic (§ 8.1.2 ) .
The classes Exception and Error are direct subclasses of Throwable .
Exception is the superclass of all the exceptions from which ordinary programs may wish to
recover.
Error is the superclass of all the exceptions from which ordinary programs are not ordinarily
expected to recover.
Error and all its subclasses are, collectively, the error classes .
The class Error is a separate subclass of Throwable , distinct from Exception in the class
hierarchy, to allow programs to use the idiom “ } catch (Exception e) { ” (§ 11.2.3 ) to catch
all exceptions from which recovery may be possible without catching errors from
which recovery is typically not possible.
The class RuntimeException is a direct subclass of Exception . RuntimeException is the superclass
of all the exceptions which may be thrown for many reasons during expression evaluation,
but from which recovery may still be possible.
RuntimeException and all its subclasses are, collectively, the run-time exception classes .
The unchecked exception classes are the run-time exception classes and the error classes.
The checked exception classes are all exception classes other than the unchecked exception
classes. That is, the checked exception classes are all subclasses of Throwable other than
RuntimeException and its subclasses and Error and its subclasses.
Programs can use the pre-existing exception classes of the Java SE platform API in
throw statements, or define additional exception classes as subclasses of Throwable or
of any of its subclasses, as appropriate. To take advantage of compile-time checking
Search WWH ::




Custom Search