public abstract class InitializationAnnotatedTypeFactory<Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>,Transfer extends InitializationTransfer<Value,Transfer,Store>,Flow extends CFAbstractAnalysis<Value,Store,Transfer>> extends GenericAnnotatedTypeFactory<Value,Store,Transfer,Flow>
NullnessChecker.| Modifier and Type | Class and Description |
|---|---|
protected class |
InitializationAnnotatedTypeFactory.CommitmentTreeAnnotator |
protected class |
InitializationAnnotatedTypeFactory.CommitmentTypeAnnotator |
protected class |
InitializationAnnotatedTypeFactory.InitializationQualifierHierarchy
The
QualifierHierarchy for the initialization type system. |
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
protected AnnotationMirror |
FBCBOTTOM
|
protected Set<String> |
initAnnoNames
String representation of all initialization annotations.
|
protected Set<Class<? extends Annotation>> |
initAnnos
Cache for the initialization annotations.
|
protected AnnotationMirror |
INITIALIZED
|
protected AnnotationMirror |
NOT_ONLY_INITIALIZED
NotOnlyInitialized or null. |
protected TypeMirror |
objectTypeMirror
The java.lang.Object type.
|
protected AnnotationMirror |
UNDER_INITALIZATION
UnderInitialization or null. |
protected ExecutableElement |
underInitializationValueElement
The UnderInitialization.value field/element.
|
protected AnnotationMirror |
UNKNOWN_INITIALIZATION
|
protected ExecutableElement |
unknownInitializationValueElement
The UnknownInitialization.value field/element.
|
protected ExecutableElement |
unusedWhenElement
The Unused.when field/element.
|
analysis, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorajavaTypes, artificialTreeToEnclosingElementMap, checker, currentFileAjavaTypes, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState, wpiOutputFormat| Modifier | Constructor and Description |
|---|---|
protected |
InitializationAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new InitializationAnnotatedTypeFactory.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
areAllFieldsInitializedOnly(ClassTree classTree)
Are all fields initialized-only?
|
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
protected TypeAnnotator |
createTypeAnnotator()
Returns a
DefaultForTypeAnnotator that adds annotations to a type based on the content
of the type itself. |
AnnotationMirror |
createUnderInitializationAnnotation(Class<?> typeFrame)
Creates a
UnderInitialization annotation with the given type frame. |
AnnotationMirror |
createUnderInitializationAnnotation(TypeMirror typeFrame)
Creates a
UnderInitialization annotation with the given type as its type frame
argument. |
AnnotationMirror |
createUnknownInitializationAnnotation(Class<?> typeFrame)
Creates a
UnknownInitialization annotation with a given type frame. |
AnnotationMirror |
createUnknownInitializationAnnotation(TypeMirror typeFrame)
Creates an
UnknownInitialization annotation with a given type frame. |
AnnotatedTypeMirror |
getAnnotatedTypeLhs(Tree lhsTree)
Returns the type of a left-hand side of an assignment.
|
abstract AnnotationMirror |
getFieldInvariantAnnotation()
Returns the annotation that makes up the invariant of this commitment type system, such as
@NonNull. |
Set<Class<? extends Annotation>> |
getInitializationAnnotations() |
List<VariableTree> |
getInitializedInvariantFields(Store store,
TreePath path)
Returns the fields that have the invariant annotation and are initialized in a given store.
|
Set<Class<? extends Annotation>> |
getInvalidConstructorReturnTypeAnnotations()
Returns the list of annotations that is forbidden for the constructor return type.
|
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(Tree tree)
Returns the type of
this at the location of tree. |
TypeMirror |
getTypeFrameFromAnnotation(AnnotationMirror annotation)
Returns the type frame (that is, the argument) of a given initialization annotation.
|
protected AnnotationMirror |
getUnderInitializationAnnotationOfSuperType(TypeMirror type)
Returns an
UnderInitialization annotation that has the superclass of type as
type frame. |
Pair<List<VariableTree>,List<VariableTree>> |
getUninitializedFields(Store store,
TreePath path,
boolean isStatic,
Collection<? extends AnnotationMirror> receiverAnnotations)
Returns the fields that are not yet initialized in a given store.
|
List<VariableTree> |
getUninitializedInvariantFields(Store store,
TreePath path,
boolean isStatic,
List<? extends AnnotationMirror> receiverAnnotations)
Returns the fields that have the invariant annotation and are not yet initialized in a given
store.
|
protected abstract boolean |
hasFieldInvariantAnnotation(AnnotatedTypeMirror type,
VariableElement fieldElement)
Returns whether or not
type has the invariant annotation. |
protected boolean |
hasFieldInvariantAnnotation(VariableTree field)
Returns whether or not
field has the invariant annotation. |
boolean |
isFbcBottom(AnnotatedTypeMirror anno)
Does
anno have the bottom annotation? |
boolean |
isFbcBottom(AnnotationMirror anno)
Is
anno the bottom annotation? |
protected boolean |
isInitializationAnnotation(AnnotationMirror anno)
Is the annotation
anno an initialization qualifier? |
boolean |
isInitialized(AnnotatedTypeMirror anno)
Does
anno have the annotation Initialized? |
boolean |
isInitialized(AnnotationMirror anno)
Is
anno the Initialized annotation? |
boolean |
isInitializedForFrame(AnnotatedTypeMirror type,
TypeMirror frame)
Return true if the type is initialized with respect to the given frame -- that is, all of the
fields of the frame are initialized.
|
boolean |
isUnderInitialization(AnnotatedTypeMirror anno)
Does
anno have the annotation UnderInitialization (with any type frame)? |
boolean |
isUnderInitialization(AnnotationMirror anno)
Is
anno the UnderInitialization annotation (with any type frame)? |
boolean |
isUnknownInitialization(AnnotatedTypeMirror anno)
Does
anno have the annotation UnknownInitialization (with any type frame)? |
boolean |
isUnknownInitialization(AnnotationMirror anno)
Is
anno the UnknownInitialization annotation (with any type frame)? |
void |
postAsMemberOf(AnnotatedTypeMirror type,
AnnotatedTypeMirror owner,
Element element)
A callback method for the AnnotatedTypeFactory subtypes to customize
AnnotatedTypes.asMemberOf().
|
protected void |
setSelfTypeInInitializationCode(Tree tree,
AnnotatedTypeMirror.AnnotatedDeclaredType selfType,
TreePath path)
Side-effects argument
selfType to make it @Initialized or @UnderInitialization,
depending on whether all fields have been set. |
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowAnalysis, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, fromNewClass, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, isRelevant, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchyWithMultiGraphFactory, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getChecker, getCheckerNames, getContractExpressions, getContractListValues, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingType, 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, getVisitorState, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isFromByteCode, isFromStubFile, isImmutable, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, negateConstant, order, parseAnnotationFiles, postProcessClassTree, postTypeVarSubstitution, prepareMethodForWriting, prepareMethodForWriting, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonFieldprotected final AnnotationMirror UNKNOWN_INITIALIZATION
protected final AnnotationMirror INITIALIZED
protected final AnnotationMirror UNDER_INITALIZATION
UnderInitialization or null.protected final AnnotationMirror NOT_ONLY_INITIALIZED
NotOnlyInitialized or null.protected final AnnotationMirror FBCBOTTOM
protected final TypeMirror objectTypeMirror
protected final ExecutableElement unusedWhenElement
protected final ExecutableElement underInitializationValueElement
protected final ExecutableElement unknownInitializationValueElement
protected final Set<Class<? extends Annotation>> initAnnos
protected final Set<String> initAnnoNames
UnknownInitialization UnderInitialization Initialized FBCBottom
This is used to quickly check of an AnnotationMirror is one of the initialization annotations without having to repeatedly convert them to strings.
protected InitializationAnnotatedTypeFactory(BaseTypeChecker checker)
checker - the checker to which the new type factory belongspublic Set<Class<? extends Annotation>> getInitializationAnnotations()
protected boolean isInitializationAnnotation(AnnotationMirror anno)
anno an initialization qualifier?anno - the annotation to checkpublic Set<Class<? extends Annotation>> getInvalidConstructorReturnTypeAnnotations()
public abstract AnnotationMirror getFieldInvariantAnnotation()
@NonNull.protected final boolean hasFieldInvariantAnnotation(VariableTree field)
field has the invariant annotation.
This method is a convenience method for hasFieldInvariantAnnotation(AnnotatedTypeMirror, VariableElement).
If the field is a type variable, this method returns true if any possible
instantiation of the type parameter could have the invariant annotation. See hasFieldInvariantAnnotation(VariableTree) for an example.
field - field that might have invariant annotationprotected abstract boolean hasFieldInvariantAnnotation(AnnotatedTypeMirror type, VariableElement fieldElement)
type has the invariant annotation.
If the type is a type variable, this method returns true if any possible
instantiation of the type parameter could have the invariant annotation. See hasFieldInvariantAnnotation(VariableTree) for an example.
type - of field that might have invariant annotationfieldElement - the field element, which can be used to check annotations on the
declarationpublic AnnotationMirror createUnderInitializationAnnotation(TypeMirror typeFrame)
UnderInitialization annotation with the given type as its type frame
argument.typeFrame - the type down to which some value has been initializedUnderInitialization annotation with the given argumentpublic AnnotationMirror createUnderInitializationAnnotation(Class<?> typeFrame)
UnderInitialization annotation with the given type frame.typeFrame - the type down to which some value has been initializedUnderInitialization annotation with the given argumentpublic AnnotationMirror createUnknownInitializationAnnotation(Class<?> typeFrame)
UnknownInitialization annotation with a given type frame.typeFrame - the type down to which some value has been initializedUnknownInitialization annotation with the given argumentpublic AnnotationMirror createUnknownInitializationAnnotation(TypeMirror typeFrame)
UnknownInitialization annotation with a given type frame.typeFrame - the type down to which some value has been initializedUnknownInitialization annotation with the given argumentpublic TypeMirror getTypeFrameFromAnnotation(AnnotationMirror annotation)
annotation - a UnderInitialization or UnknownInitialization annotationpublic boolean isUnderInitialization(AnnotationMirror anno)
anno the UnderInitialization annotation (with any type frame)?anno - the annotation to checkanno is UnderInitializationpublic boolean isUnknownInitialization(AnnotationMirror anno)
anno the UnknownInitialization annotation (with any type frame)?anno - the annotation to checkanno is UnknownInitializationpublic boolean isFbcBottom(AnnotationMirror anno)
anno the bottom annotation?anno - the annotation to checkanno is FBCBottompublic boolean isInitialized(AnnotationMirror anno)
anno the Initialized annotation?anno - the annotation to checkanno is Initializedpublic boolean isUnderInitialization(AnnotatedTypeMirror anno)
anno have the annotation UnderInitialization (with any type frame)?anno - the annotation to checkanno has UnderInitializationpublic boolean isUnknownInitialization(AnnotatedTypeMirror anno)
anno have the annotation UnknownInitialization (with any type frame)?anno - the annotation to checkanno has UnknownInitializationpublic boolean isFbcBottom(AnnotatedTypeMirror anno)
anno have the bottom annotation?anno - the annotation to checkanno has FBCBottompublic boolean isInitialized(AnnotatedTypeMirror anno)
anno have the annotation Initialized?anno - the annotation to checkanno has Initializedprotected boolean areAllFieldsInitializedOnly(ClassTree classTree)
classTree - the class to querypublic void postAsMemberOf(AnnotatedTypeMirror type, AnnotatedTypeMirror owner, Element element)
In most cases, subclasses want to call this method first because it may clear all annotations and use the hierarchy's root annotations.
postAsMemberOf in class GenericAnnotatedTypeFactory<Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>,Transfer extends InitializationTransfer<Value,Transfer,Store>,Flow extends CFAbstractAnalysis<Value,Store,Transfer>>type - the annotated type of the elementowner - the annotated type of the receiver of the accessing treeelement - the element of the field or methodpublic AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree)
GenericAnnotatedTypeFactoryThe default implementation returns the type without considering dataflow type refinement. Subclass can override this method and add additional logic for computing the type of a LHS.
getAnnotatedTypeLhs in class GenericAnnotatedTypeFactory<Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>,Transfer extends InitializationTransfer<Value,Transfer,Store>,Flow extends CFAbstractAnalysis<Value,Store,Transfer>>lhsTree - left-hand side of an assignmentlhsTreepublic AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(Tree tree)
AnnotatedTypeFactorythis at the location of tree. Returns null if
tree is in a location where this has no meaning, such as the body of a static
method.
The parameter is an arbitrary tree and does not have to mention "this", neither explicitly nor implicitly. This method can be overridden for type-system specific behavior.
getSelfType in class AnnotatedTypeFactorytree - location used to decide the type of thisthis at the location of treeprotected void setSelfTypeInInitializationCode(Tree tree, AnnotatedTypeMirror.AnnotatedDeclaredType selfType, TreePath path)
selfType to make it @Initialized or @UnderInitialization,
depending on whether all fields have been set.tree - a treeselfType - the type to side-effectpath - a pathprotected AnnotationMirror getUnderInitializationAnnotationOfSuperType(TypeMirror type)
UnderInitialization annotation that has the superclass of type as
type frame.type - a typeUnderInitialization for the supertype of typepublic Pair<List<VariableTree>,List<VariableTree>> getUninitializedFields(Store store, TreePath path, boolean isStatic, Collection<? extends AnnotationMirror> receiverAnnotations)
store - a storepath - the current path, used to determine the current classisStatic - whether to report static fields or instance fieldsreceiverAnnotations - the annotations on the receiverpublic final List<VariableTree> getUninitializedInvariantFields(Store store, TreePath path, boolean isStatic, List<? extends AnnotationMirror> receiverAnnotations)
store - a storepath - the current path, used to determine the current classisStatic - whether to report static fields or instance fieldsreceiverAnnotations - the annotations on the receiverpublic List<VariableTree> getInitializedInvariantFields(Store store, TreePath path)
store - a storepath - the current path; used to compute the current classpublic boolean isInitializedForFrame(AnnotatedTypeMirror type, TypeMirror frame)
type - the type whose initialization type qualifiers to checkframe - a class in type's class hierarchyprotected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactoryDefaultForTypeAnnotator that adds annotations to a type based on the content
of the type itself.
Subclass may override this method. The default type annotator is a ListTypeAnnotator
of the following:
IrrelevantTypeAnnotator: Adds top to types not listed in the @RelevantJavaTypes annotation on the checker.
PropagationTypeAnnotator: Propagates annotation onto wildcards.
createTypeAnnotator in class GenericAnnotatedTypeFactory<Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>,Transfer extends InitializationTransfer<Value,Transfer,Store>,Flow extends CFAbstractAnalysis<Value,Store,Transfer>>protected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactoryTreeAnnotator that adds annotations to a type based on the contents of a
tree.
The default tree annotator is a ListTreeAnnotator of the following:
PropagationTreeAnnotator: Propagates annotations from subtrees
LiteralTreeAnnotator: Adds annotations based on QualifierForLiterals
meta-annotations
DependentTypesTreeAnnotator: Adapts dependent annotations based on context
Subclasses may override this method to specify additional tree annotators, for example:
new ListTreeAnnotator(super.createTreeAnnotator(), new KeyLookupTreeAnnotator(this));
createTreeAnnotator in class GenericAnnotatedTypeFactory<Value extends CFAbstractValue<Value>,Store extends InitializationStore<Value,Store>,Transfer extends InitializationTransfer<Value,Transfer,Store>,Flow extends CFAbstractAnalysis<Value,Store,Transfer>>