Class ResourceLeakVisitor

All Implemented Interfaces:
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(MethodTree tree, Void p)
      Description copied from class: BaseTypeVisitor
      Checks that the method or constructor 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 TreeVisitor<Void,Void>
      Overrides:
      visitMethod in class CalledMethodsVisitor
    • shouldPerformContractInference

      protected boolean shouldPerformContractInference()
      Description copied from class: BaseTypeVisitor
      Should Whole Program Inference attempt to infer contract annotations? Typically, the answer is "yes" whenever WPI is enabled, but this method exists to allow subclasses to customize that behavior.
      Overrides:
      shouldPerformContractInference in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
      Returns:
      true if contract inference should be performed, false if it should be disabled (even when WPI is enabled)
    • visitVariable

      public Void visitVariable(VariableTree tree, Void p)
      Specified by:
      visitVariable in interface TreeVisitor<Void,Void>
      Overrides:
      visitVariable in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
    • isWpiEnabledForRLC

      protected boolean isWpiEnabledForRLC()
      Checks if WPI is enabled for the Resource Leak Checker inference. See ResourceLeakChecker.ENABLE_WPI_FOR_RLC.
      Returns:
      returns true if WPI is enabled for the Resource Leak Checker