checkers.lock
Class LockVisitor
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
com.sun.source.util.TreePathScanner<R,P>
checkers.source.SourceVisitor<R,P>
checkers.basetype.BaseTypeVisitor<Void,Void>
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.
Methods inherited from class checkers.basetype.BaseTypeVisitor |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConstructorInvocation, checkOverride, checkTypeArguments, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, enclosingMemberSelect, 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.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 |
LockVisitor
public LockVisitor(LockChecker checker,
CompilationUnitTree root)
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:
- 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 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:
- 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 TreeVisitor<Void,Void>
- Overrides:
visitMethodInvocation
in class BaseTypeVisitor<Void,Void>
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 methodnode
- the method invocation node
- Returns:
- true iff the call of 'node' is a valid call