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 when the
013 * monitor of the method argument indexed by value is owned.
014 * @author Mathias Ricken
015 */
016 @Retention(RetentionPolicy.RUNTIME)
017 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
018
019 @PredicateLink(value = ThreadCheckPredicates.class, method = "checkMonitorOwnedArgument", arguments = true)
020 public @interface OnlySynchronizedArgument {
021 int value();
022
023 //
024 // nested interfaces
025 //
026
027 /**
028 * Annotation used to designate methods that are only allowed to be run if they own
029 * one or more of the monitors specified in the method arguments, i.e. the individual
030 * @OnlySynchronizedArgument annotations are combined using OR.
031 */
032 @Retention(RetentionPolicy.RUNTIME)
033 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
034
035 @Combine(Combine.Mode.OR)
036 public static @interface Any {
037 OnlySynchronizedArgument[] value();
038 }
039
040 /**
041 * Annotation used to designate methods that are only allowed to be run if they own
042 * all of the monitors specified in the method arguments, i.e. the individual
043 * @OnlySynchronizedArgument annotations are combined using ALL.
044 */
045 @Retention(RetentionPolicy.RUNTIME)
046 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
047
048 @Combine(Combine.Mode.AND)
049 public static @interface All {
050 OnlySynchronizedArgument[] value();
051 }
052 }