166e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilsonpackage javax.annotation.concurrent;
266e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson
366e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilsonimport java.lang.annotation.ElementType;
466e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilsonimport java.lang.annotation.Retention;
566e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilsonimport java.lang.annotation.RetentionPolicy;
666e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilsonimport java.lang.annotation.Target;
766e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson
866e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson/*
966e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * Copyright (c) 2005 Brian Goetz
1066e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * Released under the Creative Commons Attribution License
1166e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson *   (http://creativecommons.org/licenses/by/2.5)
1266e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * Official home: http://www.jcip.net
1366e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson */
1466e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson
1566e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson/**
1666e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * GuardedBy
1766e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson *
1866e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * The field or method to which this annotation is applied can only be accessed
1966e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * when holding a particular lock, which may be a built-in (synchronization)
2066e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * lock, or may be an explicit java.util.concurrent.Lock.
2166e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson *
2266e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * The argument determines which lock guards the annotated field or method: this :
2366e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * The string literal "this" means that this field is guarded by the class in
2466e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * which it is defined. class-name.this : For inner classes, it may be necessary
2566e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * to disambiguate 'this'; the class-name.this designation allows you to specify
2666e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * which 'this' reference is intended itself : For reference fields only; the
2766e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * object to which the field refers. field-name : The lock object is referenced
2866e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * by the (instance or static) field specified by field-name.
2966e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * class-name.field-name : The lock object is reference by the static field
3066e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * specified by class-name.field-name. method-name() : The lock object is
3166e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * returned by calling the named nil-ary method. class-name.class : The Class
3266e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson * object for the specified class should be used as the lock object.
3366e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson */
3466e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson@Target( { ElementType.FIELD, ElementType.METHOD })
3566e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson@Retention(RetentionPolicy.CLASS)
3666e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilsonpublic @interface GuardedBy {
3766e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson    String value();
3866e84b9ff30de7c75b510cb9117205368cf5bd25Jesse Wilson}
39