Java Reference
In-Depth Information
The only objects that are considered definitely reachable at a point
di
are those that can be
shown to be reachable by the application of these rules:
• An object
B
is definitely reachable at
di
from
static
fields if there exists a write
w1
to a
static
field
v
of a class
C
such that the value written by
w1
is a reference to
B
,
the class
C
is loaded by a reachable classloader, and there does not exist a write
w2
to
v
such that
hb(w2, w1)
is not true and both
w1
and
w2
come-before
di
.
• An object
B
is definitely reachable from
A
at
di
if there is a write
w1
to an element
v
of
A
such that the value written by
w1
is a reference to
B
and there does not exist
a write
w2
to
v
such that
hb(w2, w1)
is not true and both
w1
and
w2
come-before
di
.
• If an object
C
is definitely reachable from an object
B
, and object
B
is definitely
reachable from an object
A
, then
C
is definitely reachable from
A
.
If an object
X
is marked as unreachable at
di
, then:
•
X
must not be definitely reachable at
di
from
static
fields; and
• All
active uses
of
X
in thread
t
that come-after
di
must occur in the finalizer invoc-
ation for
X
or as a result of thread
t
performing a read that comes-after
di
of a ref-
erence to
X
; and
• All reads that come-after
di
that see a reference to
X
must see writes to elements of
objects that were unreachable at
di
, or see writes that came-after
di
.
An action
a
is an active use of
X
if and only if at least one of the following conditions holds:
•
a
reads or writes an element of
X
•
a
locks or unlocks
X
and there is a lock action on
X
that happens-after the invoca-
tion of the finalizer for
X
•
a
writes a reference to
X
•
a
is an active use of an object
Y
, and
X
is definitely reachable from
Y
If an object
X
is marked as finalizable at
di
, then:
•
X
must be marked as unreachable at
di
; and
•
di
must be the only place where
X
is marked as finalizable; and
• actions that happen-after the finalizer invocation must come-after
di
.
12.7. Unloading of Classes and Interfaces
An implementation of the Java programming language may
unload
classes.