public class ResourceLeakAnnotatedTypeFactory extends CalledMethodsAnnotatedTypeFactory implements CreatesMustCallForElementSupplier
postAnalyze(ControlFlowGraph) method checks that must-call obligations are fulfilled.AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy, AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotatorGenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableTypeaccumulationChecker, bottom, topanalysis, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorajavaTypes, 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 ResourceLeakAnalysis |
createFlowAnalysis()
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow
analysis.
|
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. |
<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, returnsThisconvertToPredicate, createAccumulatorAnnotation, createAccumulatorAnnotation, createPredicateAnnotation, createQualifierHierarchy, evaluatePredicate, evaluatePredicate, getAccumulatedValues, isAccumulatorAnnotation, isPredicate, isPredicateSubtypeaddAnnotationsFromDefaultForType, 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, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, 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, wpiAdjustForUpdateNonFieldclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCreatesMustCallForExpression, getCreatesMustCallForExpressions, issueUnparseableErrorpublic ResourceLeakAnnotatedTypeFactory(BaseTypeChecker checker)
checker - the checker associated with this type factoryprotected 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 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 AnnotatedTypeFactorypublic AnnotationMirror createCalledMethods(String... val)
val - the methods that have been calledpublic void postAnalyze(ControlFlowGraph cfg)
GenericAnnotatedTypeFactoryGenericAnnotatedTypeFactory.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)protected ResourceLeakAnalysis createFlowAnalysis()
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 CalledMethodsAnnotatedTypeFactorypublic boolean hasCreatesMustCallFor(MethodInvocationNode node)
CreatesMustCallFor annotations.node - a method invocation nodepublic boolean canCreateObligations()
CreatesMustCallFor?public <T extends GenericAnnotatedTypeFactory<?,?,?,?>> T getTypeFactoryOfSubchecker(Class<? extends BaseTypeChecker> subCheckerClass)
GenericAnnotatedTypeFactoryBecause 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 AnnotatedTypeFactorysubCheckerClass - the exact class of the subcheckerpublic ExecutableElement getCreatesMustCallForValueElement()
CreatesMustCallFor.value() element.getCreatesMustCallForValueElement in interface CreatesMustCallForElementSupplierCreatesMustCallFor.value() elementpublic ExecutableElement getCreatesMustCallForListValueElement()
CreatesMustCallFor.List.value()
element.getCreatesMustCallForListValueElement in interface CreatesMustCallForElementSupplierCreatesMustCallFor.List.value()
element