Class ElementDefaultAnnotatedTypeFactory
- All Implemented Interfaces:
AnnotationProvider
QualifierDefaults.addElementDefault(javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror, org.checkerframework.framework.qual.TypeUseLocation) directly on package elementdefault.pkg
and on two of its classes, and QualifierDefaults.addPackageDefault(javax.lang.model.element.PackageElement, javax.lang.model.element.AnnotationMirror, org.checkerframework.framework.qual.TypeUseLocation, boolean) on package
elementdefault.nonpropagating, rather than through a written @DefaultQualifier
annotation.
All the calls happen while this factory is being initialized, but they are deliberately
interleaved with queries that populate QualifierDefaults' memoization caches, so that the
tests in framework/tests/elementdefault check that a programmatic default does not depend
on which defaults happened to be queried before it was added. See eisop#2037 and eisop#2047.
Every test that uses this checker must therefore compile all of
framework/tests/elementdefault: the elements this factory annotates are resolved by name, and a
name that does not resolve is an error rather than a silently skipped scenario.
-
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
FieldsModifier and TypeFieldDescriptionstatic final StringCommand-line option that makes this factory register a programmatic element default that conflicts with a@DefaultQualifierwritten on the same declaration.static final StringCommand-line option that makes this factory register a checked code default for a location prohibited by the qualifier's @TargetLocations meta-annotation.static final StringCommand-line option that makes this factory register an element default for a location prohibited by the qualifier's @TargetLocations meta-annotation.static final StringCommand-line option that makes this factory register an unchecked code default for a location prohibited by the qualifier's @TargetLocations meta-annotation.static final StringCommand-line option that makes this factory add an element default too late.static final StringCommand-line option that makes this factory register programmatic defaults for a qualifier carrying @ProgrammaticDefaultLocations for a location not permitted by its @TargetLocations.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 new ElementDefaultAnnotatedTypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds default qualifiers for type-checked code by readingDefaultForandDefaultQualifierInHierarchymeta-annotations.protected Set<Class<? extends Annotation>> Returns a mutable set of annotation classes that are supported by a checker.voidpreProcessClassTree(ClassTree classTree) Performs flow-sensitive type refinement onclassTreeif this type factory is configured to do so.Methods inherited from class org.checkerframework.common.basetype.BaseAnnotatedTypeFactory
createFlowAnalysisMethods inherited from class org.checkerframework.framework.type.GenericAnnotatedTypeFactory
addAnnotationsFromDefaultForType, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotationsWithoutFlow, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, annotationsForIrrelevantJavaType, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, canCacheFlowDependentType, canUseCachedFlowDependentType, checkForDefaultQualifierInHierarchy, clearParsePhaseCache, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, createTreeAnnotator, createTypeAnnotator, getAnnotatedTypeBefore, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractExpressions, getContractsFromMethod, getDefaultAnnosForUses, getDefaultAnnotations, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, 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, isNotFullyInitializedReceiver, isRelevant, isRelevant, isRelevantImpl, isUnreachable, methodFromUse, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysisForClass, performFlowAnalysisForClassImpl, performFlowAnalysisForClassOnce, postAnalyze, postAsMemberOf, postInit, runWithBodyVisitorPath, setRoot, typeVariablesFromUseMethods inherited from class org.checkerframework.framework.type.AnnotatedTypeFactory
adaptGetClassReturnTypeToReceiver, 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, createQualifierHierarchy, 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, getChecker, 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, isImmutable, 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
-
LATE_OPTION
Command-line option that makes this factory add an element default too late.- See Also:
-
CONFLICT_OPTION
Command-line option that makes this factory register a programmatic element default that conflicts with a@DefaultQualifierwritten on the same declaration.- See Also:
-
DISALLOWED_CHECKED_OPTION
Command-line option that makes this factory register a checked code default for a location prohibited by the qualifier's @TargetLocations meta-annotation.- See Also:
-
DISALLOWED_UNCHECKED_OPTION
Command-line option that makes this factory register an unchecked code default for a location prohibited by the qualifier's @TargetLocations meta-annotation.- See Also:
-
DISALLOWED_ELEMENT_OPTION
Command-line option that makes this factory register an element default for a location prohibited by the qualifier's @TargetLocations meta-annotation.- See Also:
-
PROGRAMMATIC_ALLOWED_OPTION
Command-line option that makes this factory register programmatic defaults for a qualifier carrying @ProgrammaticDefaultLocations for a location not permitted by its @TargetLocations.- See Also:
-
-
Constructor Details
-
ElementDefaultAnnotatedTypeFactory
Creates a new ElementDefaultAnnotatedTypeFactory.- Parameters:
checker- the checker
-
-
Method Details
-
addCheckedCodeDefaults
Description copied from class:GenericAnnotatedTypeFactoryAdds default qualifiers for type-checked code by readingDefaultForandDefaultQualifierInHierarchymeta-annotations. Subclasses may override this method to add defaults that cannot be specified with aDefaultFororDefaultQualifierInHierarchymeta-annotations.- Overrides:
addCheckedCodeDefaultsin classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
defs- the QualifierDefault object to which defaults are added
-
preProcessClassTree
Description copied from class:GenericAnnotatedTypeFactoryPerforms flow-sensitive type refinement onclassTreeif this type factory is configured to do so.- Overrides:
preProcessClassTreein classGenericAnnotatedTypeFactory<CFValue,CFStore, CFTransfer, CFAnalysis> - Parameters:
classTree- tree on which to perform flow-sensitive type refinement
-
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:
-