Class ResourceLeakVisitor

All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<Void,Void>

public class ResourceLeakVisitor extends CalledMethodsVisitor
The visitor for the Resource Leak Checker. Responsible for checking that the rules for Owning fields are satisfied, and for checking that CreatesMustCallFor overrides are valid.
  • Constructor Details

    • ResourceLeakVisitor

      public ResourceLeakVisitor(BaseTypeChecker checker)
      Create the visitor.
      Parameters:
      checker - the type-checker associated with this visitor
  • Method Details

    • 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 class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
      Returns:
      the appropriate type factory
    • visitMethod

      public Void visitMethod(com.sun.source.tree.MethodTree node, 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
      Also, it issues a "missing.this" error for static method annotated receivers.
      Specified by:
      visitMethod in interface com.sun.source.tree.TreeVisitor<Void,Void>
      Overrides:
      visitMethod in class CalledMethodsVisitor
    • checkPostcondition

      protected void checkPostcondition(com.sun.source.tree.MethodTree methodTree, AnnotationMirror annotation, JavaExpression expression)
      Description copied from class: BaseTypeVisitor
      Check that the expression's type is annotated with annotation at the regular exit store.
      Overrides:
      checkPostcondition in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
      Parameters:
      methodTree - declaration of the method
      annotation - expression's type must have this annotation
      expression - the expression that must have an annotation
    • visitVariable

      public Void visitVariable(com.sun.source.tree.VariableTree node, Void p)
      Specified by:
      visitVariable in interface com.sun.source.tree.TreeVisitor<Void,Void>
      Overrides:
      visitVariable in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>