Annotation Interface AnnotatedFor
@AnnotatedFor({"nullness", "regex"}) indicates that the class has been annotated with
annotations such as @Nullable and @Regex. The argument to AnnotatedFor is
not an annotation name, but a checker name.
You should only use this annotation in a partially-annotated library. There is no point to using it in a fully-annotated library nor in an application that does not export APIs for clients.
This annotation has no effect unless the
-AuseConservativeDefaultsForUncheckedCode=source command-line argument is supplied. Ordinarily,
the -AuseConservativeDefaultsForUncheckedCode=source command-line argument causes
unannotated locations to be defaulted using conservative defaults, and it suppresses all
warnings. However, a class with a relevant @AnnotatedFor annotation is always defaulted
normally (typically using the CLIMB-to-top rule), and typechecking warnings are issued.
This annotation is stored in class files and is available via reflection at run time.
An @AnnotatedFor on a package also applies to subpackages, unless the
applyToSubpackages field is set to false. Setting it to false does not block an applicable
@AnnotatedFor on an enclosing package.
You may write multiple @AnnotatedFor annotations at the same location, for example to
give two type systems different applyToSubpackages settings on one package:
@AnnotatedFor(value = "nullness", applyToSubpackages = false) @AnnotatedFor(value = "index", applyToSubpackages = true) package mypackage;
- See the Checker Framework Manual:
- Compiling partially-annotated libraries
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceA wrapper annotation that makes theAnnotatedForannotation repeatable. -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhen used on a package, whether this annotation should also apply to subpackages.
-
Element Details
-
value
String[] valueReturns the type systems for which the class has been annotated. Legal arguments are any string that may be passed to the-processorcommand-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@AnnotatedFor({}), has no effect.- Returns:
- the type systems for which the class has been annotated
- See the Checker Framework Manual:
- Short names for built-in checkers
-
applyToSubpackages
boolean applyToSubpackagesWhen used on a package, whether this annotation should also apply to subpackages.- Returns:
- whether this annotation should be inherited by subpackages
- Default:
true
-