Class InitializationAnnotatedTypeFactory
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeFactory
-
- org.checkerframework.framework.type.GenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
-
- org.checkerframework.checker.initialization.InitializationParentAnnotatedTypeFactory
-
- org.checkerframework.checker.initialization.InitializationAnnotatedTypeFactory
-
- All Implemented Interfaces:
AnnotationProvider
public class InitializationAnnotatedTypeFactory extends InitializationParentAnnotatedTypeFactory
The annotated type factory for the freedom-before-commitment type system. When using the freedom-before-commitment type system as a subchecker, you must ensure that the parent checker hooks into it properly. SeeInitializationChecker
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
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
Constructors Constructor Description InitializationAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new InitializationAnnotatedTypeFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InitializationAnalysis
createFlowAnalysis()
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.InitializationChecker
getChecker()
Returns the checker associated with this factory.InitializationStore
getExceptionalExitStore(com.sun.source.tree.Tree tree)
Returns the exceptional exit store for a method or another code block (such as static initializers).protected @Nullable InitializationFieldAccessAnnotatedTypeFactory
getFieldAccessFactory()
Gets the factory of theInitializationFieldAccessSubchecker
, whose flow-analysis results we reuse to avoid performing the same flow analysis twice.InitializationStore
getRegularExitStore(com.sun.source.tree.Tree tree)
Returns the regular exit store for a method or another code block (such as static initializers).java.util.List<org.plumelib.util.IPair<ReturnNode,TransferResult<CFValue,InitializationStore>>>
getReturnStatementStores(com.sun.source.tree.MethodTree methodTree)
Returns a list of all return statements ofmethod
paired with their correspondingTransferResult
.static boolean
isInitialized(GenericAnnotatedTypeFactory<?,?,?,?> factory, CFAbstractValue<?> value, javax.lang.model.element.VariableElement var)
Determines whether the specified variable's current value is initialized.protected void
performFlowAnalysis(com.sun.source.tree.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, 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 Detail
-
InitializationAnnotatedTypeFactory
public InitializationAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new InitializationAnnotatedTypeFactory.- Parameters:
checker
- the checker to which the new type factory belongs
-
-
Method Detail
-
getChecker
public InitializationChecker 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
protected @Nullable InitializationFieldAccessAnnotatedTypeFactory 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()
,performFlowAnalysis(ClassTree)
,getRegularExitStore(Tree)
,getExceptionalExitStore(Tree)
,getReturnStatementStores(MethodTree)
-
createFlowAnalysis
protected InitializationAnalysis 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
protected void performFlowAnalysis(com.sun.source.tree.ClassTree classTree)
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
public InitializationStore getRegularExitStore(com.sun.source.tree.Tree tree)
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
public InitializationStore getExceptionalExitStore(com.sun.source.tree.Tree tree)
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 java.util.List<org.plumelib.util.IPair<ReturnNode,TransferResult<CFValue,InitializationStore>>> getReturnStatementStores(com.sun.source.tree.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
-
isInitialized
public static boolean isInitialized(GenericAnnotatedTypeFactory<?,?,?,?> factory, CFAbstractValue<?> value, javax.lang.model.element.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
-
-