Class ResourceLeakVisitor
- java.lang.Object
-
- com.sun.source.util.TreeScanner<R,P>
-
- com.sun.source.util.TreePathScanner<R,P>
-
- org.checkerframework.framework.source.SourceVisitor<java.lang.Void,java.lang.Void>
-
- org.checkerframework.common.basetype.BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
-
- org.checkerframework.common.accumulation.AccumulationVisitor
-
- org.checkerframework.checker.calledmethods.CalledMethodsVisitor
-
- org.checkerframework.checker.resourceleak.ResourceLeakVisitor
-
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
public class ResourceLeakVisitor extends CalledMethodsVisitor
The visitor for the Resource Leak Checker. Responsible for checking that the rules forOwning
fields are satisfied, and for checking thatCreatesMustCallFor
overrides are valid.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
BaseTypeVisitor.FoundRequired, BaseTypeVisitor.OverrideChecker
-
-
Field Summary
-
Fields inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
atypeFactory, checker, DETERMINISTIC, ignoreTargetLocations, IMPURE, methodTree, positions, PURE, qualAllowedLocations, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElement
-
Fields inherited from class org.checkerframework.framework.source.SourceVisitor
elements, root, trees, treesWithSuppressWarnings, types
-
-
Constructor Summary
Constructors Constructor Description ResourceLeakVisitor(BaseTypeChecker checker)
Create the visitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkPostcondition(com.sun.source.tree.MethodTree methodTree, javax.lang.model.element.AnnotationMirror annotation, JavaExpression expression)
Check that the expression's type is annotated withannotation
at the regular exit store.protected ResourceLeakAnnotatedTypeFactory
createTypeFactory()
Constructs an instance of the appropriate type factory for the implemented type system.java.lang.Void
visitMethod(com.sun.source.tree.MethodTree tree, java.lang.Void p)
Checks that the method obeys override and subtype rules to all overridden methods.java.lang.Void
visitVariable(com.sun.source.tree.VariableTree tree, java.lang.Void p)
-
Methods inherited from class org.checkerframework.checker.calledmethods.CalledMethodsVisitor
reportMethodInvocabilityError, visitAnnotation, visitMethodInvocation
-
Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
checkAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkConstructorResult, checkContract, checkDefaultConstructor, checkEnclosingExpr, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createQualAllowedLocations, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, isValidUse, processClassTree, reportCommonAssignmentError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateTargetLocation, validateType, validateTypeOf, validateVariablesTargetLocation, visitAnnotatedType, visitAnnotatedType, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeCast, visitTypeParameter, visitUnary, warnAboutIrrelevantJavaTypes, warnRedundantAnnotations
-
Methods inherited from class org.checkerframework.framework.source.SourceVisitor
visit
-
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitArrayAccess, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard
-
-
-
-
Constructor Detail
-
ResourceLeakVisitor
public ResourceLeakVisitor(BaseTypeChecker checker)
Create the visitor.- Parameters:
checker
- the type-checker associated with this visitor
-
-
Method Detail
-
createTypeFactory
protected ResourceLeakAnnotatedTypeFactory createTypeFactory()
Description copied from class:BaseTypeVisitor
Constructs an instance of the appropriate type factory for the implemented type system.The default implementation uses the checker naming convention to create the appropriate type factory. If no factory is found, it returns
BaseAnnotatedTypeFactory
. It reflectively invokes the constructor that accepts this checker and compilation unit tree (in that order) as arguments.Subclasses have to override this method to create the appropriate visitor if they do not follow the checker naming convention.
- Overrides:
createTypeFactory
in classBaseTypeVisitor<AccumulationAnnotatedTypeFactory>
- Returns:
- the appropriate type factory
-
visitMethod
public java.lang.Void visitMethod(com.sun.source.tree.MethodTree tree, java.lang.Void p)
Description copied from class:BaseTypeVisitor
Checks that the method obeys override and subtype rules to all overridden methods. (Uses the pseudo-assignment logic to do so.)The override rule specifies that a method, m1, may override a method m2 only if:
- m1 return type is a subtype of m2
- m1 receiver type is a supertype of m2
- m1 parameters are supertypes of corresponding m2 parameters
- Specified by:
visitMethod
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitMethod
in classCalledMethodsVisitor
-
checkPostcondition
protected void checkPostcondition(com.sun.source.tree.MethodTree methodTree, javax.lang.model.element.AnnotationMirror annotation, JavaExpression expression)
Description copied from class:BaseTypeVisitor
Check that the expression's type is annotated withannotation
at the regular exit store.- Overrides:
checkPostcondition
in classBaseTypeVisitor<AccumulationAnnotatedTypeFactory>
- Parameters:
methodTree
- declaration of the methodannotation
- expression's type must have this annotationexpression
- the expression that must have an annotation
-
visitVariable
public java.lang.Void visitVariable(com.sun.source.tree.VariableTree tree, java.lang.Void p)
- Specified by:
visitVariable
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Overrides:
visitVariable
in classBaseTypeVisitor<AccumulationAnnotatedTypeFactory>
-
-