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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16.5 Definite Assignment and Enum Constants DEFINITE ASSIGNMENT<br />

548<br />

16.5 Definite Assignment and Enum Constants<br />

<strong>The</strong> rules determining when a variable is definitely assigned or definitely unassigned<br />

before an enum constant are given §16.8.<br />

DISCUSSION<br />

This is because an enum constant is essentially a static final field (§8.3.1.1, §8.3.1.2) that<br />

is initialized with a class instance creation expression (§15.9).<br />

• V is definitely assigned before the declaration of a class body of an enum constant<br />

with no arguments that is declared within the scope of V iff V is definitely<br />

assigned before the enum constant.<br />

• V is definitely assigned before the declaration of the class body of an enum<br />

constant with arguments that is declared within the scope of V iff V is definitely<br />

assigned after the last argument expression of the enum constant<br />

<strong>The</strong> definite assignment/unassignment status of any construct within the class<br />

body of an enum constant is governed by the usual rules for classes.<br />

Let y be an argument of an enum constant, but not the first. <strong>The</strong>n:<br />

• V is [un]assigned before y iff it is [un]assigned after the argument to the left of<br />

y<br />

Otherwise:<br />

• V is [un]assigned before the first argument to an enum constant iff it is<br />

[un]assigned before the enum constant<br />

DRAFT<br />

16.6 Definite Assignment and Anonymous Classes<br />

• V is definitely assigned before an anonymous class declaration (§15.9.5) that<br />

is declared within the scope of V iff V is definitely assigned after the class<br />

instance creation expression that declares the anonymous class.

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

Saved successfully!

Ooh no, something went wrong!