Class InitializationParentAnnotatedTypeFactory
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeFactory
-
- org.checkerframework.framework.type.GenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
-
- org.checkerframework.checker.initialization.InitializationParentAnnotatedTypeFactory
-
- All Implemented Interfaces:
AnnotationProvider
- Direct Known Subclasses:
InitializationAnnotatedTypeFactory
,InitializationFieldAccessAnnotatedTypeFactory
public abstract class InitializationParentAnnotatedTypeFactory extends GenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
Superclass forInitializationFieldAccessAnnotatedTypeFactory
andInitializationAnnotatedTypeFactory
to contain common functionality.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
InitializationParentAnnotatedTypeFactory.CommitmentTreeAnnotator
This tree annotator modifies the propagation tree annotator to add propagation rules for the freedom-before-commitment system.protected class
InitializationParentAnnotatedTypeFactory.CommitmentTypeAnnotator
This type annotator adds the correct UnderInitialization annotation to super constructors.protected class
InitializationParentAnnotatedTypeFactory.InitializationQualifierHierarchy
TheQualifierHierarchy
for the initialization type system.-
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 Modifier and Type Field Description protected javax.lang.model.element.AnnotationMirror
FBCBOTTOM
protected javax.lang.model.element.AnnotationMirror
INITIALIZED
protected javax.lang.model.element.AnnotationMirror
NOT_ONLY_INITIALIZED
NotOnlyInitialized
or null.protected javax.lang.model.type.TypeMirror
objectTypeMirror
The java.lang.Object type.protected javax.lang.model.element.AnnotationMirror
POLY_INITIALIZED
protected javax.lang.model.element.AnnotationMirror
UNDER_INITALIZATION
UnderInitialization
or null.protected javax.lang.model.element.ExecutableElement
underInitializationValueElement
The UnderInitialization.value field/element.protected javax.lang.model.element.AnnotationMirror
UNKNOWN_INITIALIZATION
protected javax.lang.model.element.ExecutableElement
unknownInitializationValueElement
The UnknownInitialization.value field/element.protected javax.lang.model.element.ExecutableElement
unusedWhenElement
The Unused.when field/element.-
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 InitializationParentAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new InitializationParentAnnotatedTypeFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
areAllFieldsInitializedOnly(com.sun.source.tree.ClassTree classTree)
Are all fields initialized-only?InitializationTransfer
createFlowTransferFunction(CFAbstractAnalysis<CFValue,InitializationStore,InitializationTransfer> analysis)
Returns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.protected QualifierHierarchy
createQualifierHierarchy()
Returns theQualifierHierarchy
to be used by this checker.protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.protected TreeAnnotator
createTreeAnnotator()
Returns aTreeAnnotator
that adds annotations to a type based on the contents of a tree.protected TypeAnnotator
createTypeAnnotator()
Returns aDefaultForTypeAnnotator
that adds annotations to a type based on the content of the type itself.javax.lang.model.element.AnnotationMirror
createUnderInitializationAnnotation(java.lang.Class<?> typeFrame)
Creates aUnderInitialization
annotation with the given type frame.javax.lang.model.element.AnnotationMirror
createUnderInitializationAnnotation(javax.lang.model.type.TypeMirror typeFrame)
Creates aUnderInitialization
annotation with the given type as its type frame argument.javax.lang.model.element.AnnotationMirror
createUnknownInitializationAnnotation(java.lang.Class<?> typeFrame)
Creates aUnknownInitialization
annotation with a given type frame.javax.lang.model.element.AnnotationMirror
createUnknownInitializationAnnotation(javax.lang.model.type.TypeMirror typeFrame)
Creates anUnknownInitialization
annotation with a given type frame.java.util.List<com.sun.source.tree.VariableTree>
getInitializedFields(InitializationStore store, com.sun.source.util.TreePath path)
Returns the fields that are initialized in the given store.@Nullable AnnotatedTypeMirror.AnnotatedDeclaredType
getSelfType(com.sun.source.tree.Tree tree)
Returns the type ofthis
at the location oftree
.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.protected javax.lang.model.element.AnnotationMirror
getUnderInitializationAnnotationOfSuperType(javax.lang.model.type.TypeMirror type)
Returns anUnderInitialization
annotation that has the superclass oftype
as type frame.java.util.List<com.sun.source.tree.VariableTree>
getUninitializedFields(InitializationStore store, com.sun.source.util.TreePath path, boolean isStatic, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
Returns the fields that are not yet initialized in a given store.boolean
isFbcBottom(javax.lang.model.element.AnnotationMirror anno)
Isanno
the bottom annotation?boolean
isFbcBottom(AnnotatedTypeMirror anno)
Doesanno
have the bottom annotation?boolean
isImmutable(javax.lang.model.type.TypeMirror type)
Returnstrue
.boolean
isInitialized(javax.lang.model.element.AnnotationMirror anno)
Isanno
theInitialized
annotation?boolean
isInitialized(AnnotatedTypeMirror anno)
Doesanno
have the annotationInitialized
?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
isNotFullyInitializedReceiver(com.sun.source.tree.MethodTree methodTree)
Returns true if the receiver of a method or constructor might not be fully initialized.boolean
isUnderInitialization(javax.lang.model.element.AnnotationMirror anno)
Isanno
theUnderInitialization
annotation (with any type frame)?boolean
isUnderInitialization(AnnotatedTypeMirror anno)
Doesanno
have the annotationUnderInitialization
(with any type frame)?boolean
isUnknownInitialization(javax.lang.model.element.AnnotationMirror anno)
Isanno
theUnknownInitialization
annotation (with any type frame)?boolean
isUnknownInitialization(AnnotatedTypeMirror anno)
Doesanno
have the annotationUnknownInitialization
(with any type frame)?protected boolean
isUnused(com.sun.source.tree.VariableTree field, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> receiverAnnos)
Returns whether the specified field is unused, given the specified annotations on the receiver.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 argumentselfType
to make it @Initialized or @UnderInitialization, depending on whether all fields have been set.boolean
shouldWarnIfStubRedundantWithBytecode()
Returnsfalse
.-
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, createFlowAnalysis, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, getAnnotatedTypeBefore, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isComputingAnnotatedTypeMirrorOfLhs, isRelevant, isRelevant, isRelevantImpl, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, 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, getChecker, 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
-
-
-
-
Field Detail
-
UNKNOWN_INITIALIZATION
protected final javax.lang.model.element.AnnotationMirror UNKNOWN_INITIALIZATION
-
INITIALIZED
protected final javax.lang.model.element.AnnotationMirror INITIALIZED
-
UNDER_INITALIZATION
protected final javax.lang.model.element.AnnotationMirror UNDER_INITALIZATION
UnderInitialization
or null.
-
NOT_ONLY_INITIALIZED
protected final javax.lang.model.element.AnnotationMirror NOT_ONLY_INITIALIZED
NotOnlyInitialized
or null.
-
POLY_INITIALIZED
protected final javax.lang.model.element.AnnotationMirror POLY_INITIALIZED
-
FBCBOTTOM
protected final javax.lang.model.element.AnnotationMirror FBCBOTTOM
-
objectTypeMirror
protected final javax.lang.model.type.TypeMirror objectTypeMirror
The java.lang.Object type.
-
unusedWhenElement
protected final javax.lang.model.element.ExecutableElement unusedWhenElement
The Unused.when field/element.
-
underInitializationValueElement
protected final javax.lang.model.element.ExecutableElement underInitializationValueElement
The UnderInitialization.value field/element.
-
unknownInitializationValueElement
protected final javax.lang.model.element.ExecutableElement unknownInitializationValueElement
The UnknownInitialization.value field/element.
-
-
Constructor Detail
-
InitializationParentAnnotatedTypeFactory
public InitializationParentAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new InitializationParentAnnotatedTypeFactory.Don't forget to call
GenericAnnotatedTypeFactory.postInit()
in the concrete subclass.- Parameters:
checker
- the checker to which the new type factory belongs
-
-
Method Detail
-
postAsMemberOf
public void postAsMemberOf(AnnotatedTypeMirror type, AnnotatedTypeMirror owner, javax.lang.model.element.Element element)
Description copied from class:AnnotatedTypeFactory
A callback method for the AnnotatedTypeFactory subtypes to customize AnnotatedTypes.asMemberOf(). Overriding methods should merely change the annotations on the subtypes, without changing the types.- Overrides:
postAsMemberOf
in classGenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
- Parameters:
type
- the annotated type of the elementowner
- the annotated type of the receiver of the accessing treeelement
- the element of the field or method
-
createSupportedTypeQualifiers
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> createSupportedTypeQualifiers()
Description copied from class:AnnotatedTypeFactory
Returns a mutable set of annotation classes that are supported by a checker.Subclasses may override this method to return a mutable set of their supported type qualifiers through one of the 5 approaches shown below.
Subclasses should not call this method; they should call
AnnotatedTypeFactory.getSupportedTypeQualifiers()
instead.By default, a checker supports all annotations located in a subdirectory called qual that's located in the same directory as the checker. Note that only annotations defined with the
@Target({ElementType.TYPE_USE})
meta-annotation (and optionally with the additional value ofElementType.TYPE_PARAMETER
, but no otherElementType
values) are automatically considered as supported annotations.To support a different set of annotations than those in the qual subdirectory, or that have other
ElementType
values, see examples below.In total, there are 5 ways to indicate annotations that are supported by a checker:
- Only support annotations located in a checker's qual directory:
This is the default behavior. Simply place those annotations within the qual directory.
- Support annotations located in a checker's qual directory and a list of
other annotations:
Place those annotations within the qual directory, and override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
by callingAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
with a varargs parameter list of the other annotations. Code example:@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return getBundledTypeQualifiers(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class); }
- Supporting only annotations that are explicitly listed: Override
AnnotatedTypeFactory.createSupportedTypeQualifiers()
and return a mutable set of the supported annotations. Code example:@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { return new HashSet<Class<? extends Annotation>>( Arrays.asList(A.class, B.class)); }
AnnotatedTypeFactory.createSupportedTypeQualifiers()
must be a fresh, mutable set. The methodsAnnotatedTypeFactory.getBundledTypeQualifiers(Class...)
must return a fresh, mutable set
- Overrides:
createSupportedTypeQualifiers
in classAnnotatedTypeFactory
- Returns:
- the type qualifiers supported this processor, or an empty set if none
- Only support annotations located in a checker's qual directory:
-
createFlowTransferFunction
public InitializationTransfer createFlowTransferFunction(CFAbstractAnalysis<CFValue,InitializationStore,InitializationTransfer> analysis)
Description copied from class:GenericAnnotatedTypeFactory
Returns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.This implementation uses the checker naming convention to create the appropriate transfer function. If no transfer function is found, it returns an instance of
CFTransfer
.Subclasses have to override this method to create the appropriate transfer function if they do not follow the checker naming convention.
- Overrides:
createFlowTransferFunction
in classGenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
- Parameters:
analysis
- a dataflow analysis- Returns:
- a new transfer function
-
isImmutable
public boolean isImmutable(javax.lang.model.type.TypeMirror type)
Returnstrue
. Initialization cannot be undone, i.e., an @Initialized object always stays @Initialized, an @UnderInitialization(A) object always stays @UnderInitialization(A) (though it may additionally become @Initialized), etc.- Overrides:
isImmutable
in classAnnotatedTypeFactory
- Parameters:
type
- type to test- Returns:
- true if the type is immutable
-
createUnderInitializationAnnotation
public javax.lang.model.element.AnnotationMirror createUnderInitializationAnnotation(javax.lang.model.type.TypeMirror typeFrame)
Creates aUnderInitialization
annotation with the given type as its type frame argument.- Parameters:
typeFrame
- the type down to which some value has been initialized- Returns:
- an
UnderInitialization
annotation with the given argument
-
getSelfType
public @Nullable AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(com.sun.source.tree.Tree tree)
Description copied from class:AnnotatedTypeFactory
Returns the type ofthis
at the location oftree
. Returnsnull
iftree
is in a location wherethis
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.
- Overrides:
getSelfType
in classAnnotatedTypeFactory
- Parameters:
tree
- location used to decide the type ofthis
- Returns:
- the type of
this
at the location oftree
-
setSelfTypeInInitializationCode
protected void setSelfTypeInInitializationCode(com.sun.source.tree.Tree tree, AnnotatedTypeMirror.AnnotatedDeclaredType selfType, com.sun.source.util.TreePath path)
Side-effects argumentselfType
to make it @Initialized or @UnderInitialization, depending on whether all fields have been set.- Parameters:
tree
- a treeselfType
- the type to side-effectpath
- a path
-
getUnderInitializationAnnotationOfSuperType
protected javax.lang.model.element.AnnotationMirror getUnderInitializationAnnotationOfSuperType(javax.lang.model.type.TypeMirror type)
Returns anUnderInitialization
annotation that has the superclass oftype
as type frame.- Parameters:
type
- a type- Returns:
- true an
UnderInitialization
for the supertype oftype
-
isUnused
protected boolean isUnused(com.sun.source.tree.VariableTree field, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> receiverAnnos)
Returns whether the specified field is unused, given the specified annotations on the receiver.- Parameters:
field
- the field to checkreceiverAnnos
- the annotations on the receiver- Returns:
- whether
field
is unused givenreceiverAnnos
-
createUnderInitializationAnnotation
public javax.lang.model.element.AnnotationMirror createUnderInitializationAnnotation(java.lang.Class<?> typeFrame)
Creates aUnderInitialization
annotation with the given type frame.- Parameters:
typeFrame
- the type down to which some value has been initialized- Returns:
- an
UnderInitialization
annotation with the given argument
-
areAllFieldsInitializedOnly
protected boolean areAllFieldsInitializedOnly(com.sun.source.tree.ClassTree classTree)
Are all fields initialized-only?- Parameters:
classTree
- the class to query- Returns:
- true if all fields are initialized-only
-
getUninitializedFields
public java.util.List<com.sun.source.tree.VariableTree> getUninitializedFields(InitializationStore store, com.sun.source.util.TreePath path, boolean isStatic, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
Returns the fields that are not yet initialized in a given store.- Parameters:
store
- a storepath
- 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
-
getInitializedFields
public java.util.List<com.sun.source.tree.VariableTree> getInitializedFields(InitializationStore store, com.sun.source.util.TreePath path)
Returns the fields that are initialized in the given store.- Parameters:
store
- a storepath
- the current path; used to compute the current class- Returns:
- the fields that are initialized in the given store
-
isNotFullyInitializedReceiver
public boolean isNotFullyInitializedReceiver(com.sun.source.tree.MethodTree methodTree)
Description copied from class:GenericAnnotatedTypeFactory
Returns true if the receiver of a method or constructor might not be fully initialized.- Overrides:
isNotFullyInitializedReceiver
in classGenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
- Parameters:
methodTree
- the declaration of the method or constructor- Returns:
- true if the receiver of a method or constructor might not be fully initialized
-
createUnknownInitializationAnnotation
public javax.lang.model.element.AnnotationMirror createUnknownInitializationAnnotation(java.lang.Class<?> typeFrame)
Creates aUnknownInitialization
annotation with a given type frame.- Parameters:
typeFrame
- the type down to which some value has been initialized- Returns:
- an
UnknownInitialization
annotation with the given argument
-
createUnknownInitializationAnnotation
public javax.lang.model.element.AnnotationMirror createUnknownInitializationAnnotation(javax.lang.model.type.TypeMirror typeFrame)
Creates anUnknownInitialization
annotation with a given type frame.- Parameters:
typeFrame
- the type down to which some value has been initialized- Returns:
- an
UnknownInitialization
annotation with the given argument
-
isUnderInitialization
public boolean isUnderInitialization(javax.lang.model.element.AnnotationMirror anno)
Isanno
theUnderInitialization
annotation (with any type frame)?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
isUnderInitialization
-
isUnknownInitialization
public boolean isUnknownInitialization(javax.lang.model.element.AnnotationMirror anno)
Isanno
theUnknownInitialization
annotation (with any type frame)?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
isUnknownInitialization
-
isFbcBottom
public boolean isFbcBottom(javax.lang.model.element.AnnotationMirror anno)
Isanno
the bottom annotation?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
isFBCBottom
-
isInitialized
public boolean isInitialized(javax.lang.model.element.AnnotationMirror anno)
Isanno
theInitialized
annotation?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
isInitialized
-
isUnderInitialization
public boolean isUnderInitialization(AnnotatedTypeMirror anno)
Doesanno
have the annotationUnderInitialization
(with any type frame)?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
hasUnderInitialization
-
isUnknownInitialization
public boolean isUnknownInitialization(AnnotatedTypeMirror anno)
Doesanno
have the annotationUnknownInitialization
(with any type frame)?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
hasUnknownInitialization
-
isFbcBottom
public boolean isFbcBottom(AnnotatedTypeMirror anno)
Doesanno
have the bottom annotation?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
hasFBCBottom
-
isInitialized
public boolean isInitialized(AnnotatedTypeMirror anno)
Doesanno
have the annotationInitialized
?- Parameters:
anno
- the annotation to check- Returns:
- true if
anno
hasInitialized
-
isInitializedForFrame
public 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.- Parameters:
type
- the type whose initialization type qualifiers to checkframe
- a class intype
's class hierarchy- Returns:
- true if the type is initialized for the given frame
-
getTypeFrameFromAnnotation
public 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.- Parameters:
annotation
- aUnderInitialization
orUnknownInitialization
annotation- Returns:
- the annotation's argument
-
createQualifierHierarchy
protected QualifierHierarchy createQualifierHierarchy()
Description copied from class:AnnotatedTypeFactory
Returns theQualifierHierarchy
to be used by this checker.The implementation builds the type qualifier hierarchy for the
AnnotatedTypeFactory.getSupportedTypeQualifiers()
using the meta-annotations found in them. The current implementation returns an instance ofNoElementQualifierHierarchy
.Subclasses must override this method if their qualifiers have elements; the method must return an implementation of
QualifierHierarchy
, such asElementQualifierHierarchy
.- Overrides:
createQualifierHierarchy
in classAnnotatedTypeFactory
- Returns:
- a QualifierHierarchy for this type system
-
createTypeAnnotator
protected TypeAnnotator createTypeAnnotator()
Description copied from class:GenericAnnotatedTypeFactory
Returns aDefaultForTypeAnnotator
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.
- Overrides:
createTypeAnnotator
in classGenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
- Returns:
- a type annotator
-
shouldWarnIfStubRedundantWithBytecode
public boolean shouldWarnIfStubRedundantWithBytecode()
Returnsfalse
. Redundancy in only the initialization hierarchy is ok and may even be caused by implicit default annotations. The parent checker should determine whether to warn about redundancy.- Overrides:
shouldWarnIfStubRedundantWithBytecode
in classAnnotatedTypeFactory
- Returns:
- whether to warn about redundancy between a stub file and bytecode
-
createTreeAnnotator
protected TreeAnnotator createTreeAnnotator()
Description copied from class:GenericAnnotatedTypeFactory
Returns aTreeAnnotator
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 subtreesLiteralTreeAnnotator
: Adds annotations based onQualifierForLiterals
meta-annotationsDependentTypesTreeAnnotator
: 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));
- Overrides:
createTreeAnnotator
in classGenericAnnotatedTypeFactory<CFValue,InitializationStore,InitializationTransfer,InitializationAnalysis>
- Returns:
- a tree annotator
-
-