Class CalledMethodsVisitor

java.lang.Object
com.sun.source.util.TreeScanner<R,P>
All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<Void,Void>
Direct Known Subclasses:
ResourceLeakVisitor

public class CalledMethodsVisitor extends AccumulationVisitor
This visitor implements the custom error message finalizer.invocation. It also supports counting the number of framework build calls.
  • Constructor Details

    • CalledMethodsVisitor

      public CalledMethodsVisitor(BaseTypeChecker checker)
      Creates a new CalledMethodsVisitor.
      Parameters:
      checker - the type-checker associated with this visitor
  • Method Details

    • visitAnnotation

      public Void visitAnnotation(com.sun.source.tree.AnnotationTree node, Void p)
      Issue an error at every EnsuresCalledMethodsVarArgs annotation, because using it is unsound.
      Specified by:
      visitAnnotation in interface com.sun.source.tree.TreeVisitor<Void,Void>
      Overrides:
      visitAnnotation in class AccumulationVisitor
    • 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 BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
    • visitMethodInvocation

      public Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node, Void p)
      Description copied from class: BaseTypeVisitor
      Performs a method invocation check.

      An invocation of a method, m, on the receiver, r is valid only if:

      • passed arguments are subtypes of corresponding m parameters
      • r is a subtype of m receiver type
      • if m is generic, passed type arguments are subtypes of m type variables
      Specified by:
      visitMethodInvocation in interface com.sun.source.tree.TreeVisitor<Void,Void>
      Overrides:
      visitMethodInvocation in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
    • reportMethodInvocabilityError

      protected void reportMethodInvocabilityError(com.sun.source.tree.MethodInvocationTree node, AnnotatedTypeMirror found, AnnotatedTypeMirror expected)
      Turns some method.invocation errors into finalizer.invocation errors.
      Overrides:
      reportMethodInvocabilityError in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
      Parameters:
      node - the AST node at which to report the error
      found - the actual type of the receiver
      expected - the expected type of the receiver