15.5
Normal and Abrupt Completion of Evaluation
EXPRESSIONS
15.5 Normal and Abrupt Completion of Evaluation
No more: the end is sudden and abrupt.
William Wordsworth,
Apology for the Foregoing Poems
(1831)
Every expression has a normal mode of evaluation in which certain computational
steps are carried out. The following sections describe the normal mode of evalua
tion for each kind of expression. If all the steps are carried out without an excep
tion being thrown, the expression is said to
complete normally
.
If, however, evaluation of an expression throws an exception, then the expres
sion is said to
complete abruptly
. An abrupt completion always has an associated
reason
, which is always a
throw
with a given value.
Run time exceptions are thrown by the predefined operators as follows:
A class instance creation expression ( 15.8), array creation expression
( 15.9), or string concatenation operatior expression ( 15.17.1) throws an
OutOfMemoryError
if there is insufficient memory available.
An array creation expression throws an
ArrayNegativeSizeException
if
the value of any dimension expression is less than zero ( 15.9).
A field access ( 15.10) throws a
NullPointerException
if the value of the
object reference expression is
null
.
A method invocation expression ( 15.11) that invokes an instance method
throws a
NullPointerException
if the target reference is
null
.
An array access ( 15.12) throws a
NullPointerException
if the value of
the array reference expression is
null
.
An array access ( 15.12) throws an
IndexOutOfBoundsException
if the
value of the array index expression is negative or greater than or equal to the
length
of the array.
A cast ( 15.15) throws a
ClassCastException
if a cast is found to be imper
missible at run time.
An integer division ( 15.16.2) or integer remainder ( 15.16.3) operator
throws an
ArithmeticException
if the value of the right hand operand
expression is zero.
An assignment to an array component of reference type ( 15.25.1) throws an
ArrayStoreException
when the value to be assigned is not compatible with
the component type of the array.
304
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved