Class InitializationVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>,Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>>      
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<Factory>
org.checkerframework.checker.initialization.InitializationVisitor<Factory,Value,Store>  
- All Implemented Interfaces:
- TreeVisitor<Void,- Void> 
- Direct Known Subclasses:
- NullnessVisitor
public class InitializationVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,Store,?,?>,Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>>      
extends BaseTypeVisitor<Factory>
The visitor for the freedom-before-commitment type-system. The freedom-before-commitment
 type-system and this class are abstract and need to be combined with another type-system whose
 safe initialization should be tracked. For an example, see the 
NullnessChecker.- 
Nested Class SummaryNested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitorBaseTypeVisitor.OverrideChecker
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final AnnotationFormatterThe annotation formatter.protected final List<VariableTree>Fields 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 SummaryConstructorsConstructorDescriptionInitializationVisitor(BaseTypeChecker checker) Creates a new InitializationVisitor.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcheckConstructorInvocation(AnnotatedTypeMirror.AnnotatedDeclaredType dt, AnnotatedTypeMirror.AnnotatedExecutableType constructor, NewClassTree src) Check that the (explicit) annotations on a new class tree are comparable to the result type of the constructor.protected voidcheckConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Issue a warning if the result type of the constructor is not top.protected booleancheckContract(JavaExpression expr, AnnotationMirror necessaryAnnotation, AnnotationMirror inferredAnnotation, CFAbstractStore<?, ?> store) Returns true if and only ifinferredAnnotationis valid for a given expression to match thenecessaryAnnotation.protected voidcheckFieldsInitialized(Tree tree, boolean staticFields, Store store, List<? extends AnnotationMirror> receiverAnnotations) Checks that all fields (all static fields ifstaticFieldsis true) are initialized in the given store.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.voidprocessClassTree(ClassTree tree) Type-check classTree.voidsetRoot(CompilationUnitTree root) Set the CompilationUnitTree to be used during any visits.visitMethod(MethodTree tree, Void p) Checks that the method obeys override and subtype rules to all overridden methods.visitTypeCast(TypeCastTree tree, Void p) visitVariable(VariableTree tree, Void p) Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitorcheckAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createTypeFactory, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, isValidUse, reportMethodInvocabilityError, reportPurityErrors, scan, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotatedType, visitAnnotatedType, visitAnnotation, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethodInvocation, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeParameter, visitUnary, warnAboutIrrelevantJavaTypesMethods 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
- 
Field Details- 
annoFormatterThe annotation formatter.
- 
initializedFields
 
- 
- 
Constructor Details- 
InitializationVisitorCreates a new InitializationVisitor.- Parameters:
- checker- the associated type-checker
 
 
- 
- 
Method Details- 
setRootDescription copied from class:SourceVisitorSet the CompilationUnitTree to be used during any visits. For any later calls ofcom.sun.source.util.TreePathScanner.scan(TreePath, P), the CompilationUnitTree of the TreePath has to be equal toroot.- Overrides:
- setRootin class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
 
- 
checkConstructorInvocationprotected void checkConstructorInvocation(AnnotatedTypeMirror.AnnotatedDeclaredType dt, AnnotatedTypeMirror.AnnotatedExecutableType constructor, NewClassTree src) Description copied from class:BaseTypeVisitorCheck that the (explicit) annotations on a new class tree are comparable to the result type of the constructor. Issue an error if not.Issue a warning if the annotations on the constructor invocation is a subtype of the constructor result type. This is equivalent to down-casting. - Overrides:
- checkConstructorInvocationin class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
 
- 
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<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
- 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<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
- Parameters:
- superCall- the AST node for the constructor call
- errorKey- the error message key to use if the check fails
 
- 
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<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
- 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
 
- 
visitVariable- Specified by:
- visitVariablein interface- TreeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>, - Value extends CFAbstractValue<Value>> 
- Overrides:
- visitVariablein class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
 
- 
checkContractprotected boolean checkContract(JavaExpression expr, AnnotationMirror necessaryAnnotation, AnnotationMirror inferredAnnotation, CFAbstractStore<?, ?> store) Description copied from class:BaseTypeVisitorReturns true if and only ifinferredAnnotationis valid for a given expression to match thenecessaryAnnotation.By default, inferredAnnotationmust be a subtype ofnecessaryAnnotation, but subclasses might override this behavior.- Overrides:
- checkContractin class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
 
- 
visitTypeCast- Specified by:
- visitTypeCastin interface- TreeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>, - Value extends CFAbstractValue<Value>> 
- Overrides:
- visitTypeCastin class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
 
- 
processClassTreeDescription copied from class:BaseTypeVisitorType-check classTree. Subclasses should override this method instead ofBaseTypeVisitor.visitClass(ClassTree, Void).- Overrides:
- processClassTreein class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
- Parameters:
- tree- class to check
 
- 
visitMethodDescription copied from class:BaseTypeVisitorChecks that the method obeys override and subtype rules to all overridden methods. (Uses the pseudo-assignment logic to do so.)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
 - Specified by:
- visitMethodin interface- TreeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>, - Value extends CFAbstractValue<Value>> 
- Overrides:
- visitMethodin class- BaseTypeVisitor<Factory extends InitializationAnnotatedTypeFactory<Value,- Store, - ?, - ?>> 
 
- 
checkFieldsInitializedprotected void checkFieldsInitialized(Tree tree, boolean staticFields, Store store, List<? extends AnnotationMirror> receiverAnnotations) Checks that all fields (all static fields ifstaticFieldsis true) are initialized in the given store.- Parameters:
- tree- a- ClassTreeif- staticFieldsis true; a- MethodTreefor a constructor if- staticFieldsis false. This is where errors are reported, if they are not reported at the fields themselves
- staticFields- whether to check static fields or instance fields
- store- the store
- receiverAnnotations- the annotations on the receiver
 
 
-