Java Reference
In-Depth Information
Note that there are no rules that would allow us to conclude that
V
is definitely
unassigned before a static variable initializer or enum constant. We can in-
formally conclude that
V
is not definitely unassigned before any static variable
initializer of
C
, but there is no need for such a rule to be stated explicitly.
Let
C
be a class, and let
V
be a blank
static final
member field of
C
, declared in
C
. Then:
•
V
is definitely unassigned (and moreover is not definitely assigned) before the left-
•
V
is [un]assigned before an enum constant, static initializer, or static variable ini-
tializer of
C
other than the leftmost iff
V
is [un]assigned after the preceding enum
constant, static initializer, or static variable initializer of
C
.
Let
C
be a class, and let
V
be a blank
static final
member field of
C
, declared in a superclass
of
C
. Then:
•
V
is definitely assigned (and moreover is not definitely unassigned) before every
enum constant of
C
.
•
V
is definitely assigned (and moreover is not definitely unassigned) before the
block that is the body of a static initializer of
C
.
•
V
is definitely assigned (and moreover is not definitely unassigned) before every
static variable initializer of
C
.
16.9. Definite Assignment, Constructors, and Instance Initializers
Let
C
be a class declared within the scope of
V
. Then:
is definitely assigned before the declaration of
C
.
Note that there are no rules that would allow us to conclude that
V
is definitely
unassigned before an instance variable initializer. We can informally conclude
that
V
is not definitely unassigned before any instance variable initializer of
C
,
but there is no need for such a rule to be stated explicitly.
Let
C
be a class, and let
V
be a blank
final
non-
static
member field of
C
, declared in
C
. Then:
•
V
is definitely unassigned (and moreover is not definitely assigned) before the left-
most instance initializer (§
8.6
) or instance variable initializer of
C
.
•
V
is [un]assigned before an instance initializer or instance variable initializer of
C
other than the leftmost iff
V
is [un]assigned after the preceding instance initializer
or instance variable initializer of
C
.