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.AccumulationTreeAnnotatorNested 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
Fields inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
accumulationChecker, bottom, topFields 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
ConstructorsConstructorDescriptionCreates a new ResourceLeakAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDoes this type factory supportCreatesMustCallFor?createCalledMethods(String... val) Creates a @CalledMethods annotation whose values are the given strings.protected ResourceLeakAnalysisReturns 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 theEnsuresCalledMethodsOnExceptionannotations on it.<T extends GenericAnnotatedTypeFactory<?,?, ?, ?>>
@Nullable TgetTypeFactoryOfSubcheckerOrNull(Class<? extends SourceChecker> subCheckerClass) Returns the type factory used by a subchecker.booleanReturns true if the declaration of the method being invoked has one or moreCreatesMustCallForannotations.booleanhasNotOwning(Element elt) Does the given element have an@NotOwningannotation (including in stub files)?booleanDoes the given element have an@Owningannotation (including in stub files)?voidPerform any additional operations on a CFG.Methods inherited from class org.checkerframework.checker.calledmethods.CalledMethodsAnnotatedTypeFactory
adjustMethodNameUsingValueChecker, createRequiresOrEnsuresQualifier, createTreeAnnotator, createTypeAnnotator, getCalledMethods, getDummyAssignedTo, isIgnoredExceptionType, returnsThisMethods inherited from class org.checkerframework.common.accumulation.AccumulationAnnotatedTypeFactory
convertToPredicate, createAccumulatorAnnotation, createAccumulatorAnnotation, createPredicateAnnotation, createQualifierHierarchy, evaluatePredicate, evaluatePredicate, getAccumulatedValues, getAccumulatedValues, isAccumulatorAnnotation, isPredicate, isPredicateSubtypeMethods 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, 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, 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, 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, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isTop, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, 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: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:
-
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:GenericAnnotatedTypeFactoryPerform 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:
postAnalyzein classGenericAnnotatedTypeFactory<AccumulationValue,AccumulationStore, AccumulationTransfer, AccumulationAnalysis> - Parameters:
cfg- the CFG- See Also:
-
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 classCalledMethodsAnnotatedTypeFactory- Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
getMustCallAnnotation
Retrieves the@MustCallannotation for the given object, which can be either anElementor aTree. This method delegates to theMustCallAnnotatedTypeFactoryto get the annotated type of the input object and then extracts the primary@MustCallannotation from it.- Parameters:
obj- the object for which to retrieve the@MustCallannotation. Must be either an instance ofElementorTree.- Returns:
- the
@MustCallannotation if present, null otherwise - Throws:
IllegalArgumentException- if the input object type is not supported
-
hasCreatesMustCallFor
Returns true if the declaration of the method being invoked has one or moreCreatesMustCallForannotations.- 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 SourceChecker> subCheckerClass) Description copied from class:GenericAnnotatedTypeFactoryReturns 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:
getTypeFactoryOfSubcheckerOrNullin 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:
getCreatesMustCallForValueElementin interfaceCreatesMustCallForElementSupplier- Returns:
- the
CreatesMustCallFor.value()element
-
getCreatesMustCallForListValueElement
Returns theCreatesMustCallFor.List.value()element.- Specified by:
getCreatesMustCallForListValueElementin interfaceCreatesMustCallForElementSupplier- Returns:
- the
CreatesMustCallFor.List.value()element
-
hasNotOwning
Does the given element have an@NotOwningannotation (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@Owningannotation (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:CalledMethodsAnnotatedTypeFactoryGet the exceptional postconditions for the given method from theEnsuresCalledMethodsOnExceptionannotations on it.- Overrides:
getExceptionalPostconditionsin 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
-