01: /*
02: * Copyright (c) 2005 Brian Goetz and Tim Peierls
03: * Released under the Creative Commons Attribution License
04: * (http://creativecommons.org/licenses/by/2.5)
05: * Official home: http://www.jcip.net
06: *
07: * Any republication or derived work distributed in source code form
08: * must include this copyright and license notice.
09: */
10:
11: package net.jcip.annotations;
12:
13: import java.lang.annotation.ElementType;
14: import java.lang.annotation.Retention;
15: import java.lang.annotation.RetentionPolicy;
16: import java.lang.annotation.Target;
17:
18: /**
19: * The field or method to which this annotation is applied can only be accessed
20: * when holding a particular lock, which may be a built-in (synchronization) lock,
21: * or may be an explicit java.util.concurrent.Lock.
22: *
23: * The argument determines which lock guards the annotated field or method:
24: * <ul>
25: * <li>
26: * <code>this</code> : The intrinsic lock of the object in whose class the field is defined.
27: * </li>
28: * <li>
29: * <code>class-name.this</code> : For inner classes, it may be necessary to disambiguate 'this';
30: * the <em>class-name.this</em> designation allows you to specify which 'this' reference is intended
31: * </li>
32: * <li>
33: * <code>itself</code> : For reference fields only; the object to which the field refers.
34: * </li>
35: * <li>
36: * <code>field-name</code> : The lock object is referenced by the (instance or static) field
37: * specified by <em>field-name</em>.
38: * </li>
39: * <li>
40: * <code>class-name.field-name</code> : The lock object is reference by the static field specified
41: * by <em>class-name.field-name</em>.
42: * </li>
43: * <li>
44: * <code>method-name()</code> : The lock object is returned by calling the named nil-ary method.
45: * </li>
46: * <li>
47: * <code>class-name.class</code> : The Class object for the specified class should be used as the lock object.
48: * </li>
49: */
50: @Target({ElementType.FIELD,ElementType.METHOD})
51: @Retention(RetentionPolicy.RUNTIME)
52: public @interface GuardedBy {
53: String value();
54: }
|