Class LockAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
However, there are a number of other annotations used in conjunction with these annotations to enforce proper locking.
- See the Checker Framework Manual:
- Lock Checker
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanStateNested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.CapturedTypeVarSubstitutor, AnnotatedTypeFactory.ParameterizedExecutableType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutableElementThe EnsuresLockHeldIf.expression element/field.protected final ExecutableElementThe EnsuresLockHeld.value element/field.protected final AnnotationMirrorThe @GuardedByannotation.protected final AnnotationMirrorThe @GuardedByBottomannotation.protected final AnnotationMirrorThe @GuardedByUnknownannotation.protected final ExecutableElementThe value() element/field of a @GuardedBy annotation.protected final AnnotationMirrorThe @GuardSatisfiedannotation.protected final ExecutableElementThe value() element/field of a @GuardSatisfied annotation.protected final @Nullable Class<? extends Annotation> The javax.annotation.concurrent.GuardedBy annotation, or null if not on the classpath.protected final @Nullable Class<? extends Annotation> The net.jcip.annotations.GuardedBy annotation, or null if not on the classpath.protected final AnnotationMirrorThe @LockHeldannotation.protected final AnnotationMirrorThe @LockPossiblyHeldannotation.protected final AnnotationMirrorThe @NewObjectannotation.static final Stringdependent type annotation error message for when the expression is not effectively final.protected final AnnotationMirrorThe @SideEffectFreeannotation.Fields inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
analysis, arraysAreRelevant, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorFields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, artificialTreeToEnclosingElementMap, capturedTypeVarSubstitutor, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreRawTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, typeInformationPresenter, types, typeVarSubstitutor, uid, wpiOutputFormat -
Constructor Summary
ConstructorsConstructorDescriptionLockAnnotatedTypeFactory(BaseTypeChecker checker) Create a new LockAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComputedTypeAnnotations(Tree tree, AnnotatedTypeMirror type, boolean useFlow) voidaddComputedTypeAnnotations(Element elt, AnnotatedTypeMirror type) To add annotations to the type of method or constructor parameters, add aTypeAnnotatorusingGenericAnnotatedTypeFactory.createTypeAnnotator()and see the comment inTypeAnnotator.visitExecutable(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType, Void).protected DependentTypesHelperCreates aDependentTypesHelperand returns it.protected LockAnalysisReturns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.Returns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.protected QualifierHierarchyReturns theQualifierHierarchyto be used by this checker.protected Set<Class<? extends Annotation>> Returns a mutable set of annotation classes that are supported by a checker.protected TreeAnnotatorReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.booleanisSideEffectFree(ExecutableElement method) Returns true if the given method is side-effect-free according to this AnnotationProvider — that is, if a call to the given method does not undo flow-sensitive type refinement.methodFromUse(ExpressionTree tree, ExecutableElement methodElt, AnnotatedTypeMirror receiverType, boolean inferTypeArgs) Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotationsForWarnRedundant, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, createTypeAnnotator, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultAnnotationsForWarnRedundant, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
adaptGetClassReturnTypeToReceiver, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeInformationPresenter, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getResultingTypeOfConstructorMemberReference, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getVisitorTreePath, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isDeterministic, isFromByteCode, isFromStubFile, isImmutable, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isTop, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField, wpiPrepareMethodForWriting, wpiPrepareMethodForWriting, wpiShouldInferTypesForReceivers
-
Field Details
-
NOT_EFFECTIVELY_FINAL
dependent type annotation error message for when the expression is not effectively final.- See Also:
-
LOCKHELD
The @LockHeldannotation. -
LOCKPOSSIBLYHELD
The @LockPossiblyHeldannotation. -
SIDEEFFECTFREE
The @SideEffectFreeannotation. -
GUARDEDBYUNKNOWN
The @GuardedByUnknownannotation. -
GUARDEDBY
The @GuardedByannotation. -
NEWOBJECT
The @NewObjectannotation. -
GUARDEDBYBOTTOM
The @GuardedByBottomannotation. -
GUARDSATISFIED
The @GuardSatisfiedannotation. -
guardedByValueElement
The value() element/field of a @GuardedBy annotation. -
guardSatisfiedValueElement
The value() element/field of a @GuardSatisfied annotation. -
ensuresLockHeldValueElement
The EnsuresLockHeld.value element/field. -
ensuresLockHeldIfExpressionElement
The EnsuresLockHeldIf.expression element/field. -
jcipGuardedBy
The net.jcip.annotations.GuardedBy annotation, or null if not on the classpath. -
javaxGuardedBy
The javax.annotation.concurrent.GuardedBy annotation, or null if not on the classpath.
-
-
Constructor Details
-
LockAnnotatedTypeFactory
Create a new LockAnnotatedTypeFactory.
-
-
Method Details
-
createDependentTypesHelper
Description copied from class:GenericAnnotatedTypeFactoryCreates aDependentTypesHelperand returns it. UseGenericAnnotatedTypeFactory.getDependentTypesHelper()to access the value.- Overrides:
createDependentTypesHelperin classGenericAnnotatedTypeFactory<CFValue,LockStore, LockTransfer, LockAnalysis> - Returns:
- a new
DependentTypesHelper
-
createSupportedTypeQualifiers
Description copied from class:AnnotatedTypeFactoryReturns a mutable set of annotation classes that are supported by a checker.Subclasses 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 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 ofElementType.TYPE_PARAMETER, but no otherElementTypevalues) are automatically considered as supported annotations.To support a different set of annotations than those in the qual subdirectory, or that have other
ElementTypevalues, see examples below.In total, there are 5 ways to indicate annotations that are supported by a checker:
- Only support annotations located in a checker's qual directory:
This is the default behavior. Simply place those annotations within the qual directory.
- Support annotations located in a checker's qual directory and a list of other
annotations:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()by callingAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)with a varargs parameter list of the other annotations. Code example:@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return getBundledTypeQualifiers(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class); } - Supporting only annotations that are explicitly listed: Override
AnnotatedTypeFactory.createSupportedTypeQualifiers()and return a mutable set of the supported annotations. Code example:
The set of qualifiers returned by@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return new HashSet<Class<? extends Annotation>>( Arrays.asList(A.class, B.class)); }AnnotatedTypeFactory.createSupportedTypeQualifiers()must be a fresh, mutable set. The methodsAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)must return a fresh, mutable set
- Overrides:
createSupportedTypeQualifiersin classAnnotatedTypeFactory- Returns:
- the type qualifiers supported this processor, or an empty set if none
- Only support annotations located in a checker's qual directory:
-
createQualifierHierarchy
Description copied from class:AnnotatedTypeFactoryReturns theQualifierHierarchyto be used by this checker.The implementation builds the type qualifier hierarchy for the
AnnotatedTypeFactory.getSupportedTypeQualifiers()using the meta-annotations found in them. The current implementation returns an instance ofNoElementQualifierHierarchy.Subclasses must override this method if their qualifiers have elements; the method must return an implementation of
QualifierHierarchy, such asElementQualifierHierarchy.- Overrides:
createQualifierHierarchyin classAnnotatedTypeFactory- Returns:
- a QualifierHierarchy for this type system
-
createFlowAnalysis
Description copied from class:GenericAnnotatedTypeFactoryReturns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.This 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.
- Overrides:
createFlowAnalysisin classGenericAnnotatedTypeFactory<CFValue,LockStore, LockTransfer, LockAnalysis> - Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
createFlowTransferFunction
public LockTransfer createFlowTransferFunction(CFAbstractAnalysis<CFValue, LockStore, LockTransfer> analysis) Description copied from class:GenericAnnotatedTypeFactoryReturns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.This 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.
- Overrides:
createFlowTransferFunctionin classGenericAnnotatedTypeFactory<CFValue,LockStore, LockTransfer, LockAnalysis> - Parameters:
analysis- a dataflow analysis- Returns:
- a new transfer function
-
methodFromUse
public AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(ExpressionTree tree, ExecutableElement methodElt, AnnotatedTypeMirror receiverType, boolean inferTypeArgs) Description copied from class:AnnotatedTypeFactoryThe implementation ofAnnotatedTypeFactory.methodFromUse(ExpressionTree, ExecutableElement, AnnotatedTypeMirror)andAnnotatedTypeFactory.methodFromUseWithoutTypeArgInference(ExpressionTree, ExecutableElement, AnnotatedTypeMirror).- Overrides:
methodFromUsein classAnnotatedTypeFactory- Parameters:
tree- either a MethodInvocationTree or a MemberReferenceTreemethodElt- the element of the referenced methodreceiverType- the type of the receiverinferTypeArgs- whether type arguments should be inferred- Returns:
- the type of the invoked method
-
createTreeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.The default tree annotator is a
ListTreeAnnotatorof the following:PropagationTreeAnnotator: Propagates annotations from subtreesLiteralTreeAnnotator: Adds annotations based onQualifierForLiteralsmeta-annotationsDependentTypesTreeAnnotator: 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));
- Overrides:
createTreeAnnotatorin classGenericAnnotatedTypeFactory<CFValue,LockStore, LockTransfer, LockAnalysis> - Returns:
- a tree annotator
-
addComputedTypeAnnotations
Description copied from class:GenericAnnotatedTypeFactoryTo add annotations to the type of method or constructor parameters, add aTypeAnnotatorusingGenericAnnotatedTypeFactory.createTypeAnnotator()and see the comment inTypeAnnotator.visitExecutable(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType, Void).- Overrides:
addComputedTypeAnnotationsin classGenericAnnotatedTypeFactory<CFValue,LockStore, LockTransfer, LockAnalysis> - Parameters:
elt- an elementtype- the type obtained fromelt
-
addComputedTypeAnnotations
Description copied from class:GenericAnnotatedTypeFactoryLikeGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror). Overriding implementations typically simply pass the boolean to calls to super.- Overrides:
addComputedTypeAnnotationsin classGenericAnnotatedTypeFactory<CFValue,LockStore, LockTransfer, LockAnalysis> - Parameters:
tree- an AST nodetype- the type obtained from treeuseFlow- whether to use information from dataflow analysis
-
isSideEffectFree
Description copied from interface:AnnotationProviderReturns true if the given method is side-effect-free according to this AnnotationProvider — that is, if a call to the given method does not undo flow-sensitive type refinement.Note that this method takes account of this AnnotationProvider's semantics, whereas
org.checkerframework.dataflow.util.PurityUtils#isSideEffectFreedoes not.- Specified by:
isSideEffectFreein interfaceAnnotationProvider- Overrides:
isSideEffectFreein classAnnotatedTypeFactory- Parameters:
method- a method- Returns:
- true if a call to the method does not undo flow-sensitive type refinement
-