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, parsePhasePrimaryDefaultsCache, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorFields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForApplyToSubpackagesElement, annotatedForListValueElement, annotatedForValueElement, capturedTypeVarSubstitutor, checker, currentFileAjavaTypes, defaultQualifierListValueElement, elements, ensuresQualifierExpressionElement, ensuresQualifierIfExpressionElement, ensuresQualifierIfListTM, ensuresQualifierIfListValueElement, ensuresQualifierIfResultElement, ensuresQualifierIfTM, ensuresQualifierListTM, ensuresQualifierListValueElement, ensuresQualifierTM, fieldInvariantFieldElement, fieldInvariantQualifierElement, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, hasQualifierParameterApplyToSubpackagesElement, hasQualifierParameterValueElement, ignoreRawTypeArguments, inferenceResultCache, loader, methodValClassNameElement, methodValMethodNameElement, methodValParamsElement, nodeValueInferenceResultCache, noQualifierParameterValueElement, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, requiresQualifierExpressionElement, requiresQualifierListTM, requiresQualifierListValueElement, requiresQualifierTM, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, typeInformationPresenter, types, typeVarSubstitutor, uid, UNANNOTATED_FOR_NAME, unannotatedForApplyToSubpackagesElement, unannotatedForListValueElement, unannotatedForValueElement, 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 DefaultForTypeAnnotatorCreates anDefaultForTypeAnnotator.protected NullnessNoInitAnalysisReturns the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis.createFlowTransferFunction(CFAbstractAnalysis<CFValue, 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.Returns the message key for why a call to Arrays.copyOf cannot return an array of@NonNullelements, or null if the call is safe or not applicable.getDefaultValueAnnotatedType(TypeMirror typeMirror) Returns the type of the default value of the given type.Set<Class<? extends Annotation>> Returns the list of annotations of the non-null type system.booleanisCollectionIsEmpty(Node node) Returns true ifnodeis an invocation of Collection.isEmpty.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.booleanisQueuePeek(Node node) Returns true ifnodeis an invocation of Queue.peek, Deque.peekFirst, or Deque.peekLast.booleanisQueuePoll(Node node) Returns true ifnodeis an invocation of Queue.poll, Deque.pollFirst, or Deque.pollLast.methodFromUse(MethodInvocationTree tree, boolean inferTypeArgs) Methods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsWithoutFlow, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, canCacheFlowDependentType, canUseCachedFlowDependentType, checkForDefaultQualifierInHierarchy, clearParsePhaseCache, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnosForUses, getDefaultAnnotations, getDefaultForTypeAnnotator, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getQualifierDefaults, getQualifierPolymorphism, getRegularExitStore, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStandaloneTypeForNodeValue, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, getUseFlow, handleCFGViz, irrelevantExtraMessage, isAnonymousDiamondSupertypeFinal, isComputingAnnotatedTypeMirrorOfLhs, isComputingNodeValue, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysisForClass, performFlowAnalysisForClassImpl, performFlowAnalysisForClassOnce, postAnalyze, postAsMemberOf, postInit, preProcessClassTree, runWithBodyVisitorPath, setRoot, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
addAliasedDeclAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, annotatedForPrecedesUnannotatedFor, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, asSupportedQualifier, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, clearNodeValueInferenceResults, combineIntersectionBoundAnnotationsInHierarchy, compoundAssignmentTreeArgTypes, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, containsSameOrAlias, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeInformationPresenter, createTypeVariableSubstitutor, createViewpointAdapter, declarationFromElement, doesAnnotatedForApplyToSubpackages, doesAnnotatedForApplyToThisChecker, doesUnannotatedForApplyToSubpackages, doesUnannotatedForApplyToThisChecker, fromElement, fromElement, fromElement, getAnnotatedForAnnotations, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationByClass, getAnnotationFormatter, getAnnotationMirror, getAnnotationOrTypeDeclarationBound, getAnnotationWithMetaAnnotation, getAnonymousDiamondCreation, getAnonymousDiamondSuperConstructor, getAnonymousDiamondSupertype, getBoxedType, getBundledTypeQualifiers, getCacheSize, getCheckerNames, getConstructorReceiverType, getContractExpressions, getContractListValues, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultQualifierAnnotations, getDefaultTypeDeclarationBounds, getDirectSupertypes, getDummyAssignedTo, getElementAnnotations, getElementUtils, getEnclosingClassOrMethod, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getInferenceWorkBudget, getInitializerTargetType, getIterableElementType, getIterableElementType, getMethodReceiverType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getResultingTypeOfConstructorMemberReference, getRoot, getSelfType, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeDeclarationBoundsFromUse, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnannotatedForAnnotations, getUnboxedType, getViewpointAdaptedTypeDeclarationBounds, getVisitorTreePath, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, inferTypeArguments, initializeAtm, initializeReflectionResolution, isAliasedTypeAnnotation, isComputingInitializerTargetType, isDeterministic, isFromByteCode, isFromStubFile, isInferringStandalone, isParsingAnnotationFile, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isSupportedQualifierOrAlias, isWithinConstructor, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, negateConstant, order, overriddenMethodType, parseAnnotationFiles, permissiveOverriddenType, postDirectSuperTypes, postProcessClassTree, replaceAnnotations, replaceAnnotations, setPathForArtificialTree, setVisitorTreePath, shouldCacheElementType, shouldCacheMethodAsMemberOf, shouldStoreInBytecode, 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 3 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( // These annotations are in the Called Methods Checker, not the Resource Leak Checker. CalledMethods.class, CalledMethodsBottom.class, CalledMethodsPredicate.class); } - Support only annotations that are explicitly listed. This is common when a single
directory holds qualifiers for multiple qualifier hierarchies. 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:
-
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<CFValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Returns:
- the appropriate flow analysis class that is used for the org.checkerframework.dataflow analysis
-
createFlowTransferFunction
public NullnessNoInitTransfer createFlowTransferFunction(CFAbstractAnalysis<CFValue, 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<CFValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
analysis- a dataflow analysis- Returns:
- a new transfer function
-
methodFromUse
protected AnnotatedTypeFactory.ParameterizedExecutableType methodFromUse(MethodInvocationTree tree, boolean inferTypeArgs) Description copied from class:AnnotatedTypeFactoryThe implementation ofAnnotatedTypeFactory.methodFromUse(MethodInvocationTree)andAnnotatedTypeFactory.methodFromUseWithoutTypeArgInference(MethodInvocationTree).- Overrides:
methodFromUsein classGenericAnnotatedTypeFactory<CFValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Parameters:
tree- a method invocation treeinferTypeArgs- true if 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 >
A method reference such as
x::getClassorFoo::getClassreturns the same type as an invocation on the reference's receiver.- 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- a getClass method invocation or member reference tree
-
isNotFullyInitializedReceiver
Description copied from class:GenericAnnotatedTypeFactoryReturns true if the receiver of a method or constructor might not be fully initialized.- Overrides:
isNotFullyInitializedReceiverin classGenericAnnotatedTypeFactory<CFValue,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<CFValue,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<CFValue,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<CFValue,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<CFValue,NullnessNoInitStore, NullnessNoInitTransfer, NullnessNoInitAnalysis> - Returns:
- a tree annotator
-
getCopyOfUnsafeReason
Returns the message key for why a call to Arrays.copyOf cannot return an array of@NonNullelements, or null if the call is safe or not applicable.- Parameters:
tree- the method invocation tree to analyze- Returns:
- the diagnostic message key explaining why the copy is unsafe, or null if it's safe or not an Arrays.copyOf call
-
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<CFValue,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.
This method is used only for issuing an error when a nullness annotation is written in a place it should not be.
- 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.
This method is used only for issuing an error when a nullness annotation is written in a place it should not be. 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:GenericAnnotatedTypeFactoryReturns the type of the default value of the given type. The default value is 0, false, or null.- Overrides:
getDefaultValueAnnotatedTypein classGenericAnnotatedTypeFactory<CFValue,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
-
isCollectionIsEmpty
Returns true ifnodeis an invocation of Collection.isEmpty.- Parameters:
node- a CFG node- Returns:
- true if
nodeis an invocation of Collection.isEmpty
-
isQueuePoll
Returns true ifnodeis an invocation of Queue.poll, Deque.pollFirst, or Deque.pollLast.- Parameters:
node- a CFG node- Returns:
- true if
nodeis an invocation of a queue/deque poll method
-
isQueuePeek
Returns true ifnodeis an invocation of Queue.peek, Deque.peekFirst, or Deque.peekLast.- Parameters:
node- a CFG node- Returns:
- true if
nodeis an invocation of a queue/deque peek method
-