Java Reference
In-Depth Information
not terminate (using a conservative analysis) also have their terminatesNormally
flag set to false.
The isReachable and terminatesNormally fields are set according to the fol-
lowing rules:
If isReachable is true for a statement list, then it is also true for the first
statement in the list.
If terminatesNormally is false for the last statement in a statement list,
then it is also false for the whole statement list.
The statement list that comprises the body of a method, constructor, or
static initializer is always considered reachable (its isReachable value is
true).
A local variable declaration or an expression statement (assignment,
method call, heap allocation, variable increment, or decrement) always
has terminatesNormally set to true (even if the statement has isReachable
set to false). (This is done so that all of the statements following an
unreachable statement do not generate error messages.)
A null statement or statement list never generates an error message if its
isReachable field is false. Rather, the isReachable value is propagated to
the statement's (or statement list's) successor.
If a statement has a predecessor (it is not the first statement in a list),
then its isReachable value is equal to its predecessor's terminatesNormally
value. That is, a statement is reachable if and only if its predecessor
terminates normally.
As an example, consider the following method body:
void example() {
int v; v++; return; ; v=10; v=20; }
This method body is considered reachable, and thus, so is the declaration of
v. This declaration and the increment of variable v complete normally, but the
return does not (see Section 9.1.5). The null statement following the return is
unreachable, and propagates this fact to the assignment of 10, which generates
an error message. This assignment terminates normally, so its successor is
considered reachable.
In the following sections we will study the semantic analysis of the control
structures of Java. Included in this analysiswill bewhether or not the statement
in question terminates normally. We will set the terminatesNormally value for
 
Search WWH ::




Custom Search