Annotation Interface UnknownNullability


@Documented @Retention(CLASS) @Target(TYPE_USE) public @interface UnknownNullability
An element annotated with UnknownNullability 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 return null but in many cases, user knows that in this particular code path null 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.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Element Details

    • value

      Returns:
      textual reason when the annotated value could be null, for documentation purposes.
      Default:
      ""