Annotation Interface NonNull
@Documented
@Retention(RUNTIME)
@Target({TYPE_USE,TYPE_PARAMETER})
@SubtypeOf(MonotonicNonNull.class)
@DefaultQualifierInHierarchy
@QualifierForLiterals(STRING)
@DefaultFor(EXCEPTION_PARAMETER)
@UpperBoundFor(typeKinds={PACKAGE,INT,BOOLEAN,CHAR,DOUBLE,FLOAT,LONG,SHORT,BYTE})
public @interface NonNull
If an expression's type is qualified by
@NonNull
, then the expression never evaluates to
null
. (Unless the program has a bug; annotations specify intended behavior.)
For fields of a class, the NonNull
annotation indicates that this field is never
null
after the class has been fully initialized. For static fields, the NonNull
annotation indicates that this field is never null
after the containing
class is initialized. "Fully initialized" essentially means that the Java constructor has
completed. See the Initialization Checker
documentation for more details.
This annotation is rarely written in source code, because it is the default.
- See Also:
- See the Checker Framework Manual:
- Nullness Checker, Initialization Checker, the bottom type