public class ResourceLeakAnnotatedTypeFactory extends CalledMethodsAnnotatedTypeFactory implements CreatesMustCallForElementSupplier
postAnalyze(ControlFlowGraph)
method checks that must-call obligations are fulfilled.AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy, AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.ParameterizedExecutableType
accumulationChecker, bottom, top
analysis, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotator
ajavaTypes, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState, wpiOutputFormat
Constructor and Description |
---|
ResourceLeakAnnotatedTypeFactory(BaseTypeChecker checker)
Creates a new ResourceLeakAnnotatedTypeFactory.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canCreateObligations()
Does this type factory support
CreatesMustCallFor ? |
AnnotationMirror |
createCalledMethods(String... val)
Creates a @CalledMethods annotation whose values are the given strings.
|
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.
|
ExecutableElement |
getCreatesMustCallForListValueElement()
Returns the
CreatesMustCallFor.List.value()
element. |
ExecutableElement |
getCreatesMustCallForValueElement()
Returns the
CreatesMustCallFor.value() element. |
@Nullable List<String> |
getMustCallValue(Set<org.checkerframework.checker.resourceleak.MustCallConsistencyAnalyzer.ResourceAlias> resourceAliasSet,
@Nullable CFStore mcStore)
Use the must-call store to get the must-call value of the resource represented by the given
resource aliases.
|
<T extends GenericAnnotatedTypeFactory<?,?,?,?>> |
getTypeFactoryOfSubchecker(Class<? extends BaseTypeChecker> subCheckerClass)
Returns the type factory used by a subchecker.
|
boolean |
hasCreatesMustCallFor(MethodInvocationNode node)
Returns true if the declaration of the method being invoked has one or more
CreatesMustCallFor annotations. |
void |
postAnalyze(ControlFlowGraph cfg)
Perform any additional operations on a CFG.
|
adjustMethodNameUsingValueChecker, createRequiresOrEnsuresQualifier, createTreeAnnotator, createTypeAnnotator, getDummyAssignedTo, returnsThis
convertToPredicate, createAccumulatorAnnotation, createAccumulatorAnnotation, createPredicateAnnotation, createQualifierHierarchy, evaluatePredicate, evaluatePredicate, getAccumulatedValues, isAccumulatorAnnotation, isPredicate, isPredicateSubtype
createFlowAnalysis
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, handleCFGViz, isRelevant, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchyWithMultiGraphFactory, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, 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, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, postTypeVarSubstitution, prepareMethodForWriting, prepareMethodForWriting, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCreatesMustCallForExpression, getCreatesMustCallForExpressions, issueUnparseableError
public ResourceLeakAnnotatedTypeFactory(BaseTypeChecker checker)
checker
- the checker associated with this type factoryprotected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactory
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 of ElementType.TYPE_PARAMETER
, but no other ElementType
values) are automatically considered as supported annotations.
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:
This is the default behavior. Simply place those annotations within the qual directory.
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers()
by calling AnnotatedTypeFactory.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);
}
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.getBundledTypeQualifiers(Class...)
must return a
fresh, mutable set
createSupportedTypeQualifiers
in class AnnotatedTypeFactory
public AnnotationMirror createCalledMethods(String... val)
val
- the methods that have been calledpublic void postAnalyze(ControlFlowGraph cfg)
GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.analyze(Queue, Queue, UnderlyingAST, List, ClassTree, boolean, boolean,
boolean, CFAbstractStore)
. This method can be used to initialize additional state or to
perform any analyses that are easier to perform on the CFG instead of the AST.postAnalyze
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
cfg
- the CFGGenericAnnotatedTypeFactory.analyze(java.util.Queue, java.util.Queue,
org.checkerframework.dataflow.cfg.UnderlyingAST, java.util.List,
com.sun.source.tree.ClassTree, boolean, boolean, boolean,
org.checkerframework.framework.flow.CFAbstractStore)
public @Nullable List<String> getMustCallValue(Set<org.checkerframework.checker.resourceleak.MustCallConsistencyAnalyzer.ResourceAlias> resourceAliasSet, @Nullable CFStore mcStore)
resourceAliasSet
- a set of resource aliases of the same resourcemcStore
- a CFStore produced by the MustCall checker's dataflow analysis. If this is null,
then the default MustCall type of each variable's class will be used.public boolean hasCreatesMustCallFor(MethodInvocationNode node)
CreatesMustCallFor
annotations.node
- a method invocation nodepublic boolean canCreateObligations()
CreatesMustCallFor
?public <T extends GenericAnnotatedTypeFactory<?,?,?,?>> T getTypeFactoryOfSubchecker(Class<? extends BaseTypeChecker> subCheckerClass)
GenericAnnotatedTypeFactory
Because the visitor state is copied, call this method each time a subfactory is needed rather than store the returned subfactory in a field.
getTypeFactoryOfSubchecker
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
T
- the type of subCheckerClass
's AnnotatedTypeFactory
subCheckerClass
- the exact class of the subcheckerpublic ExecutableElement getCreatesMustCallForValueElement()
CreatesMustCallFor.value()
element.getCreatesMustCallForValueElement
in interface CreatesMustCallForElementSupplier
CreatesMustCallFor.value()
elementpublic ExecutableElement getCreatesMustCallForListValueElement()
CreatesMustCallFor.List.value()
element.getCreatesMustCallForListValueElement
in interface CreatesMustCallForElementSupplier
CreatesMustCallFor.List.value()
element