Java Reference
In-Depth Information
The Block immediately after the keyword finally is called the finally block of the try state-
ment.
A try statement may have catch clauses, also called exception handlers .
A catch clause has exactly one parameter, which is called an exception parameter .
The scope and shadowing of an exception parameter is specified in § 6.3 and § 6.4 .
An exception parameter may denote its type as either a single class type or a union of two
or more class types (called alternatives ). The alternatives of a union are syntactically sep-
arated by | .
A catch clause whose exception parameter is denoted as a single class type is called a
uni- catch clause .
A catch clause whose exception parameter is denoted as a union of types is called a
multi- catch clause .
Each class type used in the denotation of the type of an exception parameter must be the
class Throwable or a subclass of Throwable , or a compile-time error occurs.
It is a compile-time error if a type variable is used in the denotation of the type of an ex-
ception parameter.
It is a compile-time error if a union of types contains two alternatives D i and D j ( i j )
where D i is a subtype of D j 4.10.2 ) .
The declared type of an exception parameter that denotes its type with a single class type is
that class type.
The declared type of an exception parameter that denotes its type as a union with alternat-
ives D 1 | D 2 | ... | D n is lub(D 1 , D 2 , ..., D n ) (§ 15.12.2.7 ).
An exception parameter of a multi- catch clause is implicitly declared final if it is not expli-
citly declared final .
It is a compile-time error if an exception parameter that is implicitly or explicitly declared
final is assigned to within the body of the catch clause.
In a uni- catch clause, an exception parameter that is not declared final (implicitly or expli-
citly) is considered effectively final if it never occurs within its scope as the left-hand oper-
and of an assignment operator (§ 15.26 ).
Search WWH ::




Custom Search