Annotation Interface UnannotatedFor


Indicates that this package, class, method, or constructor has not been annotated for the given type system, even though an enclosing element is annotated for it. For example, if a package is @AnnotatedFor("nullness") but one of its classes has not been annotated with @Nullable and friends, mark that class @UnannotatedFor("nullness"). The argument to UnannotatedFor is not an annotation name, but a checker name.

This annotation has no effect unless the -AuseConservativeDefaultsForUncheckedCode=source or the -AonlyAnnotatedFor command-line argument is supplied. It only subtracts from the scope of an enclosing AnnotatedFor: an element in its scope is treated as if no enclosing @AnnotatedFor were present, so its warnings are suppressed, and under -AuseConservativeDefaultsForUncheckedCode=source it is also defaulted using conservative defaults. (-AonlyAnnotatedFor suppresses warnings without changing defaults, the same as for AnnotatedFor.) An @AnnotatedFor on a nested element takes effect again for that element. Writing both an @AnnotatedFor and an @UnannotatedFor that name the same checker on one declaration is a warning ( conflicting.annotatedfor), because the two contradict each other; if that warning is suppressed, the @AnnotatedFor wins, since @UnannotatedFor only subtracts from an enclosing scope.

Like AnnotatedFor, this annotation is stored in class files and is available via reflection at run time.

An @UnannotatedFor on a package also applies to subpackages, unless the applyToSubpackages field is set to false. The innermost package annotation wins: an @UnannotatedFor on a package excludes its subpackages from an @AnnotatedFor on an enclosing package, and vice versa.

You may write multiple @UnannotatedFor annotations at the same location, for example to give two type systems different applyToSubpackages settings on one package:

   @UnannotatedFor(value = "nullness", applyToSubpackages = false)
   @UnannotatedFor(value = "index", applyToSubpackages = true)
   package mypackage;
 
See the Checker Framework Manual:
Compiling partially-annotated libraries
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    A wrapper annotation that makes the UnannotatedFor annotation repeatable.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Returns the type systems for which the annotated element has not been annotated.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    When used on a package, whether this annotation should also apply to subpackages.
  • Element Details

    • value

      String[] value
      Returns the type systems for which the annotated element has not been annotated. Legal arguments are any string that may be passed to the -processor command-line argument: the fully-qualified class name for the checker, or a shorthand for built-in checkers. Using the annotation with no arguments, as in @UnannotatedFor({}), has no effect.
      Returns:
      the type systems for which the annotated element has not been annotated
      See the Checker Framework Manual:
      Short names for built-in checkers
    • applyToSubpackages

      boolean applyToSubpackages
      When used on a package, whether this annotation should also apply to subpackages.
      Returns:
      whether this annotation should be inherited by subpackages
      Default:
      true