Class InitializationAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
InitializationChecker
for further information.-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.checker.initialization.InitializationParentAnnotatedTypeFactory
InitializationParentAnnotatedTypeFactory.CommitmentTreeAnnotator, InitializationParentAnnotatedTypeFactory.CommitmentTypeAnnotator, InitializationParentAnnotatedTypeFactory.InitializationQualifierHierarchy
Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanState
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.ParameterizedExecutableType
-
Field Summary
Fields inherited from class org.checkerframework.checker.initialization.InitializationParentAnnotatedTypeFactory
assumeInitialized, FBCBOTTOM, INITIALIZED, NOT_ONLY_INITIALIZED, objectTypeMirror, POLY_INITIALIZED, UNDER_INITALIZATION, underInitializationValueElement, UNKNOWN_INITIALIZATION, unknownInitializationValueElement, unusedWhenElement
Fields inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
analysis, arraysAreRelevant, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotator
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, viewpointAdapter
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new InitializationAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected InitializationAnalysis
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.Returns the checker associated with this factory.getExceptionalExitStore
(Tree tree) Returns the exceptional exit store for a method or another code block (such as static initializers).Gets the factory of theInitializationFieldAccessSubchecker
, whose flow-analysis results we reuse to avoid performing the same flow analysis twice.getRegularExitStore
(Tree tree) Returns the regular exit store for a method or another code block (such as static initializers).List
<org.plumelib.util.IPair<ReturnNode, TransferResult<CFValue, InitializationStore>>> getReturnStatementStores
(MethodTree methodTree) Returns a list of all return statements ofmethod
paired with their correspondingTransferResult
.getUninitializedFields
(InitializationStore initStore, CFAbstractStore<?, ?> targetStore, TreePath path, boolean isStatic, Collection<? extends AnnotationMirror> receiverAnnotations) Returns the fields that are not yet initialized in a given store, taking into account the target checker.static boolean
isInitialized
(GenericAnnotatedTypeFactory<?, ?, ?, ?> factory, CFAbstractValue<?> value, VariableElement var) Determines whether the specified variable's current value is initialized.protected void
performFlowAnalysis
(ClassTree classTree) Perform a org.checkerframework.dataflow analysis over a single class tree and its nested classes.Methods inherited from class org.checkerframework.checker.initialization.InitializationParentAnnotatedTypeFactory
areAllFieldsInitializedOnly, createFlowTransferFunction, createQualifierHierarchy, createSupportedTypeQualifiers, createTreeAnnotator, createTypeAnnotator, createUnderInitializationAnnotation, createUnderInitializationAnnotation, createUnknownInitializationAnnotation, createUnknownInitializationAnnotation, getInitializedFields, getSelfType, getTypeFrameFromAnnotation, getUnderInitializationAnnotationOfSuperType, getUninitializedFields, isFbcBottom, isFbcBottom, isImmutable, isInitialized, isInitialized, isInitializedForFrame, isNotFullyInitializedReceiver, isUnderInitialization, isUnderInitialization, isUnknownInitialization, isUnknownInitialization, isUnused, postAsMemberOf, setSelfTypeInInitializationCode, shouldWarnIfStubRedundantWithBytecode
Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, getAnnotatedTypeBefore, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getResultingTypeOfConstructorMemberReference, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isComputingAnnotatedTypeMirrorOfLhs, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, postAnalyze, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
adaptGetClassReturnTypeToReceiver, addAliasedDeclAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, createViewpointAdapter, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, fromNewClass, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationOrTypeDeclarationBound, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorTreePath, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeReflectionResolution, isFromByteCode, isFromStubFile, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setPathForArtificialTree, setVisitorTreePath, toAnnotatedType, toString, type
-
Constructor Details
-
InitializationAnnotatedTypeFactory
Create a new InitializationAnnotatedTypeFactory.- Parameters:
checker
- the checker to which the new type factory belongs
-
-
Method Details
-
getChecker
Description copied from class:AnnotatedTypeFactory
Returns the checker associated with this factory.- Overrides:
getChecker
in classAnnotatedTypeFactory
- Returns:
- the checker associated with this factory
-
getFieldAccessFactory
Gets the factory of theInitializationFieldAccessSubchecker
, whose flow-analysis results we reuse to avoid performing the same flow analysis twice.If type checking has not yet started, the subcheckers are uninitialized, and this returns
null
. More concretely, this method only returns a non-null value afterSourceChecker.initChecker()
has been called on all subcheckers. Since the flow analysis is initialized inAnnotatedTypeFactory.postInit()
, and the type factory is created after all subcheckers have been initialized, this method will always return a non-null value unless a subclass attempts to use it for some purpose other than accessing the flow analysis.- Returns:
- the factory of the
InitializationFieldAccessSubchecker
, ornull
if not yet initialized - See Also:
-
createFlowAnalysis
Description copied from class:GenericAnnotatedTypeFactory
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.This implementation uses the checker naming convention to create the appropriate analysis. If no transfer function is found, it returns an instance of
CFAnalysis
.Subclasses have to override this method to create the appropriate analysis if they do not follow the checker naming convention.
- Overrides:
createFlowAnalysis
in classGenericAnnotatedTypeFactory<CFValue,
InitializationStore, InitializationTransfer, InitializationAnalysis> - Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
performFlowAnalysis
Description copied from class:GenericAnnotatedTypeFactory
Perform a org.checkerframework.dataflow analysis over a single class tree and its nested classes.- Overrides:
performFlowAnalysis
in classGenericAnnotatedTypeFactory<CFValue,
InitializationStore, InitializationTransfer, InitializationAnalysis> - Parameters:
classTree
- the class to analyze
-
getRegularExitStore
Description copied from class:GenericAnnotatedTypeFactory
Returns the regular exit store for a method or another code block (such as static initializers). Returnsnull
if there is no such store. This can happen because the method cannot exit through the regular exit block, or it is abstract or in an interface.- Overrides:
getRegularExitStore
in classGenericAnnotatedTypeFactory<CFValue,
InitializationStore, InitializationTransfer, InitializationAnalysis> - Parameters:
tree
- a MethodTree or other code block, such as a static initializer- Returns:
- the regular exit store, or
null
-
getExceptionalExitStore
Description copied from class:GenericAnnotatedTypeFactory
Returns the exceptional exit store for a method or another code block (such as static initializers).- Overrides:
getExceptionalExitStore
in classGenericAnnotatedTypeFactory<CFValue,
InitializationStore, InitializationTransfer, InitializationAnalysis> - Parameters:
tree
- a MethodTree or other code block, such as a static initializer- Returns:
- the exceptional exit store, or
null
, if there is no such store
-
getReturnStatementStores
public List<org.plumelib.util.IPair<ReturnNode,TransferResult<CFValue, getReturnStatementStoresInitializationStore>>> (MethodTree methodTree) Description copied from class:GenericAnnotatedTypeFactory
Returns a list of all return statements ofmethod
paired with their correspondingTransferResult
. Ifmethod
has no return statement, then the empty list is returned.- Overrides:
getReturnStatementStores
in classGenericAnnotatedTypeFactory<CFValue,
InitializationStore, InitializationTransfer, InitializationAnalysis> - Parameters:
methodTree
- method whose return statements should be returned- Returns:
- a list of all return statements of
method
paired with their correspondingTransferResult
or an empty list ifmethod
has no return statements
-
getUninitializedFields
public List<VariableTree> getUninitializedFields(InitializationStore initStore, CFAbstractStore<?, ?> targetStore, TreePath path, boolean isStatic, Collection<? extends AnnotationMirror> receiverAnnotations) Returns the fields that are not yet initialized in a given store, taking into account the target checker.A field f is initialized if
- f is initialized in the initialization store, i.e., it has been assigned;
- the value of f in the target store has a non-top qualifier that does not have the
meta-annotation
HoldsForDefaultValue
; or - the declared qualifier of f in the target hierarchy either has the meta-annotation
HoldsForDefaultValue
or is a top qualifier.
See
InitializationParentAnnotatedTypeFactory.getUninitializedFields(InitializationStore, TreePath, boolean, Collection)
for a method that does not require the target checker.- Parameters:
initStore
- a store for the initialization checkertargetStore
- a store for the target checker corresponding to initStorepath
- the current path, used to determine the current classisStatic
- whether to report static fields or instance fieldsreceiverAnnotations
- the annotations on the receiver- Returns:
- the fields that are not yet initialized in a given store
-
isInitialized
public static boolean isInitialized(GenericAnnotatedTypeFactory<?, ?, ?, ?> factory, CFAbstractValue<?> value, VariableElement var) Determines whether the specified variable's current value is initialized.Returns
true
iff the variable's current value is initialized. This holds for variables whose value has a non-top qualifier that does not have the meta-annotationHoldsForDefaultValue
(e.g., variables with aNonNull
value), as well as variables whose declaration has a qualifier that has the meta-annotationHoldsForDefaultValue
(e.g., variables whose declared type isNullable
).- Parameters:
factory
- the parent checker's factoryvalue
- the variable's current valuevar
- the variable to check- Returns:
- whether the specified variable is yet to be initialized
-