Class InterningAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
AnnotatedTypeFactory that accounts for the properties of the Interned type system.
This type factory will add the Interned annotation to a type if the input:
- is a String literal
- is a class literal
- has an enum type
- has a primitive type
- has the type java.lang.Class
- is a use of a class declared to be @Interned
InternedDistinct to formal parameters that have a @FindDistinct declaration annotation. (TODO: That isn't a good implementation, because it is not
accurate: the value might be equals() to some other Java value. More seriously, it permits too
much. Writing @FindDistinct should permit equality tests on the given formal parameter,
but should not (for example) permit the formal parameter to be assigned into an
@InternedDistinct location.)
This factory extends BaseAnnotatedTypeFactory and inherits its functionality,
including: flow-sensitive qualifier inference, qualifier polymorphism (of PolyInterned),
implicit annotations via DefaultFor on Interned (to handle cases 1, 2, 4), and user-specified defaults via DefaultQualifier.
Case 5 is handled by the stub library.
-
Nested Class Summary
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
Fields inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
analysis, arraysAreRelevant, cfgVisualizer, contractsUtils, defaults, dependentTypesHelper, emptyStore, exceptionalExitStores, flowByDefault, flowResult, flowResultAnalysisCaches, formalParameterPattern, hasOrIsSubchecker, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, relevantJavaTypes, returnStatementStores, scannedClasses, shouldClearSubcheckerSharedCFGs, sideEffectsUnrefineAliases, subcheckerSharedCFG, transfer, treeAnnotator, typeAnnotatorFields inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
ajavaTypes, annotatedForValueElement, artificialTreeToEnclosingElementMap, 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, root, shouldCache, stubTypes, trees, typeArgumentInference, typeFormatter, typeHierarchy, typeInformationPresenter, types, typeVarSubstitutor, uid, wpiOutputFormat -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComputedTypeAnnotations(Tree tree, AnnotatedTypeMirror type, boolean useFlow) voidaddComputedTypeAnnotations(Element element, AnnotatedTypeMirror type) To add annotations to the type of method or constructor parameters, add aTypeAnnotatorusingGenericAnnotatedTypeFactory.createTypeAnnotator()and see the comment inTypeAnnotator.visitExecutable(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType, Void).voidaddComputedTypeAnnotationsForWarnRedundant(Tree tree, AnnotatedTypeMirror type, boolean useFlow) protected DefaultQualifierForUseTypeAnnotatorCreates anDefaultQualifierForUseTypeAnnotator.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.getTypeDeclarationBounds(TypeMirror typeMirror) Returns the set of qualifiers that are the upper bounds for a use of the type.Unbox type and replace any interning type annotations with @Interned since all primitives can safely use ==.Methods inherited from class org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
createFlowAnalysisMethods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultAnnotations, getDefaultAnnotationsForWarnRedundant, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, getDependentTypesHelper, getEmptyStore, getEnsuresQualifierIfResult, getExceptionalExitStore, getExplicitNewClassAnnos, getExplicitNewClassClassTypeArgs, getExpressionAndOffsetFromJavaExpressionString, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getNodesForTree, getPostconditionAnnotations, getPostconditionAnnotations, getPostconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreconditionAnnotations, getPreOrPostconditionAnnotations, getQualifierPolymorphism, getRegularExitStore, getReturnStatementStores, getSharedCFGForTree, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, getTypeFactoryOfSubcheckerOrNull, handleCFGViz, irrelevantExtraMessage, isIgnoredExceptionType, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
adaptGetClassReturnTypeToReceiver, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, constructorFromUse, constructorFromUseWithoutTypeArgInference, containsCapturedTypes, containsSameByClass, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierUpperBounds, createSupportedTypeQualifiers, createTypeArgumentInference, createTypeHierarchy, createTypeInformationPresenter, 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, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingClassOrMethod, getEnclosingElementForArtificialTree, getEnclosingSubType, getEnclosingType, getEnumConstructorQualifiers, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFunctionTypeFromTree, getFunctionTypeFromTree, getImplicitReceiverType, getIterableElementType, getIterableElementType, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getResultingTypeOfConstructorMemberReference, getSelfType, getStringType, getSupportedTypeQualifierNames, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getVisitorTreePath, getWholeProgramInference, getWidenedAnnotations, getWidenedType, getWidenedType, hasExplicitNoQualifierParameterInHierarchy, hasExplicitQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, hasQualifierParameterInHierarchy, initializeAtm, initializeReflectionResolution, isDeterministic, isFromByteCode, isFromStubFile, isImmutable, isSideEffectFree, isSupportedQualifier, isSupportedQualifier, isSupportedQualifier, isTop, isWithinConstructor, logGat, makeConditionConsistentWithOtherMethod, mergeAnnotationFileAnnosIntoType, methodFromUse, methodFromUse, methodFromUse, methodFromUseWithoutTypeArgInference, methodFromUseWithoutTypeArgInference, negateConstant, order, parseAnnotationFiles, postProcessClassTree, replaceAnnotations, replaceAnnotations, setEnclosingElementForArtificialTree, setVisitorTreePath, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonField, wpiPrepareMethodForWriting, wpiPrepareMethodForWriting, wpiShouldInferTypesForReceivers
-
Constructor Details
-
InterningAnnotatedTypeFactory
Creates a newInterningAnnotatedTypeFactory.- Parameters:
checker- the checker to use
-
-
Method Details
-
createDefaultForUseTypeAnnotator
Description copied from class:GenericAnnotatedTypeFactoryCreates anDefaultQualifierForUseTypeAnnotator.- Overrides:
createDefaultForUseTypeAnnotatorin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Returns:
- a new
DefaultQualifierForUseTypeAnnotator
-
getTypeDeclarationBounds
Description copied from class:AnnotatedTypeFactoryReturns the set of qualifiers that are the upper bounds for a use of the type.- Overrides:
getTypeDeclarationBoundsin classAnnotatedTypeFactory- Parameters:
typeMirror- a type whose upper bounds to obtain- Returns:
- the set of qualifiers that are the upper bounds for a use of the type
-
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,CFStore, CFTransfer, CFAnalysis> - 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<CFValue,CFStore, CFTransfer, CFAnalysis> - Returns:
- a type annotator
-
addComputedTypeAnnotations
Description copied from class:GenericAnnotatedTypeFactoryLikeGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror). Overriding implementations typically simply pass the boolean to calls to super.- Overrides:
addComputedTypeAnnotationsin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
tree- an AST nodetype- the type obtained from treeuseFlow- whether to use information from dataflow analysis
-
addComputedTypeAnnotationsForWarnRedundant
public void addComputedTypeAnnotationsForWarnRedundant(Tree tree, AnnotatedTypeMirror type, boolean useFlow) Description copied from class:GenericAnnotatedTypeFactoryLikeGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror, boolean).For use ONLY by the
-AwarnRedundantAnnotationscommand-line option. May add fewer annotations thanGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror, boolean).- Overrides:
addComputedTypeAnnotationsForWarnRedundantin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
tree- an AST nodetype- the type obtained from treeuseFlow- whether to use information from dataflow analysis
-
addComputedTypeAnnotations
Description copied from class:GenericAnnotatedTypeFactoryTo add annotations to the type of method or constructor parameters, add aTypeAnnotatorusingGenericAnnotatedTypeFactory.createTypeAnnotator()and see the comment inTypeAnnotator.visitExecutable(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType, Void).- Overrides:
addComputedTypeAnnotationsin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
element- an elementtype- the type obtained fromelt
-
getUnboxedType
public AnnotatedTypeMirror.AnnotatedPrimitiveType getUnboxedType(AnnotatedTypeMirror.AnnotatedDeclaredType type) Unbox type and replace any interning type annotations with @Interned since all primitives can safely use ==. See case 4 in the class comments.Returns the annotated primitive type of the given declared type if it is a boxed declared type. Otherwise, it throws IllegalArgumentException exception.
In the
AnnotatedTypeFactoryimplementation, the returned type has the same primary annotations as the given type. Subclasses may override this behavior.- Overrides:
getUnboxedTypein classAnnotatedTypeFactory- Parameters:
type- the declared type- Returns:
- the unboxed primitive type
-