Annotation Interface SideEffectsOnly
@SideEffectsOnly({"A", "B"}) changes
the value of at most the expressions A and B. No other expression is directly modified by the
method. Absent aliasing, no other expression has a different value after a call to the method.
But checking of this annotation (under -AcheckPurityAnnotations) treats two expressions
as possibly aliased only when an assignment relating them appears in the method body.
This annotation is inherited by subtypes, just as if it were meta-annotated with
@InheritedAnnotation.
On a constructor, this annotation constrains what the constructor modifies besides the object
being constructed. Assigning to the new object's own fields is always permitted and need not be
listed, because the object did not exist before the call; writing this in the annotation
is legal but has no additional effect. At a new expression, the expressions that are
reached through this are ignored, because the object being constructed did not exist
before the call. A constructor's annotation does not yet affect type refinement at new
expressions.
- See the Checker Framework Manual:
- Checking
-
Required Element Summary
Required Elements
-
Element Details
-
value
An upper bound on the expressions that this method might change the value of.Each expression must denote the same location every time it is evaluated: it must be a variable, a field access, an array access, a literal, a class name, or a call to a
Puremethod, recursively. A@Puremethod returns the same value every time it is called with the same arguments, so a call to one qualifies so long as its receiver and its arguments do. An expression such as"#1.getList()", wheregetListis not@Pure, may denote a different value each time it is evaluated, so no method body could satisfy it.- Returns:
- the Java expressions that the annotated method might side-effect
- See the Checker Framework Manual:
- Syntax of Java expressions
-