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
. Also supports rawness as a type-system for tracking initialization, though FBC
is preferred.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.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected AnnotationMirror |
COMMITTED
|
protected AnnotationMirror |
FBCBOTTOM
|
protected AnnotationMirror |
FREE
UnderInitialization or null |
protected Set<Class<? extends Annotation>> |
initAnnos |
protected AnnotationMirror |
NOT_ONLY_COMMITTED
NotOnlyInitialized or null |
protected AnnotationMirror |
UNCLASSIFIED
|
protected boolean |
useFbc
Should the initialization type system be FBC? If not, the rawness type system is used for
initialization.
|
analyses, cfgVisualizer, defaults, dependentTypesHelper, FLOW_BY_DEFAULT, flowResult, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, treeAnnotator, typeAnnotator
checker, elements, fromTreeCache, loader, processingEnv, qualHierarchy, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState
Constructor and Description |
---|
InitializationAnnotatedTypeFactory(BaseTypeChecker checker,
boolean useFbc) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
areAllFieldsCommittedOnly(ClassTree classTree)
Are all fields committed-only?
|
AnnotationMirror |
createFreeAnnotation(Class<?> typeFrame)
Returns a
UnderInitialization annotation with a given type frame. |
AnnotationMirror |
createFreeAnnotation(TypeMirror typeFrame)
Returns a
UnderInitialization annotation with a given type frame. |
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
ImplicitsTypeAnnotator
that adds annotations to a type based on the content of the type itself. |
AnnotationMirror |
createUnclassifiedAnnotation(Class<?> typeFrame)
Returns a
UnknownInitialization or Raw annotation with a given type frame. |
AnnotationMirror |
createUnclassifiedAnnotation(TypeMirror typeFrame)
Returns a
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 . |
protected AnnotationMirror |
getFreeOrRawAnnotationOfSuperType(TypeMirror type)
Returns a
UnderInitialization annotation (or UnknownInitialization if rawness
is used) that has the supertype of type as type frame. |
Set<Class<? extends Annotation>> |
getInitializationAnnotations() |
List<VariableTree> |
getInitializedInvariantFields(Store store,
TreePath path)
Returns the (non-static) fields that have the invariant annotation and are initialized in a
given store.
|
Set<Class<? extends Annotation>> |
getInvalidConstructorReturnTypeAnnotations() |
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(Tree tree)
Returns the type of
this in the current location, which can be used if this
has a special semantics (e.g. |
TypeMirror |
getTypeFrameFromAnnotation(AnnotationMirror annotation)
Returns the type frame of a given annotation.
|
List<VariableTree> |
getUninitializedInvariantFields(Store store,
TreePath path,
boolean isStatic,
List<? extends AnnotationMirror> receiverAnnotations)
Returns the (non-static) fields that have the invariant annotation and are not yet
initialized in a given store.
|
boolean |
isCommitted(AnnotatedTypeMirror anno)
Does
anno have the annotation Initialized ? If useFbc is false, then
NonRaw is used in the comparison. |
boolean |
isCommitted(AnnotationMirror anno)
|
boolean |
isFbcBottom(AnnotatedTypeMirror anno)
Does
anno have the bottom annotation? |
boolean |
isFbcBottom(AnnotationMirror anno)
Is
anno the bottom annotation? |
boolean |
isFree(AnnotatedTypeMirror anno)
Does
anno have the annotation UnderInitialization (with any type frame)?
Always returns false if useFbc is false. |
boolean |
isFree(AnnotationMirror anno)
Is
anno the UnderInitialization annotation (with any type frame)? Always
returns false if useFbc is false. |
protected boolean |
isInitializationAnnotation(AnnotationMirror anno)
Is the annotation
anno an initialization qualifier? |
boolean |
isInitializedForFrame(AnnotatedTypeMirror type,
TypeMirror frame) |
boolean |
isUnclassified(AnnotatedTypeMirror anno)
Does
anno have the annotation UnknownInitialization (with any type frame)? If
useFbc is false, then Raw is used in the comparison. |
boolean |
isUnclassified(AnnotationMirror anno)
Is
anno the UnknownInitialization annotation (with any type frame)? If useFbc is false, then Raw is used in the comparison. |
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) |
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addTypeNameImplicit, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createCFGVisualizer, createDependentTypesHelper, createFlowAnalysis, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, fromNewClass, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotationFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodeForTree, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedDeclAnnotation, addInheritedAnnotation, aliasedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchy, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingMethod, getEnclosingType, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initilizeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, parseStubFiles, postProcessClassTree, postTypeVarSubstitution, setPathHack, toAnnotatedType, toString, type, widenToUpperBound
protected final AnnotationMirror UNCLASSIFIED
protected final AnnotationMirror COMMITTED
protected final AnnotationMirror FREE
UnderInitialization
or nullprotected final AnnotationMirror NOT_ONLY_COMMITTED
NotOnlyInitialized
or nullprotected final AnnotationMirror FBCBOTTOM
protected final boolean useFbc
protected final Set<Class<? extends Annotation>> initAnnos
public InitializationAnnotatedTypeFactory(BaseTypeChecker checker, boolean useFbc)
public Set<Class<? extends Annotation>> getInitializationAnnotations()
protected boolean isInitializationAnnotation(AnnotationMirror anno)
anno
an initialization qualifier?public Set<Class<? extends Annotation>> getInvalidConstructorReturnTypeAnnotations()
public abstract AnnotationMirror getFieldInvariantAnnotation()
@NonNull
.public AnnotationMirror createFreeAnnotation(TypeMirror typeFrame)
UnderInitialization
annotation with a given type frame.public AnnotationMirror createFreeAnnotation(Class<?> typeFrame)
UnderInitialization
annotation with a given type frame.public AnnotationMirror createUnclassifiedAnnotation(Class<?> typeFrame)
UnknownInitialization
or Raw
annotation with a given type frame.public AnnotationMirror createUnclassifiedAnnotation(TypeMirror typeFrame)
UnknownInitialization
annotation with a given type frame.public TypeMirror getTypeFrameFromAnnotation(AnnotationMirror annotation)
UnderInitialization
or UnknownInitialization
.public boolean isFree(AnnotationMirror anno)
anno
the UnderInitialization
annotation (with any type frame)? Always
returns false if useFbc
is false.public boolean isUnclassified(AnnotationMirror anno)
anno
the UnknownInitialization
annotation (with any type frame)? If useFbc
is false, then Raw
is used in the comparison.public boolean isFbcBottom(AnnotationMirror anno)
anno
the bottom annotation?public boolean isCommitted(AnnotationMirror anno)
public boolean isFree(AnnotatedTypeMirror anno)
anno
have the annotation UnderInitialization
(with any type frame)?
Always returns false if useFbc
is false.public boolean isUnclassified(AnnotatedTypeMirror anno)
anno
have the annotation UnknownInitialization
(with any type frame)? If
useFbc
is false, then Raw
is used in the comparison.public boolean isFbcBottom(AnnotatedTypeMirror anno)
anno
have the bottom annotation?public boolean isCommitted(AnnotatedTypeMirror anno)
anno
have the annotation Initialized
? If useFbc
is false, then
NonRaw
is used in the comparison.protected MultiGraphQualifierHierarchy.MultiGraphFactory createQualifierHierarchyFactory()
AnnotatedTypeFactory
createQualifierHierarchyFactory
in class AnnotatedTypeFactory
protected boolean areAllFieldsCommittedOnly(ClassTree classTree)
public 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 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(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(Tree tree)
AnnotatedTypeFactory
this
in the current 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(Tree tree, AnnotatedTypeMirror.AnnotatedDeclaredType selfType, TreePath path)
protected AnnotationMirror getFreeOrRawAnnotationOfSuperType(TypeMirror type)
UnderInitialization
annotation (or UnknownInitialization
if rawness
is used) that has the supertype of type
as type frame.public List<VariableTree> getUninitializedInvariantFields(Store store, TreePath path, boolean isStatic, List<? extends AnnotationMirror> receiverAnnotations)
public List<VariableTree> getInitializedInvariantFields(Store store, TreePath path)
public boolean isInitializedForFrame(AnnotatedTypeMirror type, TypeMirror frame)
protected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactory
ImplicitsTypeAnnotator
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
ImplicitsTypeAnnotator
: Adds annotations based on ImplicitFor
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.
Subclasses may override this method to specify a more appropriate TreeAnnotator
.
The default tree annotator is a ListTreeAnnotator
of the following:
PropagationTreeAnnotator
: Propagates annotations from subtrees.
ImplicitsTreeAnnotator
: Adds annotations based on ImplicitFor
meta-annotations
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>>