@SubtypeOf(value=UnknownInitialization.class) @Documented @Retention(value=RUNTIME) @Target(value={TYPE_USE,TYPE_PARAMETER}) public @interface UnderInitialization
Consider a class B
that is a subtype of A
. At the beginning of the constructor
of B
, this
has the type @UnderInitialization(A.class)
, since all fields
of A
have been initialized by the super-constructor. Inside the constructor body, as soon
as all fields of B
are initialized, then the type of this
changes to
@UnderInitialization(B.class)
.
Code is allowed to store potentially not-fully-initialized objects in the fields of a partially-initialized object, as long as all initialization is complete by the end of the constructor.
What type qualifiers on the field are considered depends on the checker; for instance, the
NullnessChecker
considers NonNull
. The
initialization type system (called "freedom before commitment") is not used on its own, but in
conjunction with some other type-system that wants to ensure safe initialization.
When an expression has type @UnderInitialization
, then no aliases that are typed
differently may exist.
Modifier and Type | Optional Element and Description |
---|---|
java.lang.Class<?> |
value
The type-frame down to which the expression (of this type) has been initialized at least
(inclusive).
|
public abstract java.lang.Class<?> value
@UnderInitialization(T.class)
has all
type-frames initialized starting at Object
down to (and including) T
.