public class LockVisitor extends org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
Modifier and Type | Field and Description |
---|---|
protected static java.util.regex.Pattern |
selfReceiverPattern |
Constructor and Description |
---|
LockVisitor(org.checkerframework.common.basetype.BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkOverride(MethodTree overriderTree,
org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType,
org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType overridden,
org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType)
Ensures that subclass methods are annotated with a stronger or equally strong side effect
annotation than the parent class method.
|
protected void |
commonAssignmentCheck(org.checkerframework.framework.type.AnnotatedTypeMirror varType,
org.checkerframework.framework.type.AnnotatedTypeMirror valueType,
Tree valueTree,
@CompilerMessageKey java.lang.String errorKey) |
LockAnnotatedTypeFactory |
createTypeFactory() |
protected java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
getExceptionParameterLowerBoundAnnotations() |
boolean |
isValidUse(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType declarationType,
org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType useType,
Tree tree)
Skips the call to super and returns true.
|
void |
processClassTree(ClassTree node)
Disallows annotations from the @GuardedBy hierarchy on class declarations (other
than @GuardedBy({}).
|
protected boolean |
skipReceiverSubtypeCheck(MethodInvocationTree methodInvocationTree,
org.checkerframework.framework.type.AnnotatedTypeMirror methodDefinitionReceiver,
org.checkerframework.framework.type.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.
|
java.lang.Void |
visitAnnotation(AnnotationTree tree,
java.lang.Void p) |
java.lang.Void |
visitArrayAccess(ArrayAccessTree tree,
java.lang.Void p) |
java.lang.Void |
visitBinary(BinaryTree binaryTree,
java.lang.Void p) |
java.lang.Void |
visitCompoundAssignment(CompoundAssignmentTree node,
java.lang.Void p) |
java.lang.Void |
visitIdentifier(IdentifierTree tree,
java.lang.Void p) |
java.lang.Void |
visitMemberSelect(MemberSelectTree tree,
java.lang.Void p) |
java.lang.Void |
visitMethod(MethodTree node,
java.lang.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.
|
java.lang.Void |
visitMethodInvocation(MethodInvocationTree node,
java.lang.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.
|
java.lang.Void |
visitSynchronized(SynchronizedTree node,
java.lang.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.
|
java.lang.Void |
visitVariable(VariableTree node,
java.lang.Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkPostcondition, checkPreconditions, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, createOverrideChecker, createTypeValidator, enclosingMemberSelect, enclosingStatement, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isVectorCopyInto, reportPurityErrors, scan, setRoot, shouldSkipUses, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitConditionalExpression, visitEnhancedForLoop, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitThrow, visitTypeCast, visitTypeParameter, visitUnary
getCurrentPath, scan
reduce, 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, visitWildcard
public LockVisitor(org.checkerframework.common.basetype.BaseTypeChecker checker)
public java.lang.Void visitVariable(VariableTree node, java.lang.Void p)
visitVariable
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitVariable
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public LockAnnotatedTypeFactory createTypeFactory()
createTypeFactory
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitMethod(MethodTree node, java.lang.Void p)
visitMethod
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitMethod
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
node
- the MethodTree of the method definition to visitprotected boolean skipReceiverSubtypeCheck(MethodInvocationTree methodInvocationTree, org.checkerframework.framework.type.AnnotatedTypeMirror methodDefinitionReceiver, org.checkerframework.framework.type.AnnotatedTypeMirror methodCallReceiver)
skipReceiverSubtypeCheck
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
methodInvocationTree
- the MethodInvocationTree of the method being calledmethodDefinitionReceiver
- the ATM of the formal receiver parameter of the method being
calledmethodCallReceiver
- the ATM of the receiver argument of the method callprotected java.util.Set<? extends javax.lang.model.element.AnnotationMirror> getExceptionParameterLowerBoundAnnotations()
getExceptionParameterLowerBoundAnnotations
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
protected void commonAssignmentCheck(org.checkerframework.framework.type.AnnotatedTypeMirror varType, org.checkerframework.framework.type.AnnotatedTypeMirror valueType, Tree valueTree, @CompilerMessageKey java.lang.String errorKey)
commonAssignmentCheck
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitMemberSelect(MemberSelectTree tree, java.lang.Void p)
visitMemberSelect
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitMemberSelect
in class TreeScanner<java.lang.Void,java.lang.Void>
protected boolean checkOverride(MethodTree overriderTree, org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType overridden, org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType)
checkOverride
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitArrayAccess(ArrayAccessTree tree, java.lang.Void p)
visitArrayAccess
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitArrayAccess
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public boolean isValidUse(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, org.checkerframework.framework.type.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 org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitMethodInvocation(MethodInvocationTree node, java.lang.Void p)
visitMethodInvocation
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitMethodInvocation
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
node
- the MethodInvocationTree of the method call being visitedpublic java.lang.Void visitSynchronized(SynchronizedTree node, java.lang.Void p)
Additionally, a synchronized block may not be present in a method that has a @LockingFree guarantee or stronger. An error is issued in this case.
visitSynchronized
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitSynchronized
in class TreeScanner<java.lang.Void,java.lang.Void>
node
- the SynchronizedTree for the synchronized block being visitedpublic java.lang.Void visitAnnotation(AnnotationTree tree, java.lang.Void p)
visitAnnotation
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitAnnotation
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitIdentifier(IdentifierTree tree, java.lang.Void p)
visitIdentifier
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitIdentifier
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public void processClassTree(ClassTree node)
processClassTree
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitBinary(BinaryTree binaryTree, java.lang.Void p)
visitBinary
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitBinary
in class TreeScanner<java.lang.Void,java.lang.Void>
public java.lang.Void visitCompoundAssignment(CompoundAssignmentTree node, java.lang.Void p)
visitCompoundAssignment
in interface TreeVisitor<java.lang.Void,java.lang.Void>
visitCompoundAssignment
in class org.checkerframework.common.basetype.BaseTypeVisitor<LockAnnotatedTypeFactory>