001 package edu.rice.cs.cunit.threadCheck.predicates;
002
003 import edu.rice.cs.cunit.threadCheck.PredicateLink;
004 import edu.rice.cs.cunit.threadCheck.Combine;
005
006 import java.lang.annotation.Retention;
007 import java.lang.annotation.RetentionPolicy;
008 import java.lang.annotation.Target;
009 import java.lang.annotation.ElementType;
010
011 /**
012 * An annotation used to designate methods that are only allowed to be run by the thread in the field specified by
013 * class and field name.
014 *
015 * @author Mathias Ricken
016 */
017 @Retention(RetentionPolicy.RUNTIME)
018 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
019
020 @PredicateLink(value = ReflectionThreadCheckPredicates.class, method = "checkThread")
021 public @interface OnlyThreadInField {
022 /**
023 * The class that contains the field specifying the thread that is allowed to run.
024 *
025 * @return class containing the field
026 */
027 Class fieldClass();
028
029 /**
030 * The name of the field specifying the thread that is allowed to run.
031 *
032 * @return name of the field
033 */
034 String fieldName();
035
036 //
037 // nested interfaces
038 //
039
040 /**
041 * An annotation used to designate methods that are only allowed to be run by the thread in the field specified
042 * by class name and field name.
043 *
044 * @author Mathias Ricken
045 */
046 @Retention(RetentionPolicy.RUNTIME)
047 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
048
049 @PredicateLink(value = ReflectionThreadCheckPredicates.class, method = "checkThreadByName")
050 public static @interface ByName {
051 /**
052 * The name of the class that contains the field specifying the thread that is allowed to run.
053 *
054 * @return class containing the field
055 */
056 String fieldClassName();
057
058 /**
059 * The name of the field specifying the thread that is allowed to run.
060 *
061 * @return name of the field
062 */
063 String fieldName();
064
065 //
066 // nested interfaces
067 //
068
069 /**
070 * Annotation used to designate methods that are only allowed to be run by one of the
071 * threads specified in the fields, i.e. the individual
072 * @OnlyThreadInField.ByName annotations are combined using OR.
073 */
074 @Retention(RetentionPolicy.RUNTIME)
075 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
076
077 @Combine(Combine.Mode.OR)
078 public static @interface Any {
079 OnlyThreadInField.ByName[] value();
080 }
081 }
082
083 /**
084 * Annotation used to designate methods that are only allowed to be run by one of the
085 * threads specified in the fields, i.e. the individual
086 * @OnlyThreadInField annotations are combined using OR.
087 */
088 @Retention(RetentionPolicy.RUNTIME)
089 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
090
091 @Combine(Combine.Mode.OR)
092 public static @interface Any {
093 OnlyThreadInField[] value();
094 }
095 }