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 not allowed to run if the monitor of the field specified by 013 * class and field name is owned by any thread. 014 * 015 * @author Mathias Ricken 016 */ 017 @Retention(RetentionPolicy.RUNTIME) 018 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE}) 019 020 @PredicateLink(value = NotReflectionThreadCheckPredicates.class, method = "checkSynchronizedFieldByAnyThread") 021 public @interface NoneSynchronizedField { 022 /** 023 * The class that contains the field whose monitor may not be owned by any thread. 024 * 025 * @return class containing the field 026 */ 027 Class fieldClass(); 028 029 /** 030 * The name of the field whose monitor may not be owned by any thread. 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 not allowed to run if the monitor of the field specified by 042 * class name and field name is owned by any thread. 043 */ 044 @Retention(RetentionPolicy.RUNTIME) 045 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE}) 046 047 @PredicateLink(value = NotReflectionThreadCheckPredicates.class, method = "checkSynchronizedFieldByAnyThreadByName") 048 public static @interface ByName { 049 /** 050 * The name of the class that contains the field whose monitor may not be owned by any thread. 051 * 052 * @return class containing the field 053 */ 054 String fieldClassName(); 055 056 /** 057 * The name of the field whose monitor may not be owned by any thread. 058 * 059 * @return name of the field 060 */ 061 String fieldName(); 062 063 // 064 // nested interfaces 065 // 066 067 /** 068 * An annotation used to designate methods that are only allowed to be run when none of the 069 * monitors of the fields specified are owned by any thread, i.e. the individual 070 * @NoneSynchronizedField.ByName annotations are combined using AND. 071 */ 072 @Retention(RetentionPolicy.RUNTIME) 073 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE}) 074 075 @Combine(Combine.Mode.AND) 076 public static @interface None { 077 NoneSynchronizedField.ByName[] value(); 078 } 079 } 080 081 /** 082 * An annotation used to designate methods that are only allowed to be run when none of the 083 * monitors of the fields specified are owned by any thread, i.e. the individual 084 * @NoneSynchronizedField annotations are combined using AND. 085 */ 086 @Retention(RetentionPolicy.RUNTIME) 087 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE}) 088 089 @Combine(Combine.Mode.AND) 090 public static @interface None { 091 NoneSynchronizedField[] value(); 092 } 093 }