01: package net.jcip.annotations;
02:
03: import java.lang.annotation.ElementType;
04: import java.lang.annotation.Retention;
05: import java.lang.annotation.RetentionPolicy;
06: import java.lang.annotation.Target;
07:
08: /*
09: * Copyright (c) 2005 Brian Goetz
10: * Released under the Creative Commons Attribution License
11: * (http://creativecommons.org/licenses/by/2.5)
12: * Official home: http://www.jcip.net
13: */
14:
15: /**
16: * GuardedBy
17: *
18: * The field or method to which this annotation is applied can only be accessed
19: * when holding a particular lock, which may be a built-in (synchronization) lock,
20: * or may be an explicit java.util.concurrent.Lock.
21: *
22: * The argument determines which lock guards the annotated field or method:
23: * this : The string literal "this" means that this field is guarded by the
24: * class in which it is defined.
25: * class-name.this : For inner classes, it may be necessary to disambiguate 'this';
26: * the class-name.this designation allows you to specify which 'this' reference is intended
27: * itself : For reference fields only; the object to which the field refers.
28: * field-name : The lock object is referenced by the (instance or static) field specified by field-name.
29: * class-name.field-name : The lock object is reference by the static field specified by class-name.field-name.
30: * method-name() : The lock object is returned by calling the named nil-ary method.
31: * class-name.class : The Class object for the specified class should be used as the lock object.
32: */
33: @Target({ElementType.FIELD,ElementType.METHOD})
34: @Retention(RetentionPolicy.CLASS)
35: public @interface GuardedBy {
36: String value();
37: }
|