public class LockAnnotatedTypeFactory extends GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>
However, there are a number of other annotations used in conjunction with these annotations to enforce proper locking.
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.InheritedFromClassAnnotator, AnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
protected AnnotationMirror |
GUARDEDBY
The @
GuardedByBottom annotation. |
protected AnnotationMirror |
GUARDEDBYBOTTOM
The @
GuardedByBottom annotation. |
protected AnnotationMirror |
GUARDEDBYUNKNOWN
The @
GuardedByUnknown annotation. |
protected AnnotationMirror |
GUARDSATISFIED
The @
GuardSatisfied annotation. |
protected Class<? extends Annotation> |
javaxGuardedBy
The javax.annotation.concurrent.GuardedBy annotation, or null if not on the classpath.
|
protected Class<? extends Annotation> |
jcipGuardedBy
The net.jcip.annotations.GuardedBy annotation, or null if not on the classpath.
|
protected AnnotationMirror |
LOCKHELD
The @
LockHeld annotation. |
protected AnnotationMirror |
LOCKPOSSIBLYHELD
The @
LockPossiblyHeld annotation. |
static String |
NOT_EFFECTIVELY_FINAL
dependent type annotation error message for when the expression is not effectively final.
|
protected AnnotationMirror |
SIDEEFFECTFREE
The @
SideEffectFree annotation. |
analysis, cfgVisualizer, defaults, dependentTypesHelper, emptyStore, flowByDefault, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, transfer, treeAnnotator, typeAnnotatorchecker, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, objectGetClass, processingEnv, qualHierarchy, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState| Constructor and Description |
|---|
LockAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new LockAnnotatedTypeFactory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComputedTypeAnnotations(Element elt,
AnnotatedTypeMirror type)
Changes annotations on a type obtained from an
Element. |
void |
addComputedTypeAnnotations(Tree tree,
AnnotatedTypeMirror type,
boolean useFlow)
Like {#addComputedTypeAnnotations(Tree, AnnotatedTypeMirror)}.
|
protected DependentTypesHelper |
createDependentTypesHelper()
Creates an
DependentTypesHelper and returns it. |
protected LockAnalysis |
createFlowAnalysis(List<Pair<VariableElement,CFValue>> fieldValues)
Returns the appropriate flow analysis class that is used for the
org.checkerframework.dataflow analysis.
|
LockTransfer |
createFlowTransferFunction(CFAbstractAnalysis<CFValue,LockStore,LockTransfer> analysis)
Returns the appropriate transfer function that is used for the org.checkerframework.dataflow
analysis.
|
QualifierHierarchy |
createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
Factory method to easily change what QualifierHierarchy is created.
|
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.
|
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
AnnotatedTypeFactory.ParameterizedExecutableType |
methodFromUse(ExpressionTree tree,
ExecutableElement methodElt,
AnnotatedTypeMirror receiverType)
Determines the type of the invoked method based on the passed expression tree, executable
element, and receiver type.
|
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addDefaultAnnotations, addTypeNameImplicit, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getAnnotationMirrorFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, canonicalAnnotation, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getCacheSize, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingElementForArtificialTree, getEnclosingType, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initializeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, parseStubFiles, postAsMemberOf, postProcessClassTree, postTypeVarSubstitution, setEnclosingElementForArtificialTree, toAnnotatedType, toString, type, widenToUpperBoundpublic static final String NOT_EFFECTIVELY_FINAL
protected final AnnotationMirror LOCKHELD
LockHeld annotation.protected final AnnotationMirror LOCKPOSSIBLYHELD
LockPossiblyHeld annotation.protected final AnnotationMirror SIDEEFFECTFREE
SideEffectFree annotation.protected final AnnotationMirror GUARDEDBYUNKNOWN
GuardedByUnknown annotation.protected final AnnotationMirror GUARDEDBY
GuardedByBottom annotation.protected final AnnotationMirror GUARDEDBYBOTTOM
GuardedByBottom annotation.protected final AnnotationMirror GUARDSATISFIED
GuardSatisfied annotation.protected final Class<? extends Annotation> jcipGuardedBy
protected final Class<? extends Annotation> javaxGuardedBy
public LockAnnotatedTypeFactory(BaseTypeChecker checker)
protected DependentTypesHelper createDependentTypesHelper()
GenericAnnotatedTypeFactoryDependentTypesHelper and returns it.createDependentTypesHelper in class GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>DependentTypesHelperprotected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactorySubclasses may override this method to return a mutable set of their supported type qualifiers through one of the 5 approaches shown below.
Subclasses should not call this method; they should call AnnotatedTypeFactory.getSupportedTypeQualifiers() instead.
By default, a checker supports PolyAll, and all annotations located in a
subdirectory called qual that's located in the same directory as the checker. Note
that only annotations defined with the @Target({ElementType.TYPE_USE})
meta-annotation (and optionally with the additional value of ElementType.TYPE_PARAMETER, but no other ElementType values) are automatically
considered as supported annotations.
To not support PolyAll, see examples below.
To support a different set of annotations than those in the qual subdirectory,
or that have other ElementType values, see examples below.
In total, there are 5 ways to indicate annotations that are supported by a checker:
PolyAll:
This is the default behavior. Simply place those annotations within the qual directory.
PolyAll:
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) with no parameters passed in. Code
example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll();
}
PolyAll,
and a list of other annotations:
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) with a varargs parameter list of the
other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithPolyAll(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class);
}
PolyAll:
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiersWithoutPolyAll(Class...) with a varargs parameter list of the
other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll(UnknownFormat.class, FormatBottom.class);
}
AnnotatedTypeFactory.createSupportedTypeQualifiers() and return a mutable set of the supported
annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return new HashSet<Class<? extends Annotation>>(
Arrays.asList(A.class, B.class));
}
The set of qualifiers returned by AnnotatedTypeFactory.createSupportedTypeQualifiers() must be a
fresh, mutable set. The methods AnnotatedTypeFactory.getBundledTypeQualifiersWithoutPolyAll(Class...) and AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) each must return a fresh, mutable set
createSupportedTypeQualifiers in class AnnotatedTypeFactorypublic QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactorycreateQualifierHierarchy in class AnnotatedTypeFactoryprotected LockAnalysis createFlowAnalysis(List<Pair<VariableElement,CFValue>> fieldValues)
GenericAnnotatedTypeFactoryThis implementation uses the checker naming convention to create the appropriate analysis.
If no transfer function is found, it returns an instance of CFAnalysis.
Subclasses have to override this method to create the appropriate analysis if they do not follow the checker naming convention.
createFlowAnalysis in class GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>public LockTransfer createFlowTransferFunction(CFAbstractAnalysis<CFValue,LockStore,LockTransfer> analysis)
GenericAnnotatedTypeFactoryThis implementation uses the checker naming convention to create the appropriate transfer
function. If no transfer function is found, it returns an instance of CFTransfer.
Subclasses have to override this method to create the appropriate transfer function if they do not follow the checker naming convention.
createFlowTransferFunction in class GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>public AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(ExpressionTree tree, ExecutableElement methodElt, AnnotatedTypeMirror receiverType)
AnnotatedTypeFactorymethodFromUse in class AnnotatedTypeFactorytree - either a MethodInvocationTree or a MemberReferenceTreemethodElt - the element of the referenced methodreceiverType - the type of the receiverAnnotatedTypeFactory.methodFromUse(MethodInvocationTree)protected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactoryTreeAnnotator that adds annotations to a type based on the contents of a
tree.
The default tree annotator is a ListTreeAnnotator of the following:
PropagationTreeAnnotator: Propagates annotations from subtrees
ImplicitsTreeAnnotator: Adds annotations based on ImplicitFor
meta-annotations
DependentTypesTreeAnnotator: Adapts dependent annotations based on context
Subclasses may override this method to specify additional tree annotators, for example:
new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
createTreeAnnotator in class GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>public void addComputedTypeAnnotations(Element elt, AnnotatedTypeMirror type)
AnnotatedTypeFactoryElement. By default, this method does
nothing. GenericAnnotatedTypeFactory uses this method to implement defaulting.
Subclasses that override this method should also override AnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror).
addComputedTypeAnnotations in class GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>elt - an elementtype - the type obtained from eltpublic void addComputedTypeAnnotations(Tree tree, AnnotatedTypeMirror type, boolean useFlow)
GenericAnnotatedTypeFactoryaddComputedTypeAnnotations in class GenericAnnotatedTypeFactory<CFValue,LockStore,LockTransfer,LockAnalysis>