ImmutableAnnotationChecker
Annotations should always be immutable

Category
Severity
WARNING
Maturity

Alternate names: Immutable

The problem

Annotations should always be immutable.

Static state is dangerous to begin with, but much worse for annotations. Annotation instances are usually constants, and it is very surprising if their state ever changes, or if they are not thread-safe.

TIP: prefer [@AutoAnnotation] to writing annotation implementations by hand.

To make annotation implementations immutable, ensure:

TIP: annotating the declaration of an annotation with @Immutable is unnecessary – Error Prone assumes annotations are immutable by default.

Suppression

Suppress false positives by adding an @SuppressWarnings("ImmutableAnnotationChecker") annotation to the enclosing element.