|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.cunit.instrumentors.threadCheck.AThreadCheckStrategy
edu.rice.cs.cunit.instrumentors.threadCheck.AAddThreadCheckStrategy
edu.rice.cs.cunit.instrumentors.threadCheck.AddPredicateThreadCheckStrategy
public class AddPredicateThreadCheckStrategy
Instrumentor to add calls to ThreadCheck.checkCurrentThreadName/Id/Group to check if the current thread is not allowed to execute a class or method.
This instrumentor checks for every method if there are @NotRunBy or @OnlyRunBy annotations attached to the method, the containing class, the same method in one of the superclasses or interfaces, or a superclass or interface, and then at the beginning of the method inserts calls to ThreadCheck..
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AAddThreadCheckStrategy |
|---|
AAddThreadCheckStrategy.CacheInfo, AAddThreadCheckStrategy.OnlyAfterRealizedWarning, AAddThreadCheckStrategy.SharedAddData |
| Nested classes/interfaces inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AThreadCheckStrategy |
|---|
AThreadCheckStrategy.SharedData |
| Field Summary | |
|---|---|
protected java.io.File |
_classOutputDir
The output directory for the generated class files, corresponding to the default package. |
protected SoftHashMap<java.lang.String,PredicateAnnotationRecord> |
_generatedPredicateRecords
Hash table from a fully-qualified class name of the @Combine-type annotation to the generated predicate annotation record. |
protected java.lang.String |
_predicatePackage
The package for the generated class files, or null if none set (that is ok unless we have to auto-generate class files). |
protected java.io.File |
_predicatePackageDir
The directory where the generated class files go, corresponding to the package in _predicatePackage, or null if none set (that is ok unless we have to auto-generate class files). |
protected ClassFile |
_templatePredicateClassFile
The predicate class file which is cloned for the auto-generated predicates. |
static java.lang.String |
PRED_OUT_DIR_PARAM_PREFIX
Prefix for the parameter that determines the output directory of the generated class files. |
static java.lang.String |
PRED_OUT_PACKAGE_PARAM_PREFIX
Prefix for the parameter that determines the package of the generated class files. |
| Fields inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AAddThreadCheckStrategy |
|---|
_sharedAddData, XML_ANNOT_SAVE_MERGED_PREFIX |
| Fields inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AThreadCheckStrategy |
|---|
_sharedData, CLASS_PATH_PARAM_PREFIX, CLASS_SIG_SEPARATOR_STRING, DEFAULT_XML_CONC_DEF_PATH_PREFIX, DEFAULT_XML_PATH_PREFIX, UPDATE_PARAM_ORDER_PREFIX, XML_ANNOT_FORMAT_PARAM, XML_ANNOT_PARAM_PREFIX |
| Constructor Summary | |
|---|---|
AddPredicateThreadCheckStrategy(AThreadCheckStrategy.SharedData shared,
AAddThreadCheckStrategy.SharedAddData sharedAdd)
Constructor for this strategy. |
|
AddPredicateThreadCheckStrategy(java.util.List<java.lang.String> parameters,
AThreadCheckStrategy.SharedData shared,
AAddThreadCheckStrategy.SharedAddData sharedAdd)
Constructor for this strategy. |
|
| Method Summary | |
|---|---|
protected PredicateAnnotationRecord |
generatePredicateAnnotationRecord(PredicateAnnotationRecord par,
java.lang.String miDescriptor)
Generate the predicate annotation record for the @Combine-type annotation that contains all information except for the valueList. |
protected PredicateAnnotationRecord |
getGeneratedPredicate(ClassFile cf,
PredicateAnnotationRecord par,
java.lang.String miDescriptor)
Return a generated predicate annotation record for a @Combine-type annotation. |
protected java.lang.String |
getMethodName(PredicateAnnotationRecord par)
Return the name of the predicate method for a @Combine-type annotation, taking annotation array sizes into account. |
protected void |
getMethodNameHelper(PredicateAnnotationRecord par,
java.lang.StringBuilder sb,
java.lang.String suffix)
Return part of the method name. |
protected int |
insertPredicateCall(ClassFile cf,
MethodInfo mi,
InstructionList il,
PredicateAnnotationRecord par)
Insert a call to the predicate sp |
void |
instrument(ClassFile cf)
Instrument the class. |
private int |
loadAndTransferMemberValue(AAnnotationsAttributeInfo.Annotation.AMemberValue value,
java.lang.String paramType,
ClassFile cf,
MethodInfo mi,
InstructionList il)
Transfer the annotation member value to the class file. |
private void |
loadArguments(ClassFile cf,
MethodInfo mi,
InstructionList il)
|
protected void |
performCombineTreeWalk(PredicateAnnotationRecord par,
ILambda.Ternary<java.lang.Object,java.lang.String,java.lang.String,AAnnotationsAttributeInfo.Annotation.AMemberValue> lambda,
java.lang.String suffix)
Walk the tree of combined predicates and apply the lambda for each parameter name-parameter type-value triple. |
protected void |
transferAnnotation(AAnnotationsAttributeInfo.Annotation a,
ClassFile cf,
MethodInfo mi)
Transfer the annotation to the class file. |
| Methods inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AAddThreadCheckStrategy |
|---|
checkForSubtypingClassWarnings, checkXMLConcDef, done, extractMemberValue, extractXMLAnnotations, extractXMLConcDef, extractXMLConcDef, getClassAnnotations, getMethodAnnotations, insertCtorCall |
| Methods inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AThreadCheckStrategy |
|---|
checkCombineMembers, checkPredicateMembers, checkPublicStaticIfNestedClass, extractAnnotationArray, extractLists, extractLongArray, extractPredicateSet, extractStringArray, getAnnotationClassFile, getCombineMode, getPredicateAnnotationRecord, getPredicateLink, includePredicateMethodParameterOrder, processAnnotation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected SoftHashMap<java.lang.String,PredicateAnnotationRecord> _generatedPredicateRecords
protected ClassFile _templatePredicateClassFile
public static final java.lang.String PRED_OUT_DIR_PARAM_PREFIX
protected java.io.File _classOutputDir
protected java.io.File _predicatePackageDir
public static final java.lang.String PRED_OUT_PACKAGE_PARAM_PREFIX
protected java.lang.String _predicatePackage
| Constructor Detail |
|---|
public AddPredicateThreadCheckStrategy(AThreadCheckStrategy.SharedData shared,
AAddThreadCheckStrategy.SharedAddData sharedAdd)
shared - data shared among all AThreadCheckStrategy instancessharedAdd - data for all AAddThreadCheckStrategy instances
public AddPredicateThreadCheckStrategy(java.util.List<java.lang.String> parameters,
AThreadCheckStrategy.SharedData shared,
AAddThreadCheckStrategy.SharedAddData sharedAdd)
parameters - parameters for the instrumentorsshared - data shared among all AThreadCheckStrategy instancessharedAdd - data for all AAddThreadCheckStrategy instances| Method Detail |
|---|
public void instrument(ClassFile cf)
cf - class file info
protected int insertPredicateCall(ClassFile cf,
MethodInfo mi,
InstructionList il,
PredicateAnnotationRecord par)
cf - current class filemi - current method informationil - instruction listpar - predicate annotation record describing the check to add
private void loadArguments(ClassFile cf,
MethodInfo mi,
InstructionList il)
private int loadAndTransferMemberValue(AAnnotationsAttributeInfo.Annotation.AMemberValue value,
java.lang.String paramType,
ClassFile cf,
MethodInfo mi,
InstructionList il)
value - annotation pair valueparamType - parameter type, or null if that information is not availablecf - target class filemi - method infoil - instruction list, or null if this is a member value to be loaded
protected void transferAnnotation(AAnnotationsAttributeInfo.Annotation a,
ClassFile cf,
MethodInfo mi)
a - annotationcf - target class filemi - method info
protected PredicateAnnotationRecord getGeneratedPredicate(ClassFile cf,
PredicateAnnotationRecord par,
java.lang.String miDescriptor)
cf - current class filepar - predicate annotation record describing the @Combine-type annotationmiDescriptor - method destrictor
protected PredicateAnnotationRecord generatePredicateAnnotationRecord(PredicateAnnotationRecord par,
java.lang.String miDescriptor)
par - predicate annotation record describing the @Combine-type annotationmiDescriptor - method destrictor
protected void performCombineTreeWalk(PredicateAnnotationRecord par,
ILambda.Ternary<java.lang.Object,java.lang.String,java.lang.String,AAnnotationsAttributeInfo.Annotation.AMemberValue> lambda,
java.lang.String suffix)
par - record describing the combined predicate annotationlambda - lambda to apply to each parameter name-parameter type-value triple; return value is ignoredsuffix - string suffix for variable names to distinguish themprotected java.lang.String getMethodName(PredicateAnnotationRecord par)
par - record describing the combined predicate annotation
protected void getMethodNameHelper(PredicateAnnotationRecord par,
java.lang.StringBuilder sb,
java.lang.String suffix)
par - record describing the combined predicate annotationsb - string builder accumulating the nethod namesuffix - string suffix for variable names to distinguish them
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||