Annotation Type GuardedBy


  • @Documented
    @Target({FIELD,METHOD})
    @Retention(RUNTIME)
    public @interface GuardedBy
    The presence of this annotation indicates that the field or method must only be accessed when holding the specified lock.
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String value
      The specified lock that guards the annotated field or method.
    • Element Detail

      • value

        java.lang.String value
        The specified lock that guards the annotated field or method. Valid values are:
        • this indicates the intrinsic lock of the instance containing the field or method.
        • class-name.this which allows for disambiguation of which this when dealing with inner classes
        • itself which is valid for reference fields only, and indicates that the referenced instance's own intrinsic lock should be used as the guard
        • field-name indicates the named instance or static field is to be used as the guard. If the field type is not a sub-type of Lock then the intrinsic lock of the referenced instance is to be used
        • class-name.field-name indicates the named static field is to be used as the guard. If the field type is not a sub-type of Lock then the intrinsic lock of the referenced instance is to be used
        • method-name() indicates that the zero-argument method should be called to obtain the lock object. If the return type is not a sub-type of Lock then the intrinsic lock of the returned instance is to be used
        • class-name.class indicates that the intrinsic lock of the specified class should be used as the guard
        Returns:
        The specified lock that guards the annotated field or method