ImmutableAnnotationChecker
Annotations should always be immutable

Severity
WARNING
Tags
LikelyError
Has Fix?
REQUIRES_HUMAN_ATTENTION

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 the suppression annotation @SuppressWarnings("ImmutableAnnotationChecker") to the enclosing element.