Annotation Type UnderInitialization
-
@Documented @Retention(RUNTIME) @Target({TYPE_USE,TYPE_PARAMETER}) @SubtypeOf(UnknownInitialization.class) public @interface UnderInitialization
This type qualifier indicates that an object is (definitely) in the process of being constructed/initialized. The type qualifier also indicates how much of the object has already been initialized. Please see the manual for examples of how to use the annotation (the link appears below).Consider a class
B
that is a subtype ofA
. At the beginning of the constructor ofB
,this
has the type@UnderInitialization(A.class)
, since all fields ofA
have been initialized by the super-constructor. Inside the constructor body, as soon as all fields ofB
are initialized, then the type ofthis
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
considersNonNull
. The initialization type system 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.- See the Checker Framework Manual:
- Initialization Checker, Examples of the @UnderInitialization
annotation
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>
value
The type-frame down to which the expression (of this type) has been initialized at least (inclusive).
-
-
-
Element Detail
-
value
java.lang.Class<?> value
The type-frame down to which the expression (of this type) has been initialized at least (inclusive). That is, an expression of type@UnderInitialization(T.class)
has all type-frames initialized starting atObject
down to (and including)T
.- Returns:
- the type whose fields are fully initialized
- Default:
- java.lang.Object.class
-
-