checkers.lock
Class LockVisitor

java.lang.Object
  extended by com.sun.source.util.TreeScanner<R,P>
      extended by com.sun.source.util.TreePathScanner<R,P>
          extended by checkers.source.SourceVisitor<R,P>
              extended by checkers.basetype.BaseTypeVisitor<Void,Void>
                  extended by checkers.lock.LockVisitor
All Implemented Interfaces:
TreeVisitor<Void,Void>

public class LockVisitor
extends BaseTypeVisitor<Void,Void>

A type-checking visitor for the Lock type system. This visitor reports errors ("unguarded.access") or warnings for violations for accessing a field or calling a method without holding their locks.


Field Summary
Modifier and Type Field and Description
 
Fields inherited from class checkers.basetype.BaseTypeVisitor
annoFactory, annoTypes, checker, plainFactory, visitorState
 
Fields inherited from class checkers.source.SourceVisitor
elements, root, trees, types
 
Constructor Summary
Constructor and Description
LockVisitor(LockChecker checker, CompilationUnitTree root)
           
 
Method Summary
Modifier and Type Method and Description
protected  boolean checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, MethodInvocationTree node)
          Tests whether the method can be invoked using the receiver of the 'node' method invocation, and issues a "method.invocation.invalid" if the invocation is invalid.
protected  boolean checkOverride(MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, Void p)
          Checks that an overriding method's return type, parameter types, and receiver type are correct with respect to the annotations on the overridden method's return type, parameter types, and receiver type.
protected  List<String> methodHolding(ExecutableElement element)
           
 Void visitIdentifier(IdentifierTree node, Void p)
           
 Void visitMemberSelect(MemberSelectTree node, Void p)
           
 Void visitMethod(MethodTree node, Void p)
          Performs pseudo-assignment check: checks that the method obeys override and subtype rules to all overridden methods.
 Void visitMethodInvocation(MethodInvocationTree node, Void p)
          Performs a method invocation check.
 Void visitSynchronized(SynchronizedTree node, Void p)
           
 
Methods inherited from class checkers.basetype.BaseTypeVisitor
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConstructorInvocation, checkDefaultConstructor, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, enclosingMemberSelect, enclosingStatement, isAccessAllowed, scan, shouldSkip, shouldSkip, validateTypeOf, visitAnnotation, visitAssignment, visitClass, visitCompilationUnit, visitCompoundAssignment, visitEnhancedForLoop, visitInstanceOf, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitTypeCast, visitUnary, visitVariable
 
Methods inherited from class com.sun.source.util.TreePathScanner
getCurrentPath, scan
 
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitAnnotatedType, visitArrayAccess, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitLabeledStatement, visitLiteral, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitThrow, visitTry, visitTypeParameter, visitWhileLoop, visitWildcard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockVisitor

public LockVisitor(LockChecker checker,
                   CompilationUnitTree root)
Method Detail

visitIdentifier

public Void visitIdentifier(IdentifierTree node,
                            Void p)
Specified by:
visitIdentifier in interface TreeVisitor<Void,Void>
Overrides:
visitIdentifier in class BaseTypeVisitor<Void,Void>

visitMemberSelect

public Void visitMemberSelect(MemberSelectTree node,
                              Void p)
Specified by:
visitMemberSelect in interface TreeVisitor<Void,Void>
Overrides:
visitMemberSelect in class TreeScanner<Void,Void>

visitSynchronized

public Void visitSynchronized(SynchronizedTree node,
                              Void p)
Specified by:
visitSynchronized in interface TreeVisitor<Void,Void>
Overrides:
visitSynchronized in class TreeScanner<Void,Void>

visitMethod

public Void visitMethod(MethodTree node,
                        Void p)
Description copied from class: BaseTypeVisitor
Performs pseudo-assignment check: checks that the method obeys override and subtype rules to all overridden methods. The override rule specifies that a method, m1, may override a method m2 only if: Also, it issues a "missing.this" error for static method annotated receivers.

Specified by:
visitMethod in interface TreeVisitor<Void,Void>
Overrides:
visitMethod in class BaseTypeVisitor<Void,Void>

visitMethodInvocation

public Void visitMethodInvocation(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:

Specified by:
visitMethodInvocation in interface TreeVisitor<Void,Void>
Overrides:
visitMethodInvocation in class BaseTypeVisitor<Void,Void>

checkOverride

protected boolean checkOverride(MethodTree overriderTree,
                                AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType,
                                AnnotatedTypeMirror.AnnotatedExecutableType overridden,
                                AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType,
                                Void p)
Description copied from class: BaseTypeVisitor
Checks that an overriding method's return type, parameter types, and receiver type are correct with respect to the annotations on the overridden method's return type, parameter types, and receiver type.

This method returns the result of the check, but also emits error messages as a side effect.

Overrides:
checkOverride in class BaseTypeVisitor<Void,Void>
Parameters:
overriderTree - the AST node of the overriding method
enclosingType - the declared type enclosing the overrider method
overridden - the type of the overridden method
overriddenType - the declared type enclosing the overridden method
p - an optional parameter (as supplied to visitor methods)
Returns:
true if the override check passed, false otherwise

checkMethodInvocability

protected boolean checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method,
                                          MethodInvocationTree node)
Description copied from class: BaseTypeVisitor
Tests whether the method can be invoked using the receiver of the 'node' method invocation, and issues a "method.invocation.invalid" if the invocation is invalid. This implementation tests whether the receiver in the method invocation is a subtype of the method receiver type.

Overrides:
checkMethodInvocability in class BaseTypeVisitor<Void,Void>
Parameters:
method - the type of the invoked method
node - the method invocation node
Returns:
true iff the call of 'node' is a valid call

methodHolding

protected List<String> methodHolding(ExecutableElement element)