Class ResourceLeakAnnotatedTypeFactory
- All Implemented Interfaces:
CreatesMustCallForElementSupplier
,AnnotationProvider
postAnalyze(ControlFlowGraph)
method checks that must-call obligations are fulfilled.-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy, AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.ParameterizedExecutableType
-
Field Summary
Fields inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
accumulationChecker, bottom, top
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, typeAnnotator
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, wpiOutputFormat
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ResourceLeakAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Does this type factory supportCreatesMustCallFor
?createCalledMethods
(String... val) Creates a @CalledMethods annotation whose values are the given strings.protected ResourceLeakAnalysis
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.protected Set<Class<? extends Annotation>>
Returns a mutable set of annotation classes that are supported by a checker.Returns theCreatesMustCallFor.List.value()
element.Returns theCreatesMustCallFor.value()
element.Returns theEnsuresCalledMethods.List.value()
element.getExceptionalPostconditions
(ExecutableElement methodOrConstructor) Get the exceptional postconditions for the given method from theEnsuresCalledMethodsOnException
annotations on it.<T extends GenericAnnotatedTypeFactory<?,
?, ?, ?>>
@Nullable TgetTypeFactoryOfSubcheckerOrNull
(Class<? extends BaseTypeChecker> subCheckerClass) Returns the type factory used by a subchecker.boolean
Returns true if the declaration of the method being invoked has one or moreCreatesMustCallFor
annotations.boolean
hasNotOwning
(Element elt) Does the given element have an@NotOwning
annotation (including in stub files)?boolean
Does the given element have an@Owning
annotation (including in stub files)?void
Perform any additional operations on a CFG.Methods inherited from class org.checkerframework.checker.calledmethods.CalledMethodsAnnotatedTypeFactory
adjustMethodNameUsingValueChecker, createRequiresOrEnsuresQualifier, createTreeAnnotator, createTypeAnnotator, getCalledMethods, getDummyAssignedTo, isIgnoredExceptionType, returnsThis
Methods inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
convertToPredicate, createAccumulatorAnnotation, createAccumulatorAnnotation, createPredicateAnnotation, createQualifierHierarchy, evaluatePredicate, evaluatePredicate, getAccumulatedValues, getAccumulatedValues, isAccumulatorAnnotation, isPredicate, isPredicateSubtype
Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsForWarnRedundant, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, 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, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, irrelevantExtraMessage, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
Methods 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, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, 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, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorTreePath, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isDeterministic, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField, wpiPrepareMethodForWriting, wpiPrepareMethodForWriting, wpiShouldInferTypesForReceivers
-
Constructor Details
-
ResourceLeakAnnotatedTypeFactory
Creates a new ResourceLeakAnnotatedTypeFactory.- Parameters:
checker
- the checker associated with this type factory
-
-
Method Details
-
createSupportedTypeQualifiers
Description copied from class:AnnotatedTypeFactory
Returns 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 otherElementType
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:
- 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:@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:
createSupportedTypeQualifiers
in classAnnotatedTypeFactory
- Returns:
- the type qualifiers supported this processor, or an empty set if none
- Only support annotations located in a checker's qual directory:
-
createCalledMethods
Creates a @CalledMethods annotation whose values are the given strings.- Parameters:
val
- the methods that have been called- Returns:
- an annotation indicating that the given methods have been called
-
postAnalyze
Description copied from class:GenericAnnotatedTypeFactory
Perform any additional operations on a CFG. Called once per CFG, after the CFG has been analyzed byGenericAnnotatedTypeFactory.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.- Overrides:
postAnalyze
in classGenericAnnotatedTypeFactory<AccumulationValue,
AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Parameters:
cfg
- the CFG- See Also:
-
createFlowAnalysis
Description copied from class:GenericAnnotatedTypeFactory
Returns 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:
createFlowAnalysis
in classCalledMethodsAnnotatedTypeFactory
- Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
hasCreatesMustCallFor
Returns true if the declaration of the method being invoked has one or moreCreatesMustCallFor
annotations.- Parameters:
node
- a method invocation node- Returns:
- true iff there is one or more @CreatesMustCallFor annotations on the declaration of the invoked method
-
canCreateObligations
public boolean canCreateObligations()Does this type factory supportCreatesMustCallFor
?- Returns:
- true iff the -AnoCreatesMustCallFor command-line argument was not supplied to the checker
-
getTypeFactoryOfSubcheckerOrNull
public <T extends GenericAnnotatedTypeFactory<?,?, @Nullable T getTypeFactoryOfSubcheckerOrNull?, ?>> (Class<? extends BaseTypeChecker> subCheckerClass) Description copied from class:GenericAnnotatedTypeFactory
Returns the type factory used by a subchecker. Returns null if no matching subchecker was found or if the type factory is null. The caller must know the exact checker class to request.Because the visitor path is copied, call this method each time a subfactory is needed rather than store the returned subfactory in a field.
- Overrides:
getTypeFactoryOfSubcheckerOrNull
in classGenericAnnotatedTypeFactory<AccumulationValue,
AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Type Parameters:
T
- the type ofsubCheckerClass
'sAnnotatedTypeFactory
- Parameters:
subCheckerClass
- the exact class of the subchecker- Returns:
- the AnnotatedTypeFactory of the subchecker or null if no subchecker exists
- See Also:
-
getEnsuresCalledMethodsListValueElement
Returns theEnsuresCalledMethods.List.value()
element.- Returns:
- the
EnsuresCalledMethods.List.value()
element
-
getCreatesMustCallForValueElement
Returns theCreatesMustCallFor.value()
element.- Specified by:
getCreatesMustCallForValueElement
in interfaceCreatesMustCallForElementSupplier
- Returns:
- the
CreatesMustCallFor.value()
element
-
getCreatesMustCallForListValueElement
Returns theCreatesMustCallFor.List.value()
element.- Specified by:
getCreatesMustCallForListValueElement
in interfaceCreatesMustCallForElementSupplier
- Returns:
- the
CreatesMustCallFor.List.value()
element
-
hasNotOwning
Does the given element have an@NotOwning
annotation (including in stub files)?Prefer this method to calling
AnnotatedTypeFactory.getDeclAnnotation(Element, Class)
on the type factory directly, which won't find this annotation in stub files (it only considers stub files loaded by this checker, not subcheckers).- Parameters:
elt
- an element- Returns:
- whether there is a NotOwning annotation on the given element
-
hasOwning
Does the given element have an@Owning
annotation (including in stub files)?Prefer this method to calling
AnnotatedTypeFactory.getDeclAnnotation(Element, Class)
on the type factory directly, which won't find this annotation in stub files (it only considers stub files loaded by this checker, not subcheckers).- Parameters:
elt
- an element- Returns:
- whether there is an Owning annotation on the given element
-
getExceptionalPostconditions
public Set<EnsuresCalledMethodOnExceptionContract> getExceptionalPostconditions(ExecutableElement methodOrConstructor) Description copied from class:CalledMethodsAnnotatedTypeFactory
Get the exceptional postconditions for the given method from theEnsuresCalledMethodsOnException
annotations on it.- Overrides:
getExceptionalPostconditions
in classCalledMethodsAnnotatedTypeFactory
- Parameters:
methodOrConstructor
- the method to examine- Returns:
- the exceptional postconditions on the given method; the return value is newly-allocated and can be freely modified by callers
-