public class LockVisitor extends BaseTypeVisitor<LockAnnotatedTypeFactory>
atypeFactory, checker, contractsUtils, positions, thisPattern, typeValidator, visitorStateelements, root, trees, types| Constructor and Description |
|---|
LockVisitor(BaseTypeChecker checker) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkOverride(MethodTree overriderTree,
AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType,
Void p)
Ensures that subclass methods are annotated with a stronger or equally strong side effect annotation
than the parent class method.
|
protected void |
commonAssignmentCheck(AnnotatedTypeMirror varType,
AnnotatedTypeMirror valueType,
Tree valueTree,
@CompilerMessageKey String errorKey)
Checks the validity of an assignment (or pseudo-assignment) from a value
to a variable and emits an error message (through the compiler's
messaging interface) if it is not valid.
|
LockAnnotatedTypeFactory |
createTypeFactory()
Constructs an instance of the appropriate type factory for the
implemented type system.
|
protected Set<? extends AnnotationMirror> |
getExceptionParameterLowerBoundAnnotations()
Returns a set of AnnotationMirrors that is a lower bound for exception
parameters.
|
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType,
AnnotatedTypeMirror.AnnotatedDeclaredType useType,
Tree tree)
Skips the call to super and returns true.
|
protected FlowExpressions.Receiver |
parseExpressionString(String expression,
FlowExpressionParseUtil.FlowExpressionContext flowExprContext,
TreePath path,
Node node,
Tree treeForErrorReporting)
If expression is "itself", and the flow expression parser cannot find a variable,
class, etc.
|
protected boolean |
skipReceiverSubtypeCheck(MethodInvocationTree node,
AnnotatedTypeMirror methodDefinitionReceiver,
AnnotatedTypeMirror methodCallReceiver)
When visiting a method call, if the receiver formal parameter has type @GuardSatisfied
and the receiver actual parameter has type @GuardedBy(...), this method verifies that
the guard is satisfied, and it returns true, indicating that the receiver subtype check should be skipped.
|
Void |
visitAnnotation(AnnotationTree tree,
Void p)
Ensure that the annotation arguments comply to their declarations.
|
Void |
visitArrayAccess(ArrayAccessTree tree,
Void p) |
Void |
visitBinary(BinaryTree node,
Void p) |
Void |
visitClass(ClassTree node,
Void p)
Disallows annotations from the @GuardedBy hierarchy on class declarations (other than @GuardedBy({}).
|
Void |
visitCompoundAssignment(CompoundAssignmentTree node,
Void p)
Performs assignability check using
BaseTypeVisitor.checkAssignability(AnnotatedTypeMirror, Tree). |
Void |
visitIdentifier(IdentifierTree tree,
Void p) |
Void |
visitMemberSelect(MemberSelectTree tree,
Void p) |
Void |
visitMethod(MethodTree node,
Void p)
Issues an error if a method (explicitly or implicitly) annotated with @MayReleaseLocks has a formal parameter
or receiver (explicitly or implicitly) annotated with @GuardSatisfied.
|
Void |
visitMethodInvocation(MethodInvocationTree node,
Void p)
When visiting a method invocation, issue an error if the side effect annotation
on the called method causes the side effect guarantee of the enclosing method
to be violated.
|
Void |
visitSynchronized(SynchronizedTree node,
Void p)
When visiting a synchronized block, issue an error if the expression
has a type that implements the java.util.concurrent.locks.Lock interface.
|
Void |
visitVariable(VariableTree node,
Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostconditions, checkConditionalPostconditionsConsistency, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkFlowExprParameters, checkForAnnotatedJdk, checkMethodInvocability, checkMethodReferenceAsOverride, checkPostconditions, checkPostconditionsConsistency, checkPreconditions, checkPreconditions, checkPreconditionsConsistency, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, createTypeValidator, enclosingMemberSelect, enclosingStatement, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isVectorCopyInto, reportPurityErrors, scan, setRoot, shouldSkipUses, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAssignment, visitCatch, visitCompilationUnit, visitConditionalExpression, visitEnhancedForLoop, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitThrow, visitTypeCast, visitTypeParameter, visitUnaryvisitgetCurrentPath, scanreduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitTry, visitUnionType, visitWhileLoop, visitWildcardpublic LockVisitor(BaseTypeChecker checker)
public Void visitVariable(VariableTree node, Void p)
visitVariable in interface TreeVisitor<Void,Void>visitVariable in class BaseTypeVisitor<LockAnnotatedTypeFactory>public LockAnnotatedTypeFactory createTypeFactory()
BaseTypeVisitorBaseAnnotatedTypeFactory. 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.createTypeFactory in class BaseTypeVisitor<LockAnnotatedTypeFactory>public Void visitMethod(MethodTree node, Void p)
visitMethod in interface TreeVisitor<Void,Void>visitMethod in class BaseTypeVisitor<LockAnnotatedTypeFactory>node - the MethodTree of the method definition to visit.protected boolean skipReceiverSubtypeCheck(MethodInvocationTree node, AnnotatedTypeMirror methodDefinitionReceiver, AnnotatedTypeMirror methodCallReceiver)
skipReceiverSubtypeCheck in class BaseTypeVisitor<LockAnnotatedTypeFactory>node - the MethodInvocationTree of the method being called.methodDefinitionReceiver - the ATM of the formal receiver parameter of the method being called.methodCallReceiver - the ATM of the receiver argument of the method call.protected Set<? extends AnnotationMirror> getExceptionParameterLowerBoundAnnotations()
BaseTypeVisitorgetExceptionParameterLowerBoundAnnotations in class BaseTypeVisitor<LockAnnotatedTypeFactory>protected void commonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, Tree valueTree, @CompilerMessageKey String errorKey)
BaseTypeVisitorcommonAssignmentCheck in class BaseTypeVisitor<LockAnnotatedTypeFactory>varType - the annotated type of the variablevalueType - the annotated type of the valuevalueTree - the location to use when reporting the error messageerrorKey - the error message to use if the check fails (must be a
compiler message key, see CompilerMessageKey)public Void visitMemberSelect(MemberSelectTree tree, Void p)
visitMemberSelect in interface TreeVisitor<Void,Void>visitMemberSelect in class TreeScanner<Void,Void>protected boolean checkOverride(MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, Void p)
checkOverride in class BaseTypeVisitor<LockAnnotatedTypeFactory>overriderTree - Declaration tree of overriding methodenclosingType - Type of overriding classoverridden - Type of overridden methodoverriddenType - Type of overridden classpublic Void visitArrayAccess(ArrayAccessTree tree, Void p)
visitArrayAccess in interface TreeVisitor<Void,Void>visitArrayAccess in class BaseTypeVisitor<LockAnnotatedTypeFactory>public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType, Tree tree)
GuardedBy({}) is the default type on class declarations, which is a subtype of the top annotation @GuardedByUnknown.
However, it is valid to declare an instance of a class with any annotation from the @GuardedBy hierarchy.
Hence, this method returns true for annotations in the @GuardedBy hierarchy.
Also returns true for annotations in the @LockPossiblyHeld hierarchy since the default for that hierarchy is the top type and
annotations from that hierarchy cannot be explicitly written in code.
isValidUse in class BaseTypeVisitor<LockAnnotatedTypeFactory>declarationType - the type of the class (TypeElement)useType - the use of the class (instance type)tree - the tree where the type is usedpublic Void visitMethodInvocation(MethodInvocationTree node, Void p)
visitMethodInvocation in interface TreeVisitor<Void,Void>visitMethodInvocation in class BaseTypeVisitor<LockAnnotatedTypeFactory>node - the MethodInvocationTree of the method call being visited.public Void visitSynchronized(SynchronizedTree node, Void p)
visitSynchronized in interface TreeVisitor<Void,Void>visitSynchronized in class TreeScanner<Void,Void>node - the SynchronizedTree for the synchronized block being visited.public Void visitAnnotation(AnnotationTree tree, Void p)
BaseTypeVisitorvisitAnnotation in interface TreeVisitor<Void,Void>visitAnnotation in class BaseTypeVisitor<LockAnnotatedTypeFactory>public Void visitIdentifier(IdentifierTree tree, Void p)
visitIdentifier in interface TreeVisitor<Void,Void>visitIdentifier in class BaseTypeVisitor<LockAnnotatedTypeFactory>protected FlowExpressions.Receiver parseExpressionString(String expression, FlowExpressionParseUtil.FlowExpressionContext flowExprContext, TreePath path, Node node, Tree treeForErrorReporting) throws FlowExpressionParseUtil.FlowExpressionParseException
node is returned,
unless node is null, in which case null is returned.
Also checks that the flow expression is effectively final and issues an error if it is not.
Returns the result of the super implementation otherwise.
parseExpressionString in class BaseTypeVisitor<LockAnnotatedTypeFactory>expression - the flow expression string to be parsed.flowExprContext - the flow expression context with respect to which the expression string is to be evaluated.path - the TreePath from which to obtain the scope relative to which local variables are parsed.node - the Node immediately prior to which the preconditions checked by the calling method must hold true.
Used by overriding implementations. Allowed to be null.treeForErrorReporting - the Tree used to report parsing errors via checker.report.
Used by overriding implementations.FlowExpressionParseUtil.FlowExpressionParseExceptionpublic Void visitClass(ClassTree node, Void p)
visitClass in interface TreeVisitor<Void,Void>visitClass in class BaseTypeVisitor<LockAnnotatedTypeFactory>public Void visitBinary(BinaryTree node, Void p)
visitBinary in interface TreeVisitor<Void,Void>visitBinary in class TreeScanner<Void,Void>public Void visitCompoundAssignment(CompoundAssignmentTree node, Void p)
BaseTypeVisitorBaseTypeVisitor.checkAssignability(AnnotatedTypeMirror, Tree).visitCompoundAssignment in interface TreeVisitor<Void,Void>visitCompoundAssignment in class BaseTypeVisitor<LockAnnotatedTypeFactory>