@Deprecated @Documented @Retention(value=RUNTIME) @Target(value=TYPE_USE) @SubtypeOf(value=Nullable.class) public @interface LazyNonNull
MonotonicNonNull
should be used
instead.
Indicates that a field (or variable) is lazily initialized to a non-null value. Once the field becomes non-null, it never becomes null again. There is no guarantee that the field ever becomes non-null, however.
Lazily initialized fields have these two properties:
When the field is first read within a method, the field cannot be
assumed to be non-null. After a check that a LazyNonNull
field
holds a non-null value, all subsequent accesses within that
method can be assumed to be non-null, even after arbitrary external
method calls that might access the field.
LazyNonNull
gives stronger guarantees than Nullable
.
After a check that a Nullable
field holds a non-null value, only
accesses until the next non-SideEffectFree
method is called can be assumed
to be non-null.
To indicate that a LazyNonNull
or Nullable
field is
non-null whenever a particular method is called, use
RequiresNonNull
.
Final fields are treated as LazyNonNull by default.
This annotation is associated with the NullnessChecker
.
Nullable
,
NullnessChecker