edu.rice.cs.cunit.instrumentors.threadCheck
Class AAddThreadCheckStrategy

java.lang.Object
  extended by edu.rice.cs.cunit.instrumentors.threadCheck.AThreadCheckStrategy
      extended by edu.rice.cs.cunit.instrumentors.threadCheck.AAddThreadCheckStrategy
All Implemented Interfaces:
IInstrumentationStrategy
Direct Known Subclasses:
AddPredicateThreadCheckStrategy, AddReflectionThreadCheckStrategy, AddThreadCheckStrategy

public abstract class AAddThreadCheckStrategy
extends AThreadCheckStrategy

Abstract class for adding thread checks.

Author:
Mathias Ricken

Nested Class Summary
static class AAddThreadCheckStrategy.CacheInfo
          Cache hit/miss message.
static class AAddThreadCheckStrategy.OnlyAfterRealizedWarning
          ONLY_AFTER_REALIZED warning
static class AAddThreadCheckStrategy.SharedAddData
          Data shared among all AAddThreadCheckStrategy instances.
 
Nested classes/interfaces inherited from class edu.rice.cs.cunit.instrumentors.threadCheck.AThreadCheckStrategy
AThreadCheckStrategy.SharedData
 
Field Summary
(package private)  AAddThreadCheckStrategy.SharedAddData _sharedAddData
          Data shared among all AAddThreadCheckStrategy instances.
static java.lang.String XML_ANNOT_SAVE_MERGED_PREFIX
          Prefix for the parameter that determines the file name as which the merged XML configuration will be saved.
 
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
AAddThreadCheckStrategy(AThreadCheckStrategy.SharedData shared, AAddThreadCheckStrategy.SharedAddData sharedAdd)
          Constructor for this strategy.
AAddThreadCheckStrategy(java.util.List<java.lang.String> parameters, AThreadCheckStrategy.SharedData shared, AAddThreadCheckStrategy.SharedAddData sharedAdd)
          Constructor for a strategy that adds thread checks.
 
Method Summary
protected  void checkForSubtypingClassWarnings(ClassFile cf, MethodInfo mi, ClassFile scf, ThreadCheckAnnotationRecord classAR, ThreadCheckAnnotationRecord superClassAR)
          Check for subtyping warnings.
static java.util.Set<ThreadCheckException> checkXMLConcDef(XMLConfig xc)
          Checks if an XML concurrency definition is well-formed.
 void done()
          Instrumentation of all classes is done.
private  AAnnotationsAttributeInfo.Annotation extractAnnotation(org.w3c.dom.Node element, org.w3c.dom.Node annotType, boolean requireArrayDesc)
          Extract an annotation from the XML node specified.
protected  AAnnotationsAttributeInfo.Annotation.AMemberValue extractMemberValue(org.w3c.dom.Node childNode, boolean requireArrayDesc)
          Extract an annotation member value from the XML node specified.
 ThreadCheckAnnotationRecord extractXMLAnnotations(org.w3c.dom.Node elt)
          Extract annotations for the specified path from the XML file, if there is one.
 java.util.List<ThreadCheckDefinitionRecord> extractXMLConcDef(XMLConfig xc)
          Extract the concurrency definitions from the XML file.
 ThreadCheckDefinitionRecord extractXMLConcDef(XMLConfig xc, org.w3c.dom.Node def)
          Extracts the concurrency definition from an XML concurrency definitions configuration at the given node.
protected  ThreadCheckAnnotationRecord getClassAnnotations(ClassFile cf)
          Get the annotations for the specified class file.
protected  ThreadCheckAnnotationRecord getMethodAnnotations(ClassFile cf, MethodInfo mi)
          Get the annotations for the specified method in the specified class file.
protected  void insertCtorCall(ClassFile cf, MethodInfo mi, InstructionList il, java.lang.String className, java.lang.String ctorSig, AInstruction loadValue)
          Inserts a constructor call to the class specified for the value placed on the top of the stack.
 
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
 
Methods inherited from interface edu.rice.cs.cunit.instrumentors.IInstrumentationStrategy
instrument
 

Field Detail

XML_ANNOT_SAVE_MERGED_PREFIX

public static final java.lang.String XML_ANNOT_SAVE_MERGED_PREFIX
Prefix for the parameter that determines the file name as which the merged XML configuration will be saved. If this parameter is not specified, then the XML configuration is not saved.

See Also:
Constant Field Values

_sharedAddData

AAddThreadCheckStrategy.SharedAddData _sharedAddData
Data shared among all AAddThreadCheckStrategy instances.

Constructor Detail

AAddThreadCheckStrategy

public AAddThreadCheckStrategy(AThreadCheckStrategy.SharedData shared,
                               AAddThreadCheckStrategy.SharedAddData sharedAdd)
Constructor for this strategy.

Parameters:
shared - data shared among all AThreadCheckStrategy instances
sharedAdd - data for all AAddThreadCheckStrategy instances

AAddThreadCheckStrategy

public AAddThreadCheckStrategy(java.util.List<java.lang.String> parameters,
                               AThreadCheckStrategy.SharedData shared,
                               AAddThreadCheckStrategy.SharedAddData sharedAdd)
Constructor for a strategy that adds thread checks.

Parameters:
parameters - parameters for the instrumentors
shared - data shared among all AThreadCheckStrategy instances
sharedAdd - data for all AAddThreadCheckStrategy instances
Method Detail

getClassAnnotations

protected ThreadCheckAnnotationRecord getClassAnnotations(ClassFile cf)
Get the annotations for the specified class file.

Parameters:
cf - class file
Returns:
annotations

extractXMLConcDef

public java.util.List<ThreadCheckDefinitionRecord> extractXMLConcDef(XMLConfig xc)
Extract the concurrency definitions from the XML file. This works both for and .

Parameters:
xc - XML concurrency definitions configuration
Returns:
list of ThreadCheckDefinitionRecord

extractXMLAnnotations

public ThreadCheckAnnotationRecord extractXMLAnnotations(org.w3c.dom.Node elt)
Extract annotations for the specified path from the XML file, if there is one.

Parameters:
elt - element that contains the name/group/id/eventThread elements
Returns:
annotations record

extractAnnotation

private AAnnotationsAttributeInfo.Annotation extractAnnotation(org.w3c.dom.Node element,
                                                               org.w3c.dom.Node annotType,
                                                               boolean requireArrayDesc)
Extract an annotation from the XML node specified.

Parameters:
element - XML node
annotType - node for the annotation
requireArrayDesc -
Returns:
annotation extracted from XML

extractMemberValue

protected AAnnotationsAttributeInfo.Annotation.AMemberValue extractMemberValue(org.w3c.dom.Node childNode,
                                                                               boolean requireArrayDesc)
Extract an annotation member value from the XML node specified.

Parameters:
childNode - XML node
requireArrayDesc -
Returns:
extracted member value

getMethodAnnotations

protected ThreadCheckAnnotationRecord getMethodAnnotations(ClassFile cf,
                                                           MethodInfo mi)
Get the annotations for the specified method in the specified class file.

Parameters:
cf - class file
mi - method information
Returns:
annotations

checkForSubtypingClassWarnings

protected void checkForSubtypingClassWarnings(ClassFile cf,
                                              MethodInfo mi,
                                              ClassFile scf,
                                              ThreadCheckAnnotationRecord classAR,
                                              ThreadCheckAnnotationRecord superClassAR)
Check for subtyping warnings.

Parameters:
cf - class file
mi - method information, or null if on class level
scf - superclass/interface class file
classAR - subclass annotations
superClassAR - superclass annotations

extractXMLConcDef

public ThreadCheckDefinitionRecord extractXMLConcDef(XMLConfig xc,
                                                     org.w3c.dom.Node def)
Extracts the concurrency definition from an XML concurrency definitions configuration at the given node. This works only for .

Parameters:
xc - XML configuration
def - XML concurrency definition node
Returns:
ThreadCheckDefinitionRecord describing the invariant
Throws:
ThreadCheckException

checkXMLConcDef

public static java.util.Set<ThreadCheckException> checkXMLConcDef(XMLConfig xc)
Checks if an XML concurrency definition is well-formed.

Parameters:
xc - XML configuration
Returns:
a set of thrown ThreadCheckException

done

public void done()
Instrumentation of all classes is done.

Specified by:
done in interface IInstrumentationStrategy
Overrides:
done in class AThreadCheckStrategy

insertCtorCall

protected void insertCtorCall(ClassFile cf,
                              MethodInfo mi,
                              InstructionList il,
                              java.lang.String className,
                              java.lang.String ctorSig,
                              AInstruction loadValue)
Inserts a constructor call to the class specified for the value placed on the top of the stack.

Parameters:
cf - class file
mi - method info
il - instruction list
className - name of the class to construct
ctorSig - signature of the constructor
loadValue - instruction to load the value