public class MustCallAnnotatedTypeFactory extends BaseAnnotatedTypeFactory implements CreatesMustCallForElementSupplier
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
AnnotationMirror |
BOTTOM
|
AnnotationMirror |
TOP
The
@MustCallUnknown annotation. |
analysis, 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 |
|---|
MustCallAnnotatedTypeFactory(BaseTypeChecker checker)
Creates a MustCallAnnotatedTypeFactory.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
constructorFromUsePreSubstitution(NewClassTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
A callback method for the AnnotatedTypeFactory subtypes to customize the handling of the
declared constructor type before type variable substitution.
|
protected DefaultQualifierForUseTypeAnnotator |
createDefaultForUseTypeAnnotator()
Creates an
DefaultQualifierForUseTypeAnnotator. |
AnnotationMirror |
createMustCall(List<String> val)
Creates a
MustCall annotation whose values are the given strings. |
QualifierHierarchy |
createQualifierHierarchy()
Returns the
QualifierHierarchy to be used by this checker. |
protected QualifierUpperBounds |
createQualifierUpperBounds()
Creates
QualifierUpperBounds for this type factory. |
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. |
ExecutableElement |
getCreatesMustCallForListValueElement()
Returns the CreatesMustCallFor.List.value field/element.
|
ExecutableElement |
getCreatesMustCallForValueElement()
Returns the CreatesMustCallFor.value field/element.
|
ExecutableElement |
getMustCallValueElement()
Returns the
MustCall.value() element. |
CFStore |
getStoreForBlock(boolean afterFirstStore,
Block first,
Block succ)
Fetches the store from the results of dataflow for
first. |
@Nullable LocalVariableNode |
getTempVar(Node node)
Return the temporary variable for node, if it exists.
|
void |
methodFromUsePreSubstitution(ExpressionTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
Treat non-owning method parameters as @MustCallUnknown (top) when the method is called.
|
void |
setRoot(@Nullable CompilationUnitTree root)
Set the CompilationUnitTree that should be used.
|
createFlowAnalysisaddAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpression, getAnnotationFromJavaExpressionString, getAnnotationMirrorFromJavaExpressionString, getAnnotationsFromJavaExpression, getCFGVisualizer, getContractAnnotations, getContractAnnotations, getContractExpressions, getContractsFromMethod, getDefaultForTypeAnnotator, getDefaultValueAnnotatedType, 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, methodFromUse, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAliasedTypeAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, applyCaptureConversion, applyCaptureConversion, applyUnboxing, areSameByClass, binaryTreeArgTypes, binaryTreeArgTypes, canonicalAnnotation, checkInvalidOptionsInferSignatures, compoundAssignmentTreeArgTypes, containsSameByClass, containsUninferredTypeArguments, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchyWithMultiGraphFactory, 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, getMethodReturnType, getNarrowedAnnotations, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getQualifierParameterHierarchies, getQualifierParameterHierarchies, getQualifierUpperBounds, getReceiverType, getSelfType, 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, type, wpiAdjustForUpdateField, wpiAdjustForUpdateNonFieldclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCreatesMustCallForExpression, getCreatesMustCallForExpressions, issueUnparseableErrorpublic final AnnotationMirror TOP
@MustCallUnknown annotation.public final AnnotationMirror BOTTOM
public MustCallAnnotatedTypeFactory(BaseTypeChecker checker)
checker - the checker associated with this type factorypublic void setRoot(@Nullable CompilationUnitTree root)
AnnotatedTypeFactorysetRoot in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>root - the new compilation unit to useprotected 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 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 GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>protected 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 GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>public void methodFromUsePreSubstitution(ExpressionTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type)
methodFromUsePreSubstitution in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>tree - either a method invocation or a member reference treetype - declared method type before type variable substitutionprotected void constructorFromUsePreSubstitution(NewClassTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type)
AnnotatedTypeFactoryconstructorFromUsePreSubstitution in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>tree - a NewClassTree from constructorFromUse()type - declared method type before type variable substitutionprotected DefaultQualifierForUseTypeAnnotator createDefaultForUseTypeAnnotator()
GenericAnnotatedTypeFactoryDefaultQualifierForUseTypeAnnotator.createDefaultForUseTypeAnnotator in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>DefaultQualifierForUseTypeAnnotatorpublic ExecutableElement getMustCallValueElement()
MustCall.value() element. For use with AnnotationUtils.getElementValueArray(javax.lang.model.element.AnnotationMirror, java.lang.CharSequence, java.lang.Class<T>, boolean).MustCall.value() elementprotected QualifierUpperBounds createQualifierUpperBounds()
AnnotatedTypeFactoryQualifierUpperBounds for this type factory.createQualifierUpperBounds in class AnnotatedTypeFactoryQualifierUpperBounds for this type factorypublic AnnotationMirror createMustCall(List<String> val)
MustCall annotation whose values are the given strings.val - the methods that should be calledpublic 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 AnnotatedTypeFactorypublic CFStore getStoreForBlock(boolean afterFirstStore, Block first, Block succ)
first. If afterFirstStore is
true, then the store after first is returned; if afterFirstStore is false, the
store before succ is returned.afterFirstStore - whether to use the store after the first block or the store before its
successor, succfirst - a blocksucc - first's successorpublic ExecutableElement getCreatesMustCallForValueElement()
getCreatesMustCallForValueElement in interface CreatesMustCallForElementSupplierpublic ExecutableElement getCreatesMustCallForListValueElement()
getCreatesMustCallForListValueElement in interface CreatesMustCallForElementSupplierpublic @Nullable LocalVariableNode getTempVar(Node node)
#tempVars.node - a CFG node