|
CHAPTER 11: Exceptions |
|
 Previous |
 Java Language |
 Index |
 Next |
11.1 The Causes of Exceptions
An exception is thrown for one of three reasons:
- An abnormal execution condition was synchronously detected by a Java Virtual Machine. Such conditions arise because:
- evaluation of an expression violates the normal semantics of the Java language, such as an integer divide by zero, as summarized in S15.5
- an error occurs in loading or linking part of the Java program (S12.2, S12.3)
- some limitation a resource is exceeded, such as using too much memory
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.
- A throw
statement (S14.16) was executed in Java code.
- An asynchronous exception occurred either because:
- the method stop
of class Thread
(S20.20.16) was invoked
- an internal error has occurred in the virtual machine (S11.5.2.2)
Exceptions are represented by instances of the class Throwable
and instances of its subclasses. These classes are, collectively, the exception classes.
| © 1996 Sun Microsystems, Inc. All rights reserved. |