Package org.jetbrains.annotations
Annotation Type UnknownNullability
-
@Documented @Retention(CLASS) @Target(TYPE_USE) public @interface UnknownNullability
An element annotated withUnknownNullability
claims that no specific nullability should be assumed by static analyzer. The unconditional dereference of the annotated value should not trigger a static analysis warning by default (though static analysis tool may have an option to perform stricter analysis and issue warnings for@UnknownNullability
as well). It's mainly useful at method return types to mark methods that may occasionally returnnull
but in many cases, user knows that in this particular code pathnull
is not possible, so producing a warning would be annoying.The
UnknownNullability
is the default nullability for unannotated methods, so it's rarely necessary. An explicit annotation may serve to document the method behavior and also to override automatic annotation inference result that could be implemented in some static analysis tools.