10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BLOCKS AND STATEMENTS Unreachable Statements 14.21<br />

• A break, continue, return, or throw statement cannot complete normally.<br />

• A synchronized statement can complete normally iff the contained statement<br />

can complete normally. <strong>The</strong> contained statement is reachable iff the<br />

synchronized statement is reachable.<br />

• A try statement can complete normally iff both of the following are true:<br />

◆ <strong>The</strong> try block can complete normally or any catch block can complete<br />

normally.<br />

◆ If the try statement has a finally block, then the finally block can complete<br />

normally.<br />

• <strong>The</strong> try block is reachable iff the try statement is reachable.<br />

• A catch block C is reachable iff both of the following are true:<br />

◆ Some expression or throw statement in the try block is reachable and can<br />

throw an exception whose type is assignable to the parameter of the catch<br />

clause C. (An expression is considered reachable iff the innermost statement<br />

containing it is reachable.)<br />

◆ <strong>The</strong>re is no earlier catch block A in the try statement such that the type of<br />

C’s parameter is the same as or a subclass of the type of A’s parameter.<br />

• If a finally block is present, it is reachable iff the try statement is reachable.<br />

One might expect the if statement to be handled in the following manner, but<br />

these are not the rules that the <strong>Java</strong> programming language actually uses:<br />

• HYPOTHETICAL: An if–then statement can complete normally iff at least<br />

one of the following is true:<br />

◆ <strong>The</strong> if–then statement is reachable and the condition expression is not a<br />

constant expression whose value is true.<br />

DRAFT<br />

◆ <strong>The</strong> then–statement can complete normally.<br />

• <strong>The</strong> then–statement is reachable iff the if–then statement is reachable and<br />

the condition expression is not a constant expression whose value is false.<br />

• HYPOTHETICAL: An if–then–else statement can complete normally iff<br />

the then–statement can complete normally or the else–statement can complete<br />

normally. <strong>The</strong> then-statement is reachable iff the if–then–else statement<br />

is reachable and the condition expression is not a constant expression<br />

whose value is false. <strong>The</strong> else statement is reachable iff the if–then–else<br />

405

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!