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.ScanState
AnnotatedTypeFactory.ParameterizedExecutableType
Modifier and Type | Field and Description |
---|---|
protected javax.lang.model.element.AnnotationMirror |
FBCBOTTOM
|
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
initAnnos
Cache for the initialization annotations.
|
protected javax.lang.model.element.AnnotationMirror |
INITIALIZED
|
protected javax.lang.model.element.AnnotationMirror |
NOT_ONLY_INITIALIZED
NotOnlyInitialized or null. |
protected javax.lang.model.element.AnnotationMirror |
UNDER_INITALIZATION
UnderInitialization or null. |
protected javax.lang.model.element.AnnotationMirror |
UNKNOWN_INITIALIZATION
|
analysis, cfgVisualizer, defaults, dependentTypesHelper, emptyStore, flowByDefault, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, transfer, treeAnnotator, typeAnnotator
checker, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState
Constructor and Description |
---|
InitializationAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new InitializationAnnotatedTypeFactory.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
areAllFieldsCommittedOnly(com.sun.source.tree.ClassTree classTree)
Are all fields committed-only?
|
javax.lang.model.element.AnnotationMirror |
createFreeAnnotation(java.lang.Class<?> typeFrame)
Creates a
UnderInitialization annotation with the given type frame. |
javax.lang.model.element.AnnotationMirror |
createFreeAnnotation(javax.lang.model.type.TypeMirror typeFrame)
Creates a
UnderInitialization annotation with the given type as its type frame
argument. |
protected MultiGraphQualifierHierarchy.MultiGraphFactory |
createQualifierHierarchyFactory()
Factory method to easily change what Factory is used to create a QualifierHierarchy.
|
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. |
javax.lang.model.element.AnnotationMirror |
createUnclassifiedAnnotation(java.lang.Class<?> typeFrame)
Creates a
UnknownInitialization annotation with a given type frame. |
javax.lang.model.element.AnnotationMirror |
createUnclassifiedAnnotation(javax.lang.model.type.TypeMirror typeFrame)
Creates an
UnknownInitialization annotation with a given type frame. |
AnnotatedTypeMirror |
getAnnotatedTypeLhs(com.sun.source.tree.Tree lhsTree)
Returns the type of a left-hand side of an assignment.
|
abstract javax.lang.model.element.AnnotationMirror |
getFieldInvariantAnnotation()
Returns the annotation that makes up the invariant of this commitment type system, such as
@NonNull . |
protected javax.lang.model.element.AnnotationMirror |
getFreeOrRawAnnotationOfSuperType(javax.lang.model.type.TypeMirror type)
Returns a
UnderInitialization annotation that has the superclass of type as
type frame. |
java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
getInitializationAnnotations() |
java.util.List<com.sun.source.tree.VariableTree> |
getInitializedInvariantFields(Store store,
com.sun.source.util.TreePath path)
Returns the (non-static) fields that have the invariant annotation and are initialized in a
given store.
|
java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
getInvalidConstructorReturnTypeAnnotations() |
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(com.sun.source.tree.Tree tree)
Returns the type of
this in the given location, which can be used if this has
a special semantics (e.g. |
javax.lang.model.type.TypeMirror |
getTypeFrameFromAnnotation(javax.lang.model.element.AnnotationMirror annotation)
Returns the type frame (that is, the argument) of a given initialization annotation.
|
java.util.List<com.sun.source.tree.VariableTree> |
getUninitializedInvariantFields(Store store,
com.sun.source.util.TreePath path,
boolean isStatic,
java.util.List<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
Returns the (non-static) fields that have the invariant annotation and are not yet
initialized in a given store.
|
protected abstract boolean |
hasFieldInvariantAnnotation(AnnotatedTypeMirror type)
Returns whether or not
type has the invariant annotation. |
protected boolean |
hasFieldInvariantAnnotation(com.sun.source.tree.VariableTree field)
Returns whether or not
field has the invariant annotation. |
boolean |
isCommitted(AnnotatedTypeMirror anno)
Does
anno have the annotation Initialized ? |
boolean |
isCommitted(javax.lang.model.element.AnnotationMirror anno)
Is
anno the Initialized annotation? |
boolean |
isFbcBottom(AnnotatedTypeMirror anno)
Does
anno have the bottom annotation? |
boolean |
isFbcBottom(javax.lang.model.element.AnnotationMirror anno)
Is
anno the bottom annotation? |
boolean |
isFree(AnnotatedTypeMirror anno)
Does
anno have the annotation UnderInitialization (with any type frame)? |
boolean |
isFree(javax.lang.model.element.AnnotationMirror anno)
Is
anno the UnderInitialization annotation (with any type frame)? |
protected boolean |
isInitializationAnnotation(javax.lang.model.element.AnnotationMirror anno)
Is the annotation
anno an initialization qualifier? |
boolean |
isInitializedForFrame(AnnotatedTypeMirror type,
javax.lang.model.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 |
isUnclassified(AnnotatedTypeMirror anno)
Does
anno have the annotation UnknownInitialization (with any type frame)? |
boolean |
isUnclassified(javax.lang.model.element.AnnotationMirror anno)
Is
anno the UnknownInitialization annotation (with any type frame)? |
void |
postAsMemberOf(AnnotatedTypeMirror type,
AnnotatedTypeMirror owner,
javax.lang.model.element.Element element)
A callback method for the AnnotatedTypeFactory subtypes to customize
AnnotatedTypes.asMemberOf().
|
protected void |
setSelfTypeInInitializationCode(com.sun.source.tree.Tree tree,
AnnotatedTypeMirror.AnnotatedDeclaredType selfType,
com.sun.source.util.TreePath path)
Side-effects argument
selfType to make it @Initialized or @UnderInitialization,
depending on whether all fields have been set. |
addAnnotationsFromDefaultQualifierForUse, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowAnalysis, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, fromNewClass, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getAnnotationMirrorFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getReceiverAndOffsetFromJavaExpressionString, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, canonicalAnnotation, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchy, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getCacheSize, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initializeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, negateConstant, parseStubFiles, postProcessClassTree, postTypeVarSubstitution, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, widenToUpperBound
protected final javax.lang.model.element.AnnotationMirror UNKNOWN_INITIALIZATION
protected final javax.lang.model.element.AnnotationMirror INITIALIZED
protected final javax.lang.model.element.AnnotationMirror UNDER_INITALIZATION
UnderInitialization
or null.protected final javax.lang.model.element.AnnotationMirror NOT_ONLY_INITIALIZED
NotOnlyInitialized
or null.protected final javax.lang.model.element.AnnotationMirror FBCBOTTOM
protected final java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> initAnnos
public InitializationAnnotatedTypeFactory(BaseTypeChecker checker)
checker
- the checker to which the new type factory belongspublic java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> getInitializationAnnotations()
protected boolean isInitializationAnnotation(javax.lang.model.element.AnnotationMirror anno)
anno
an initialization qualifier?anno
- the annotation to checkpublic java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> getInvalidConstructorReturnTypeAnnotations()
public abstract javax.lang.model.element.AnnotationMirror getFieldInvariantAnnotation()
@NonNull
.protected final boolean hasFieldInvariantAnnotation(com.sun.source.tree.VariableTree field)
field
has the invariant annotation.
This method is a convenience method for hasFieldInvariantAnnotation(AnnotatedTypeMirror)
.
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)
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 annotationpublic javax.lang.model.element.AnnotationMirror createFreeAnnotation(javax.lang.model.type.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 javax.lang.model.element.AnnotationMirror createFreeAnnotation(java.lang.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 javax.lang.model.element.AnnotationMirror createUnclassifiedAnnotation(java.lang.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 javax.lang.model.element.AnnotationMirror createUnclassifiedAnnotation(javax.lang.model.type.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 javax.lang.model.type.TypeMirror getTypeFrameFromAnnotation(javax.lang.model.element.AnnotationMirror annotation)
annotation
- a UnderInitialization
or UnknownInitialization
annotationpublic boolean isFree(javax.lang.model.element.AnnotationMirror anno)
anno
the UnderInitialization
annotation (with any type frame)?anno
- the annotation to checkanno
is UnderInitialization
public boolean isUnclassified(javax.lang.model.element.AnnotationMirror anno)
anno
the UnknownInitialization
annotation (with any type frame)?anno
- the annotation to checkanno
is UnknownInitialization
public boolean isFbcBottom(javax.lang.model.element.AnnotationMirror anno)
anno
the bottom annotation?anno
- the annotation to checkanno
is FBCBottom
public boolean isCommitted(javax.lang.model.element.AnnotationMirror anno)
anno
the Initialized
annotation?anno
- the annotation to checkanno
is Initialized
public boolean isFree(AnnotatedTypeMirror anno)
anno
have the annotation UnderInitialization
(with any type frame)?anno
- the annotation to checkanno
has UnderInitialization
public boolean isUnclassified(AnnotatedTypeMirror anno)
anno
have the annotation UnknownInitialization
(with any type frame)?anno
- the annotation to checkanno
has UnknownInitialization
public boolean isFbcBottom(AnnotatedTypeMirror anno)
anno
have the bottom annotation?anno
- the annotation to checkanno
has FBCBottom
public boolean isCommitted(AnnotatedTypeMirror anno)
anno
have the annotation Initialized
?anno
- the annotation to checkanno
has Initialized
protected MultiGraphQualifierHierarchy.MultiGraphFactory createQualifierHierarchyFactory()
AnnotatedTypeFactory
createQualifierHierarchyFactory
in class AnnotatedTypeFactory
protected boolean areAllFieldsCommittedOnly(com.sun.source.tree.ClassTree classTree)
public void postAsMemberOf(AnnotatedTypeMirror type, AnnotatedTypeMirror owner, javax.lang.model.element.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 AnnotatedTypeFactory
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(com.sun.source.tree.Tree lhsTree)
GenericAnnotatedTypeFactory
The 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 assignmentlhsTree
public AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(com.sun.source.tree.Tree tree)
AnnotatedTypeFactory
this
in the given location, which can be used if this
has
a special semantics (e.g. this
is non-null).
The parameter is an arbitrary tree and does not have to mention "this", neither explicitly nor implicitly. This method should be overridden for type-system specific behavior.
TODO: in 1.8.2, handle all receiver type annotations. TODO: handle enclosing classes correctly.
getSelfType
in class AnnotatedTypeFactory
protected void setSelfTypeInInitializationCode(com.sun.source.tree.Tree tree, AnnotatedTypeMirror.AnnotatedDeclaredType selfType, com.sun.source.util.TreePath path)
selfType
to make it @Initialized or @UnderInitialization,
depending on whether all fields have been set.protected javax.lang.model.element.AnnotationMirror getFreeOrRawAnnotationOfSuperType(javax.lang.model.type.TypeMirror type)
UnderInitialization
annotation that has the superclass of type
as
type frame.public java.util.List<com.sun.source.tree.VariableTree> getUninitializedInvariantFields(Store store, com.sun.source.util.TreePath path, boolean isStatic, java.util.List<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
public java.util.List<com.sun.source.tree.VariableTree> getInitializedInvariantFields(Store store, com.sun.source.util.TreePath path)
public boolean isInitializedForFrame(AnnotatedTypeMirror type, javax.lang.model.type.TypeMirror frame)
type
- the type whose initialization type qualifiers to checkframe
- a class in type
's class hierarchyprotected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactory
DefaultForTypeAnnotator
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.
DefaultForTypeAnnotator
: Adds annotations based on DefaultFor
meta-annotations.
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()
GenericAnnotatedTypeFactory
TreeAnnotator
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>>