BLOCKS AND STATEMENTS
Unreachable Statements
14.19
14.19   Unreachable Statements
That looks like a path.
Is that the way to reach the top from here?
 Robert Frost,
The Mountain
 (1915)
It is a compile time error if a statement cannot be executed because it is
unreach 
able
. Every Java compiler must carry out the conservative flow analysis specified
here to make sure all statements are reachable.
This section is devoted to a precise explanation of the word  reachable.  The
idea is that there must be some possible execution path from the beginning of the
constructor, method, or static initializer that contains the statement to the state 
ment itself. The analysis takes into account the structure of statements. Except for
the special treatment of
while
,
do
, and
for
 statements whose condition expres 
sion has the constant value
true
, the values of expressions are not taken into
account in the flow analysis. For example, a Java compiler will accept the code:
{
int n = 5;
while (n > 7) n = 2;
}
even though the value of
n
 is known at compile time and in principle it can be
known at compile time that the assignment to
k
 can never be executed. A Java
compiler must operate according to the rules laid out in this section.
The rules in this section define two technical terms:
whether a statement is
reachable
whether a statement
can complete normally
The definitions here allow a statement to complete normally only if it is reachable.
To shorten the description of the rules, the customary abbreviation  iff  is
used to mean  if and only if. 
The rules are as follows:
The block that is the body of a constructor, method, or static initializer is
reachable.
An empty block that is not a switch block can complete normally iff it is
reachable. A nonempty block that is not a switch block can complete nor 
mally iff the last statement in it can complete normally. The first statement in
a nonempty block that is not a switch block is reachable iff the block is reach 
able. Every other statement
S
 in a nonempty block that is not a switch block is
reachable iff the statement preceding
S
 can complete normally.
295






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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