public class NullnessAnnotatedTypeFactory extends InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
NullnessAnnotatedTypeFactory.NullnessPropagationTreeAnnotator
Nullness doesn't call propagation on binary and unary because the result is always @Initialized
(the default qualifier).
|
protected class |
NullnessAnnotatedTypeFactory.NullnessQualifierHierarchy
NullnessQualifierHierarchy.
|
protected class |
NullnessAnnotatedTypeFactory.NullnessTreeAnnotator |
protected class |
NullnessAnnotatedTypeFactory.NullnessTypeAnnotator |
InitializationAnnotatedTypeFactory.CommitmentTreeAnnotator, InitializationAnnotatedTypeFactory.CommitmentTypeAnnotator, InitializationAnnotatedTypeFactory.InitializationQualifierHierarchyGenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
protected ExecutableElement |
classGetCanonicalName
The Class.getCanonicalName() method.
|
protected CollectionToArrayHeuristics |
collectionToArrayHeuristics
Determines the nullness type of calls to
Collection.toArray(). |
protected AnnotationMirror |
MONOTONIC_NONNULL
The @
MonotonicNonNull annotation. |
protected AnnotationMirror |
NONNULL
The @
NonNull annotation. |
protected AnnotationMirror |
NULLABLE
The @
Nullable annotation. |
protected Set<Class<? extends Annotation>> |
nullnessAnnos
Cache for the nullness annotations.
|
protected AnnotationMirror |
POLYNULL
The @
PolyNull annotation. |
protected SystemGetPropertyHandler |
systemGetPropertyHandler
Handles invocations of
System.getProperty(String). |
FBCBOTTOM, initAnnoNames, initAnnos, INITIALIZED, NOT_ONLY_INITIALIZED, objectTypeMirror, UNDER_INITALIZATION, underInitializationValueElement, UNKNOWN_INITIALIZATION, unknownInitializationValueElement, unusedWhenElementanalysis, 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| Constructor and Description |
|---|
NullnessAnnotatedTypeFactory(BaseTypeChecker checker)
Creates a NullnessAnnotatedTypeFactory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
adaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType,
AnnotatedTypeMirror receiverType,
ExpressionTree tree)
Java special-cases the return type of
getClass(). |
protected void |
addAnnotationsFromDefaultForType(@Nullable Element element,
AnnotatedTypeMirror type)
Adds default qualifiers based on the underlying type of
type to type. |
protected boolean |
containsNullnessAnnotation(List<? extends AnnotationTree> annoTrees)
Returns true if some annotation in the given list is a nullness annotation such
as @NonNull, @Nullable, @MonotonicNonNull, etc.
|
protected boolean |
containsNullnessAnnotation(List<? extends AnnotationTree> annoTrees,
Tree typeTree)
Returns true if some annotation on the given type, or in the given list, is a nullness
annotation such as @NonNull, @Nullable, @MonotonicNonNull, etc.
|
protected AnnotatedTypeFormatter |
createAnnotatedTypeFormatter()
Returns an AnnotatedTypeFormatter that does not print the qualifiers on null literals.
|
protected DefaultForTypeAnnotator |
createDefaultForTypeAnnotator()
Creates an
DefaultForTypeAnnotator. |
protected NullnessAnalysis |
createFlowAnalysis()
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow
analysis.
|
NullnessTransfer |
createFlowTransferFunction(CFAbstractAnalysis<NullnessValue,NullnessStore,NullnessTransfer> analysis)
Returns the appropriate transfer function that is used for the org.checkerframework.dataflow
analysis.
|
QualifierHierarchy |
createQualifierHierarchy()
Returns the
QualifierHierarchy to be used by this checker. |
protected @Nullable AnnotationMirror |
createRequiresOrEnsuresQualifier(String expression,
AnnotationMirror qualifier,
AnnotatedTypeMirror declaredType,
Analysis.BeforeOrAfter preOrPost,
@Nullable List<AnnotationMirror> preconds)
Creates a
RequiresQualifier("...") or EnsuresQualifier("...") annotation for
the given expression. |
protected Set<Class<? extends Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.
|
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. |
AnnotatedTypeMirror |
getDefaultValueAnnotatedType(TypeMirror typeMirror)
Return the type of the default value of the given type.
|
AnnotationMirror |
getFieldInvariantAnnotation()
Returns the annotation that makes up the invariant of this commitment type system, such as
@NonNull. |
AnnotatedTypeMirror |
getMethodReturnType(MethodTree m,
ReturnTree r)
Returns the return type of the method
m at the return statement r. |
Set<Class<? extends Annotation>> |
getNullnessAnnotations()
Returns the list of annotations of the non-null type system.
|
Pair<List<VariableTree>,List<VariableTree>> |
getUninitializedFields(NullnessStore store,
TreePath path,
boolean isStatic,
Collection<? extends AnnotationMirror> receiverAnnotations)
Returns the fields that are not yet initialized in a given store.
|
protected boolean |
hasFieldInvariantAnnotation(AnnotatedTypeMirror type,
VariableElement fieldElement)
Returns whether or not
type has the invariant annotation. |
protected boolean |
isNonNullOrAlias(AnnotationMirror am)
Returns true if the given annotation is @NonNull or an alias for it.
|
protected boolean |
isNullableOrAlias(AnnotationMirror am)
Returns true if the given annotation is @Nullable or an alias for it.
|
protected boolean |
isNullnessAnnotation(AnnotationMirror am)
Returns true if the given annotation is a nullness annotation such
as @NonNull, @Nullable, @MonotonicNonNull, etc.
|
AnnotatedTypeFactory.ParameterizedExecutableType |
methodFromUse(MethodInvocationTree tree)
Determines the type of the invoked method based on the passed method invocation tree.
|
protected void |
replacePolyQualifier(AnnotatedTypeMirror lhsType,
Tree context)
|
void |
wpiAdjustForUpdateField(Tree lhsTree,
Element element,
String fieldName,
AnnotatedTypeMirror rhsATM)
Changes the type of
rhsATM when being assigned to a field, for use by whole-program
inference. |
void |
wpiAdjustForUpdateNonField(AnnotatedTypeMirror rhsATM)
Changes the type of
rhsATM when being assigned to anything other than a field, for use
by whole-program inference. |
areAllFieldsInitializedOnly, createUnderInitializationAnnotation, createUnderInitializationAnnotation, createUnknownInitializationAnnotation, createUnknownInitializationAnnotation, getAnnotatedTypeLhs, getInitializationAnnotations, getInitializedInvariantFields, getInvalidConstructorReturnTypeAnnotations, getSelfType, getTypeFrameFromAnnotation, getUnderInitializationAnnotationOfSuperType, getUninitializedInvariantFields, hasFieldInvariantAnnotation, isFbcBottom, isFbcBottom, isInitializationAnnotation, isInitialized, isInitialized, isInitializedForFrame, isUnderInitialization, isUnderInitialization, isUnknownInitialization, isUnknownInitialization, postAsMemberOf, setSelfTypeInInitializationCodeaddCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createQualifierDefaults, createQualifierPolymorphism, fromNewClass, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, 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, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseaddAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchyWithMultiGraphFactory, createQualifierUpperBounds, 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, 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, typeprotected final AnnotationMirror NONNULL
NonNull annotation.protected final AnnotationMirror NULLABLE
Nullable annotation.protected final AnnotationMirror POLYNULL
PolyNull annotation.protected final AnnotationMirror MONOTONIC_NONNULL
MonotonicNonNull annotation.protected final SystemGetPropertyHandler systemGetPropertyHandler
System.getProperty(String).protected final CollectionToArrayHeuristics collectionToArrayHeuristics
Collection.toArray().protected final ExecutableElement classGetCanonicalName
protected final Set<Class<? extends Annotation>> nullnessAnnos
public NullnessAnnotatedTypeFactory(BaseTypeChecker checker)
checker - the associated NullnessCheckerprotected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactorySubclasses 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 of ElementType.TYPE_PARAMETER, but no other ElementType
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:
This is the default behavior. Simply place those annotations within the qual directory.
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.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);
}
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));
}
The set of qualifiers returned by AnnotatedTypeFactory.createSupportedTypeQualifiers() must be a
fresh, mutable set. The methods AnnotatedTypeFactory.getBundledTypeQualifiers(Class...) must return a
fresh, mutable set
createSupportedTypeQualifiers in class AnnotatedTypeFactoryprotected void replacePolyQualifier(AnnotatedTypeMirror lhsType, Tree context)
PolyNull with Nullable (or with NonNull if the org.checkerframework.dataflow analysis has determined
that this is allowed soundly. For example:
@PolyNull String foo(@PolyNull String param) {
if (param == null) {
// @PolyNull is really @Nullable, so change
// the type of param to @Nullable.
param = null;
}
return param;
}
lhsType - type to replace whose polymorphic qualifier will be replacedcontext - tree used to get dataflow valuepublic Pair<List<VariableTree>,List<VariableTree>> getUninitializedFields(NullnessStore store, TreePath path, boolean isStatic, Collection<? extends AnnotationMirror> receiverAnnotations)
InitializationAnnotatedTypeFactorygetUninitializedFields in class InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>store - a storepath - the current path, used to determine the current classisStatic - whether to report static fields or instance fieldsreceiverAnnotations - the annotations on the receiverprotected NullnessAnalysis createFlowAnalysis()
GenericAnnotatedTypeFactoryThis 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.
createFlowAnalysis in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>public NullnessTransfer createFlowTransferFunction(CFAbstractAnalysis<NullnessValue,NullnessStore,NullnessTransfer> analysis)
GenericAnnotatedTypeFactoryThis 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.
protected AnnotatedTypeFormatter createAnnotatedTypeFormatter()
createAnnotatedTypeFormatter in class AnnotatedTypeFactorypublic AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(MethodInvocationTree tree)
AnnotatedTypeFactoryThe returned method type has all type variables resolved, whether based on receiver type, passed type parameters if any, and method invocation parameter.
Subclasses may override this method to customize inference of types or qualifiers based on method invocation parameters.
As an implementation detail, this method depends on AnnotatedTypes.asMemberOf(Types,
AnnotatedTypeFactory, AnnotatedTypeMirror, Element), and customization based on receiver type
should be in accordance to its specification.
The return type is a pair of the type of the invoked method and the (inferred) type
arguments. Note that neither the explicitly passed nor the inferred type arguments are
guaranteed to be subtypes of the corresponding upper bounds. See method BaseTypeVisitor.checkTypeArguments(com.sun.source.tree.Tree, java.util.List<? extends org.checkerframework.framework.type.AnnotatedTypeParameterBounds>, java.util.List<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>, java.util.List<? extends com.sun.source.tree.Tree>, java.lang.CharSequence, java.util.List<?>) for the checks of type
argument well-formedness.
Note that "this" and "super" constructor invocations are also handled by this method
(explicit or implicit ones, at the beginning of a constructor). Method AnnotatedTypeFactory.constructorFromUse(NewClassTree) is only used for a constructor invocation in a "new"
expression.
methodFromUse in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>tree - the method invocation treepublic void adaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, ExpressionTree tree)
AnnotatedTypeFactorygetClass(). Though the
method has a return type of Class<?>, the compiler special cases this return-type and
changes the bound of the type argument to the erasure of the receiver type. For example:
x.getClass() has the type Class< ? extends erasure_of_x >
someInteger.getClass() has the type Class< ? extends Integer >
adaptGetClassReturnTypeToReceiver in class AnnotatedTypeFactorygetClassType - this must be a type representing a call to Object.getClass otherwise a
runtime exception will be thrown. It is modified by side effect.receiverType - the receiver type of the method invocation (not the declared receiver type)tree - getClass method invocation treepublic AnnotatedTypeMirror getMethodReturnType(MethodTree m, ReturnTree r)
AnnotatedTypeFactorym at the return statement r. This
implementation just calls AnnotatedTypeFactory.getMethodReturnType(MethodTree), but subclasses may override
this method to change the type based on the return statement.getMethodReturnType in class AnnotatedTypeFactorym - tree of a method declarationr - a return statement within method mm at the return statement rprotected DefaultForTypeAnnotator createDefaultForTypeAnnotator()
GenericAnnotatedTypeFactoryDefaultForTypeAnnotator.createDefaultForTypeAnnotator in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>DefaultForTypeAnnotatorprotected void addAnnotationsFromDefaultForType(@Nullable Element element, AnnotatedTypeMirror type)
GenericAnnotatedTypeFactorytype to type. If element is a local variable, then the defaults are not added.
(This uses both the DefaultQualifierForUseTypeAnnotator and DefaultForTypeAnnotator.)
addAnnotationsFromDefaultForType in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>element - possibly null element whose type is typetype - the type to which defaults are addedprotected 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 InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>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 InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>public Set<Class<? extends Annotation>> getNullnessAnnotations()
public AnnotationMirror getFieldInvariantAnnotation()
InitializationAnnotatedTypeFactory@NonNull.getFieldInvariantAnnotation in class InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>protected 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 InitializationAnnotatedTypeFactory.hasFieldInvariantAnnotation(VariableTree) for an example.
In other words, is the lower bound @NonNull?
hasFieldInvariantAnnotation in class InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>type - of field that might have invariant annotationfieldElement - the field element, which can be used to check annotations on the
declarationpublic QualifierHierarchy createQualifierHierarchy()
AnnotatedTypeFactoryQualifierHierarchy 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 of NoElementQualifierHierarchy.
Subclasses must override this method if their qualifiers have elements; the method must
return an implementation of QualifierHierarchy, such as ElementQualifierHierarchy.
createQualifierHierarchy in class AnnotatedTypeFactoryprotected boolean containsNullnessAnnotation(List<? extends AnnotationTree> annoTrees, Tree typeTree)
This method ignores aliases of nullness annotations that are declaration annotations, because they may apply to inner types.
annoTrees - a list of annotations that the the Java parser attached to the variable/method
declaration; null if this type is not from such a location. This is a list of extra
annotations to check, in addition to those on the type.typeTree - the type whose annotations to testprotected boolean containsNullnessAnnotation(List<? extends AnnotationTree> annoTrees)
This method ignores aliases of nullness annotations that are declaration annotations, because they may apply to inner types.
Clients that are processing a field or variable definition, or a method return type, should
call containsNullnessAnnotation(List, Tree) instead.
annoTrees - a list of annotations to checkcontainsNullnessAnnotation(List, Tree)protected boolean isNullnessAnnotation(AnnotationMirror am)
am - an annotationprotected boolean isNonNullOrAlias(AnnotationMirror am)
am - an annotationprotected boolean isNullableOrAlias(AnnotationMirror am)
am - an annotationpublic AnnotatedTypeMirror getDefaultValueAnnotatedType(TypeMirror typeMirror)
GenericAnnotatedTypeFactorygetDefaultValueAnnotatedType in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>typeMirror - a typetype's default valuepublic void wpiAdjustForUpdateField(Tree lhsTree, Element element, String fieldName, AnnotatedTypeMirror rhsATM)
AnnotatedTypeFactoryrhsATM when being assigned to a field, for use by whole-program
inference. The default implementation does nothing.wpiAdjustForUpdateField in class AnnotatedTypeFactorylhsTree - the tree for the field whose type will be changedelement - the element for the field whose type will be changedfieldName - the name of the field whose type will be changedrhsATM - the type of the expression being assigned to the field, which is side-effected by
this methodpublic void wpiAdjustForUpdateNonField(AnnotatedTypeMirror rhsATM)
AnnotatedTypeFactoryrhsATM when being assigned to anything other than a field, for use
by whole-program inference. The default implementation does nothing.wpiAdjustForUpdateNonField in class AnnotatedTypeFactoryrhsATM - the type of the rhs of the pseudo-assignment, which is side-effected by this
methodprotected @Nullable AnnotationMirror createRequiresOrEnsuresQualifier(String expression, AnnotationMirror qualifier, AnnotatedTypeMirror declaredType, Analysis.BeforeOrAfter preOrPost, @Nullable List<AnnotationMirror> preconds)
GenericAnnotatedTypeFactoryRequiresQualifier("...") or EnsuresQualifier("...") annotation for
the given expression.
This is of the form @RequiresQualifier(expression="expression",
qualifier=MyQual.class) or @EnsuresQualifier(expression="expression",
qualifier=MyQual.class), where "expression" is exactly the string expression and
MyQual is the annotation represented by qualifier.
Returns null if the expression is invalid when combined with the kind of annotation: for example, precondition annotations on "this" and parameters ("#1", etc.) are not supported, because receiver/parameter annotations should be inferred instead.
This implementation returns null if no annotation can be created, because the qualifier has
elements/arguments, which @RequiresQualifier and @EnsuresQualifier do not
support. Subclasses may override this method to return qualifiers that do have arguments
instead of returning null.
createRequiresOrEnsuresQualifier in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>expression - the expression to which the qualifier appliesqualifier - the qualifier that must be presentdeclaredType - the declared type of the expression, which is used to avoid inferring
redundant pre- or postcondition annotationspreOrPost - whether to return a precondition or postcondition annotationpreconds - the list of precondition annotations; used to suppress redundant
postconditions; non-null exactly when preOrPost is BeforeOrAfter.BEFORERequiresQualifier("...") or EnsuresQualifier("...") annotation for
the given expression, or null