Class NullnessNoInitAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAdds nullness-specific propagation rulesprotected classThis type annotator ensures that constructor return types are NONNULL, unless there is an explicit different annotation.Nested classes/interfaces inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
GenericAnnotatedTypeFactory.ScanStateNested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
AnnotatedTypeFactory.CapturedTypeVarSubstitutor, AnnotatedTypeFactory.ParameterizedExecutableType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutableElementThe Class.getCanonicalName() method.protected final CollectionToArrayHeuristicsDetermines the nullness type of calls toCollection.toArray().protected final AnnotationMirrorThe @MonotonicNonNullannotation.protected final AnnotationMirrorThe @NonNullannotation.protected final AnnotationMirrorThe @Nullableannotation.protected final Set<Class<? extends Annotation>> Cache for the nullness annotations.protected final AnnotationMirrorThe @PolyNullannotation.protected final SystemGetPropertyHandlerHandles invocations ofSystem.getProperty(String).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, typeAnnotatorFields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, capturedTypeVarSubstitutor, checker, currentFileAjavaTypes, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterValueElement, ignoreRawTypeArguments, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, typeInformationPresenter, types, typeVarSubstitutor, uid, viewpointAdapter -
Constructor Summary
ConstructorsConstructorDescriptionCreates a NullnessAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidadaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, ExpressionTree tree) Java special-cases the return type ofgetClass().protected voidaddAnnotationsFromDefaultForType(@Nullable Element element, AnnotatedTypeMirror type) Adds default qualifiers based on the underlying type oftypetotype.protected booleancontainsNullnessAnnotation(@Nullable 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 booleancontainsNullnessAnnotation(List<? extends AnnotationTree> annoTrees) Returns true if some annotation in the given list is a nullness annotation such as @NonNull, @Nullable, @MonotonicNonNull, etc.protected AnnotatedTypeFormatterReturns an AnnotatedTypeFormatter that does not print the qualifiers on null literals.protected DefaultForTypeAnnotatorCreates anDefaultForTypeAnnotator.protected NullnessNoInitAnalysisReturns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.createFlowTransferFunction(CFAbstractAnalysis<NullnessNoInitValue, NullnessNoInitStore, NullnessNoInitTransfer> analysis) Returns the appropriate transfer function that is used for the given org.checkerframework.dataflow analysis.protected QualifierHierarchyReturns theQualifierHierarchyto be used by this checker.protected Set<Class<? extends Annotation>> Returns a mutable set of annotation classes that are supported by a checker.protected TreeAnnotatorReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.protected TypeAnnotatorReturns aDefaultForTypeAnnotatorthat adds annotations to a type based on the content of the type itself.getAnnotatedTypeBefore(JavaExpression expr, ExpressionTree tree) Returns the type of a JavaExpressionexprif it were evaluated before a treetree.Returns the checker associated with this factory.getDefaultValueAnnotatedType(TypeMirror typeMirror) Return the type of the default value of the given type.Returns the return type of the methodmat the return statementr.Set<Class<? extends Annotation>> Returns the list of annotations of the non-null type system.booleanisImmutable(TypeMirror type) A non-null reference to an object stays non-null under mutation.booleanReturns true ifnodeis an invocation of Map.get.protected booleanReturns true if the given annotation is@NonNullor an alias for it.booleanisNotFullyInitializedReceiver(MethodTree methodDeclTree) Returns true if the receiver of a method or constructor might not be fully initialized.protected booleanReturns true if the given annotation is@Nullableor an alias for it.protected booleanReturns true if the given annotation is a nullness annotation such as@NonNull,@Nullable,@MonotonicNonNull,@PolyNull, or an alias thereof.protected booleanReturns true if the given annotation is@PolyNullor an alias for it.methodFromUse(MethodInvocationTree tree, boolean inferTypeArgs) protected voidreplacePolyQualifier(AnnotatedTypeMirror lhsType, Tree context) Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsWithoutFlow, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultForTypeAnnotator, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getRegularExitStore, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, getUseFlow, handleCFGViz, irrelevantExtraMessage, isComputingAnnotatedTypeMirrorOfLhs, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
addAliasedDeclAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, compoundAssignmentTreeArgTypes, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeInformationPresenter, createTypeVariableSubstitutor, createViewpointAdapter, declarationFromElement, doesAnnotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationOrTypeDeclarationBound, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiers, getCacheSize, getCheckerNames, getContractExpressions, getContractListValues, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getResultingTypeOfConstructorMemberReference, getRoot, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getVisitorTreePath, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isDeterministic, isFromByteCode, isFromStubFile, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setPathForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type
-
Field Details
-
NONNULL
The @NonNullannotation. -
NULLABLE
The @Nullableannotation. -
POLYNULL
The @PolyNullannotation. -
MONOTONIC_NONNULL
The @MonotonicNonNullannotation. -
systemGetPropertyHandler
Handles invocations ofSystem.getProperty(String). -
collectionToArrayHeuristics
Determines the nullness type of calls toCollection.toArray(). -
classGetCanonicalName
The Class.getCanonicalName() method. -
nullnessAnnos
Cache for the nullness annotations.
-
-
Constructor Details
-
NullnessNoInitAnnotatedTypeFactory
Creates a NullnessAnnotatedTypeFactory.- Parameters:
checker- the associatedNullnessNoInitSubchecker
-
-
Method Details
-
getChecker
Description copied from class:AnnotatedTypeFactoryReturns the checker associated with this factory.- Overrides:
getCheckerin classAnnotatedTypeFactory- Returns:
- the checker associated with this factory
-
createSupportedTypeQualifiers
Description copied from class:AnnotatedTypeFactoryReturns 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 otherElementTypevalues) are automatically considered as supported annotations.To support a different set of annotations than those in the qual subdirectory, or that have other
ElementTypevalues, 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:
The set of qualifiers returned by@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:
createSupportedTypeQualifiersin classAnnotatedTypeFactory- Returns:
- the type qualifiers supported this processor, or an empty set if none
- Only support annotations located in a checker's qual directory:
-
replacePolyQualifier
For types of left-hand side of an assignment, this method replacesPolyNullwithNullable(or withNonNullif 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; }- Parameters:
lhsType- type to replace whose polymorphic qualifier will be replacedcontext- tree used to get dataflow value
-
createFlowAnalysis
Description copied from class:GenericAnnotatedTypeFactoryReturns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.This 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.
- Overrides:
createFlowAnalysisin classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
createFlowTransferFunction
public NullnessNoInitTransfer createFlowTransferFunction(CFAbstractAnalysis<NullnessNoInitValue, NullnessNoInitStore, NullnessNoInitTransfer> analysis) Description copied from class:GenericAnnotatedTypeFactoryReturns 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:
createFlowTransferFunctionin classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
analysis- a dataflow analysis- Returns:
- a new transfer function
-
createAnnotatedTypeFormatter
Returns an AnnotatedTypeFormatter that does not print the qualifiers on null literals.- Overrides:
createAnnotatedTypeFormatterin classAnnotatedTypeFactory- Returns:
- an AnnotatedTypeFormatter that does not print the qualifiers on null literals
-
methodFromUse
protected AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(MethodInvocationTree tree, boolean inferTypeArgs) Description copied from class:AnnotatedTypeFactoryThe implementation ofAnnotatedTypeFactory.methodFromUse(MethodInvocationTree)andAnnotatedTypeFactory.methodFromUseWithoutTypeArgInference(MethodInvocationTree).- Overrides:
methodFromUsein classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
tree- a method invocation treeinferTypeArgs- whether type arguments should be inferred- Returns:
- the type of the invoked method, any explicit type arguments, and if
inferTypeArgsis true, any inferred type arguments
-
adaptGetClassReturnTypeToReceiver
public void adaptGetClassReturnTypeToReceiver(AnnotatedTypeMirror.AnnotatedExecutableType getClassType, AnnotatedTypeMirror receiverType, ExpressionTree tree) Description copied from class:AnnotatedTypeFactoryJava special-cases the return type ofgetClass(). Though the method has a return type ofClass<?>, 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 typeClass< ? extends erasure_of_x >someInteger.getClass()has the typeClass< ? extends Integer >
- Overrides:
adaptGetClassReturnTypeToReceiverin classAnnotatedTypeFactory- Parameters:
getClassType- 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 tree
-
getMethodReturnType
Description copied from class:AnnotatedTypeFactoryReturns the return type of the methodmat the return statementr. This implementation just callsAnnotatedTypeFactory.getMethodReturnType(MethodTree), but subclasses may override this method to change the type based on the return statement.- Overrides:
getMethodReturnTypein classAnnotatedTypeFactory- Parameters:
m- tree of a method declarationr- a return statement within methodm- Returns:
- the return type of the method
mat the return statementr
-
isNotFullyInitializedReceiver
Description copied from class:GenericAnnotatedTypeFactoryReturns true if the receiver of a method or constructor might not be fully initialized.- Overrides:
isNotFullyInitializedReceiverin classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
methodDeclTree- the declaration of the method or constructor- Returns:
- true if the receiver of a method or constructor might not be fully initialized
-
getAnnotatedTypeBefore
Description copied from class:GenericAnnotatedTypeFactoryReturns the type of a JavaExpressionexprif it were evaluated before a treetree.This is used by
BaseTypeVisitor.visitMethodInvocation(MethodInvocationTree, Void)to check the preconditions of method calls.- Overrides:
getAnnotatedTypeBeforein classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
expr- the expression to typetree- a tree- Returns:
- the type of
exprif it were evaluated before treetree
-
createDefaultForTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryCreates anDefaultForTypeAnnotator.- Overrides:
createDefaultForTypeAnnotatorin classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Returns:
- a new
DefaultForTypeAnnotator
-
addAnnotationsFromDefaultForType
protected void addAnnotationsFromDefaultForType(@Nullable Element element, AnnotatedTypeMirror type) Description copied from class:GenericAnnotatedTypeFactoryAdds default qualifiers based on the underlying type oftypetotype. Ifelementis a local variable, or if the type already has an annotation from the relevant type hierarchy, then the defaults are not added.(This uses both the
DefaultQualifierForUseTypeAnnotatorandDefaultForTypeAnnotator.)- Overrides:
addAnnotationsFromDefaultForTypein classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
element- possibly null element whose type istypetype- the type to which defaults are added
-
createTreeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryReturns aTreeAnnotatorthat adds annotations to a type based on the contents of a tree.The default tree annotator is a
ListTreeAnnotatorof the following:PropagationTreeAnnotator: Propagates annotations from subtreesLiteralTreeAnnotator: Adds annotations based onQualifierForLiteralsmeta-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:
createTreeAnnotatorin classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Returns:
- a tree annotator
-
createTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryReturns aDefaultForTypeAnnotatorthat adds annotations to a type based on the content of the type itself.Subclass may override this method. The default type annotator is a
ListTypeAnnotatorof the following:IrrelevantTypeAnnotator: Adds top to types not listed in the@RelevantJavaTypesannotation on the checker.PropagationTypeAnnotator: Propagates annotation onto wildcards.
- Overrides:
createTypeAnnotatorin classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Returns:
- a type annotator
-
getNullnessAnnotations
Returns the list of annotations of the non-null type system.- Returns:
- the list of annotations of the non-null type system
-
createQualifierHierarchy
Description copied from class:AnnotatedTypeFactoryReturns theQualifierHierarchyto 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:
createQualifierHierarchyin classAnnotatedTypeFactory- Returns:
- a QualifierHierarchy for this type system
-
containsNullnessAnnotation
protected boolean containsNullnessAnnotation(@Nullable 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.This method ignores aliases of nullness annotations that are declaration annotations, because they may apply to inner types.
- Parameters:
annoTrees- a list of annotations that 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 test- Returns:
- true if some annotation is a nullness annotation
-
containsNullnessAnnotation
Returns true if some annotation in the given list is a nullness annotation such as @NonNull, @Nullable, @MonotonicNonNull, etc.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.- Parameters:
annoTrees- a list of annotations to check- Returns:
- true if some annotation is a nullness annotation
- See Also:
-
isNullnessAnnotation
Returns true if the given annotation is a nullness annotation such as@NonNull,@Nullable,@MonotonicNonNull,@PolyNull, or an alias thereof.- Parameters:
am- an annotation- Returns:
- true if the given annotation is a nullness annotation
-
isNonNullOrAlias
Returns true if the given annotation is@NonNullor an alias for it.- Parameters:
am- an annotation- Returns:
- true if the given annotation is
@NonNullor an alias for it
-
isNullableOrAlias
Returns true if the given annotation is@Nullableor an alias for it.- Parameters:
am- an annotation- Returns:
- true if the given annotation is
@Nullableor an alias for it
-
isPolyNullOrAlias
Returns true if the given annotation is@PolyNullor an alias for it.- Parameters:
am- an annotation- Returns:
- true if the given annotation is
@PolyNullor an alias for it
-
getDefaultValueAnnotatedType
Description copied from class:GenericAnnotatedTypeFactoryReturn the type of the default value of the given type. The default value is 0, false, or null.- Overrides:
getDefaultValueAnnotatedTypein classGenericAnnotatedTypeFactory<NullnessNoInitValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
typeMirror- a type- Returns:
- the annotated type of
type's default value
-
isImmutable
A non-null reference to an object stays non-null under mutation.- Overrides:
isImmutablein classAnnotatedTypeFactory- Parameters:
type- type to test- Returns:
- true if the type is immutable
-
isMapGet
Returns true ifnodeis an invocation of Map.get.- Parameters:
node- a CFG node- Returns:
- true if
nodeis an invocation of Map.get
-