Class CalledMethodsVisitor

  • All Implemented Interfaces:
    com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
    Direct Known Subclasses:
    ResourceLeakVisitor

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

      • CalledMethodsVisitor

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

      • visitAnnotation

        public java.lang.Void visitAnnotation​(com.sun.source.tree.AnnotationTree tree,
                                              java.lang.Void p)
        Issue an error at every EnsuresCalledMethodsVarArgs annotation, because using it is unsound.
        Specified by:
        visitAnnotation in interface com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
        Overrides:
        visitAnnotation in class AccumulationVisitor
      • 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
        Also, it issues a "missing.this" error for static method annotated receivers.
        Specified by:
        visitMethod in interface com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
        Overrides:
        visitMethod in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
      • visitMethodInvocation

        public java.lang.Void visitMethodInvocation​(com.sun.source.tree.MethodInvocationTree tree,
                                                    java.lang.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<java.lang.Void,​java.lang.Void>
        Overrides:
        visitMethodInvocation in class BaseTypeVisitor<AccumulationAnnotatedTypeFactory>