Annotation Type GuardedBy

Indicates that a thread may dereference the value referred to by the annotated variable only if the thread holds all the given lock expressions.

@GuardedBy({}) is the default type qualifier.

The argument is a string or set of strings that indicates the expression(s) that must be held, using the syntax of Java expressions described in the manual. The expressions evaluate to an intrinsic (built-in, synchronization) monitor or an explicit Lock. The expression "<self>" is also permitted; the type @GuardedBy("<self>") Object o indicates that the value referenced by o is guarded by the intrinsic (monitor) lock of the value referenced by o.

Two @GuardedBy annotations with different argument expressions are unrelated by subtyping.

See Also:
See the Checker Framework Manual:
Lock Checker, Example use of @GuardedBy
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    The Java value expressions that need to be held.