Home | History | Annotate | Download | only in concurrent
      1 package javax.annotation.concurrent;
      2 
      3 import java.lang.annotation.ElementType;
      4 import java.lang.annotation.Retention;
      5 import java.lang.annotation.RetentionPolicy;
      6 import java.lang.annotation.Target;
      7 
      8 /*
      9  * 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)
     20  * lock, or may be an explicit java.util.concurrent.Lock.
     21  *
     22  * The argument determines which lock guards the annotated field or method: this :
     23  * The string literal "this" means that this field is guarded by the class in
     24  * which it is defined. class-name.this : For inner classes, it may be necessary
     25  * to disambiguate 'this'; the class-name.this designation allows you to specify
     26  * which 'this' reference is intended itself : For reference fields only; the
     27  * object to which the field refers. field-name : The lock object is referenced
     28  * by the (instance or static) field specified by field-name.
     29  * class-name.field-name : The lock object is reference by the static field
     30  * specified by class-name.field-name. method-name() : The lock object is
     31  * returned by calling the named nil-ary method. class-name.class : The Class
     32  * object for the specified class should be used as the lock object.
     33  */
     34 @Target( { ElementType.FIELD, ElementType.METHOD })
     35 @Retention(RetentionPolicy.CLASS)
     36 public @interface GuardedBy {
     37     String value();
     38 }
     39