Java Reference
In-Depth Information
To shorten the description of the rules, the customary abbreviation “iff” is used to mean “if
and only if.”
A reachable break statement exits a statement if, within the break target, either there are no
try statements whose try blocks contain the break statement, or there are try statements whose
try blocks contain the break statement and all finally clauses of those try statements can com-
plete normally.
This definition is based on the logic around “attempts to transfer control” in § 14.15 .
A continue statement continues a do statement if, within the do statement, either there are
no try statements whose try blocks contain the continue statement, or there are try statements
whose try blocks contain the continue statement and all finally clauses of those try statements
can complete normally.
The rules are as follows:
• The block that is the body of a constructor, method, instance initializer, or static
initializer is reachable.
• An empty block that is not a switch block can complete normally iff it is reachable.
A non-empty block that is not a switch block can complete normally iff the last
statement in it can complete normally.
The first statement in a non-empty block that is not a switch block is reachable iff
the block is reachable.
Every other statement S in a non-empty block that is not a switch block is reach-
able iff the statement preceding S can complete normally.
• A local class declaration statement can complete normally iff it is reachable.
• A local variable declaration statement can complete normally iff it is reachable.
• An empty statement can complete normally iff it is reachable.
• A labeled statement can complete normally if at least one of the following is true:
♦ The contained statement can complete normally.
♦ There is a reachable break statement that exits the labeled statement.
The contained statement is reachable iff the labeled statement is reachable.
• An expression statement can complete normally iff it is reachable.
• The if statement, whether or not it has an else part, is handled in an unusual manner.
For this reason, it is discussed separately at the end of this section.
• An assert statement can complete normally iff it is reachable.
Search WWH ::




Custom Search