Class AliasingVisitor
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
 
com.sun.source.util.TreePathScanner<R,P>
 
org.checkerframework.framework.source.SourceVisitor<Void,Void>
 
org.checkerframework.common.basetype.BaseTypeVisitor<AliasingAnnotatedTypeFactory>
org.checkerframework.common.aliasing.AliasingVisitor
- All Implemented Interfaces:
- TreeVisitor<Void,- Void> 
This visitor ensures that every constructor whose result is annotated as @Unique does
 not leak aliases.
 
TODO: Implement @NonLeaked and @LeakedToResult verifications:
@NonLeaked: When a method declaration has a parameter annotated as @NonLeaked, the method body must not leak a reference to that parameter.
@LeakedToResult: When a method declaration has a parameter annotated as @LeakedToResult, the method body must not leak a reference to that parameter, except at the method return statements.
Both of the checks above are similar to the @Unique check that is implemented in this visitor.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitorBaseTypeVisitor.OverrideChecker
- 
Field SummaryFields inherited from class org.checkerframework.common.basetype.BaseTypeVisitoratypeFactory, checker, DETERMINISTIC, methodTree, positions, PURE, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeValidator, unusedWhenElementFields inherited from class org.checkerframework.framework.source.SourceVisitorelements, root, trees, treesWithSuppressWarnings, types
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcheckConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Issue a warning if the result type of the constructor is not top.protected voidcheckThisOrSuperConstructorCall(MethodInvocationTree superCall, @CompilerMessageKey String errorKey) Checks that the following rule is satisfied: The type on a constructor declaration must be a supertype of the return type of "this()" or "super()" invocation within that constructor.protected voidcommonAssignmentCheck(Tree varTree, ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs) 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.protected voidcommonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, Tree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) 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.Checks that if a method call is being invoked inside a constructor with result type @Unique, it must not leak the "this" reference.visitNewArray(NewArrayTree tree, Void p) visitThrow(ThrowTree tree, Void p) Checks the type of a thrown exception.visitVariable(VariableTree tree, Void p) Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitorcheckAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createTypeFactory, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, isValidUse, processClassTree, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotatedType, visitAnnotatedType, visitAnnotation, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitNewClass, visitReturn, visitSwitchExpression17, visitTypeCast, visitTypeParameter, visitUnary, warnAboutIrrelevantJavaTypes, warnRedundantAnnotationsMethods inherited from class org.checkerframework.framework.source.SourceVisitorvisitMethods inherited from class com.sun.source.util.TreePathScannergetCurrentPath, scanMethods inherited from class com.sun.source.util.TreeScannerreduce, scan, visitArrayAccess, visitArrayType, visitAssert, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSwitchExpression, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard, visitYield
- 
Constructor Details- 
AliasingVisitor
 
- 
- 
Method Details- 
visitMethodInvocationChecks that if a method call is being invoked inside a constructor with result type @Unique, it must not leak the "this" reference. There are 3 ways to make sure that this is not happening:- thisis not an argument of the method call.
- thisis an argument of the method call, but the respective parameter is annotated as @NonLeaked.
- thisis an argument of the method call, but the respective parameter is annotated as @LeakedToResult AND the result of the method call is not being stored (the method call is a statement).
 isUniqueCheckhandles cases 2 and 3.- Specified by:
- visitMethodInvocationin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitMethodInvocationin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
 
- 
commonAssignmentCheckprotected void commonAssignmentCheck(Tree varTree, ExpressionTree valueExp, @CompilerMessageKey String errorKey, Object... extraArgs) Description copied from class:BaseTypeVisitorChecks 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.- Overrides:
- commonAssignmentCheckin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
- Parameters:
- varTree- the AST node for the lvalue (usually a variable)
- valueExp- the AST node for the rvalue (the new value)
- errorKey- the error message key to use if the check fails
- extraArgs- arguments to the error message key, before "found" and "expected" types
 
- 
commonAssignmentCheck@FormatMethod protected void commonAssignmentCheck(AnnotatedTypeMirror varType, AnnotatedTypeMirror valueType, Tree valueTree, @CompilerMessageKey String errorKey, Object... extraArgs) Description copied from class:BaseTypeVisitorChecks 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.- Overrides:
- commonAssignmentCheckin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
- Parameters:
- varType- the annotated type of the variable
- valueType- the annotated type of the value
- valueTree- the location to use when reporting the error message
- errorKey- the error message key to use if the check fails
- extraArgs- arguments to the error message key, before "found" and "expected" types
 
- 
visitThrowDescription copied from class:BaseTypeVisitorChecks the type of a thrown exception. Subclasses should override checkThrownExpression(ThrowTree tree) rather than this method to change the behavior of this check.- Specified by:
- visitThrowin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitThrowin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
 
- 
visitVariable- Specified by:
- visitVariablein interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitVariablein class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
 
- 
visitNewArray- Specified by:
- visitNewArrayin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitNewArrayin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
 
- 
checkConstructorResultprotected void checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Description copied from class:BaseTypeVisitorIssue a warning if the result type of the constructor is not top. If it is a supertype of the class, then a conflicting.annos error will also be issued byBaseTypeVisitor.isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType,AnnotatedTypeMirror.AnnotatedDeclaredType,Tree).- Overrides:
- checkConstructorResultin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
- Parameters:
- constructorType- AnnotatedExecutableType for the constructor
- constructorElement- element that declares the constructor
 
- 
checkThisOrSuperConstructorCallprotected void checkThisOrSuperConstructorCall(MethodInvocationTree superCall, @CompilerMessageKey String errorKey) Description copied from class:BaseTypeVisitorChecks that the following rule is satisfied: The type on a constructor declaration must be a supertype of the return type of "this()" or "super()" invocation within that constructor.- Overrides:
- checkThisOrSuperConstructorCallin class- BaseTypeVisitor<AliasingAnnotatedTypeFactory>
- Parameters:
- superCall- the AST node for the constructor call
- errorKey- the error message key to use if the check fails
 
 
-