public class UpperBoundAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
Rules implemented by this class:
| Modifier and Type | Class and Description |
|---|---|
protected class |
UpperBoundAnnotatedTypeFactory.UpperBoundQualifierHierarchy
The qualifier hierarchy for the upperbound type system.
|
protected class |
UpperBoundAnnotatedTypeFactory.UpperBoundTreeAnnotator |
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
javax.lang.model.element.AnnotationMirror |
BOTTOM
The @
UpperBoundBottom annotation. |
javax.lang.model.element.AnnotationMirror |
POLY
The @
PolyUpperBound annotation. |
javax.lang.model.element.AnnotationMirror |
UNKNOWN
The @
UpperBoundUnknown annotation. |
analysis, cfgVisualizer, defaults, dependentTypesHelper, emptyStore, flowByDefault, flowResult, flowResultAnalysisCaches, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, transfer, treeAnnotator, typeAnnotatorchecker, elements, fromExpressionTreeCache, fromMemberTreeCache, fromTypeTreeCache, ignoreUninferredTypeArguments, loader, objectGetClass, processingEnv, qualHierarchy, qualifierUpperBounds, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState| Constructor and Description |
|---|
UpperBoundAnnotatedTypeFactory(BaseTypeChecker checker)
Create a new UpperBoundAnnotatedTypeFactory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComputedTypeAnnotations(javax.lang.model.element.Element element,
AnnotatedTypeMirror type)
To add annotations to the type of method or constructor parameters, add a
TypeAnnotator using GenericAnnotatedTypeFactory.createTypeAnnotator() and see the comment in TypeAnnotator#visitExecutable(AnnotatedExecutableType, Void). |
void |
addComputedTypeAnnotations(com.sun.source.tree.Tree tree,
AnnotatedTypeMirror type,
boolean iUseFlow)
|
javax.lang.model.element.AnnotationMirror |
convertUBQualifierToAnnotation(UBQualifier qualifier) |
protected DependentTypesHelper |
createDependentTypesHelper()
Creates an
DependentTypesHelper and returns it. |
QualifierHierarchy |
createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
Factory method to easily change what QualifierHierarchy is created.
|
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
createSupportedTypeQualifiers()
Returns a mutable set of annotation classes that are supported by a checker.
|
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. |
LessThanAnnotatedTypeFactory |
getLessThanAnnotatedTypeFactory()
Returns the LessThan Checker's annotated type factory.
|
boolean |
hasLowerBoundTypeByClass(Node node,
java.lang.Class<? extends java.lang.annotation.Annotation> classOfType)
Returns true iff the given node has the passed Lower Bound qualifier according to the LBC.
|
boolean |
isMathMin(com.sun.source.tree.Tree methodTree) |
boolean |
isRandomNextInt(com.sun.source.tree.Tree methodTree)
Returns true if the tree is for
Random.nextInt(int). |
javax.lang.model.element.AnnotationMirror |
sameLenAnnotationFromTree(com.sun.source.tree.Tree tree)
Queries the SameLen Checker to return the type that the SameLen Checker associates with the
given tree.
|
createFlowAnalysisaddAnnotationsFromDefaultQualifierForUse, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addDefaultAnnotations, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createAndInitQualifierDefaults, createCFGVisualizer, createDefaultForUseTypeAnnotator, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotatedTypeRhsUnaryAssign, getAnnotatedTypeVarargsArray, getAnnotationFromJavaExpressionString, getAnnotationFromReceiver, getAnnotationMirrorFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getFirstNodeOfKindForTree, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodesForTree, getQualifierPolymorphism, getReceiverAndOffsetFromJavaExpressionString, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreAfter, getStoreAfter, getStoreBefore, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUseadaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedAnnotation, addAliasedDeclAnnotation, addAnnotationFromFieldInvariant, addInheritedAnnotation, canonicalAnnotation, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationClassLoader, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createQualifierUpperBounds, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFormatter, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getCacheSize, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getDefaultTypeDeclarationBounds, getDummyAssignedTo, getElementUtils, getEnclosingElementForArtificialTree, getEnclosingType, getExpressionAndOffset, getFieldInvariantAnnotationTree, getFieldInvariantDeclarationAnnotations, getFieldInvariants, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeDeclarationBounds, getTypeHierarchy, getTypeOfExtendsImplements, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initializeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, negateConstant, parseStubFiles, postAsMemberOf, postProcessClassTree, postTypeVarSubstitution, setEnclosingElementForArtificialTree, shouldWarnIfStubRedundantWithBytecode, toAnnotatedType, toString, type, widenToUpperBoundpublic final javax.lang.model.element.AnnotationMirror UNKNOWN
UpperBoundUnknown annotation.public final javax.lang.model.element.AnnotationMirror BOTTOM
UpperBoundBottom annotation.public final javax.lang.model.element.AnnotationMirror POLY
PolyUpperBound annotation.public UpperBoundAnnotatedTypeFactory(BaseTypeChecker checker)
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.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 PolyAll, and 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 not support PolyAll, see examples below.
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:
PolyAll:
This is the default behavior. Simply place those annotations within the qual directory.
PolyAll:
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) with no parameters passed in. Code
example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll();
}
PolyAll,
and a list of other annotations:
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) with a varargs parameter list of the
other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithPolyAll(Regex.class, PartialRegex.class, RegexBottom.class, UnknownRegex.class);
}
PolyAll:
Place those annotations within the qual directory, and override AnnotatedTypeFactory.createSupportedTypeQualifiers() by calling AnnotatedTypeFactory.getBundledTypeQualifiersWithoutPolyAll(Class...) with a varargs parameter list of the
other annotations. Code example:
@Override protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll(UnknownFormat.class, FormatBottom.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.getBundledTypeQualifiersWithoutPolyAll(Class...) and AnnotatedTypeFactory.getBundledTypeQualifiersWithPolyAll(Class...) each must return a fresh, mutable set
createSupportedTypeQualifiers in class AnnotatedTypeFactorypublic LessThanAnnotatedTypeFactory getLessThanAnnotatedTypeFactory()
public void addComputedTypeAnnotations(javax.lang.model.element.Element element,
AnnotatedTypeMirror type)
GenericAnnotatedTypeFactoryTypeAnnotator using GenericAnnotatedTypeFactory.createTypeAnnotator() and see the comment in TypeAnnotator#visitExecutable(AnnotatedExecutableType, Void).addComputedTypeAnnotations in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>element - an elementtype - the type obtained from eltpublic void addComputedTypeAnnotations(com.sun.source.tree.Tree tree,
AnnotatedTypeMirror type,
boolean iUseFlow)
GenericAnnotatedTypeFactoryGenericAnnotatedTypeFactory.addComputedTypeAnnotations(Tree, AnnotatedTypeMirror). Overriding
implementations typically simply pass the boolean to calls to super.addComputedTypeAnnotations 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.
DefaultForTypeAnnotator: Adds annotations based on DefaultFor
meta-annotations.
createTypeAnnotator in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>protected DependentTypesHelper createDependentTypesHelper()
GenericAnnotatedTypeFactoryDependentTypesHelper and returns it.createDependentTypesHelper in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>DependentTypesHelperpublic javax.lang.model.element.AnnotationMirror sameLenAnnotationFromTree(com.sun.source.tree.Tree tree)
public boolean isMathMin(com.sun.source.tree.Tree methodTree)
public boolean isRandomNextInt(com.sun.source.tree.Tree methodTree)
Random.nextInt(int).methodTree - a tree to checkRandom.nextInt(int)public boolean hasLowerBoundTypeByClass(Node node, java.lang.Class<? extends java.lang.annotation.Annotation> classOfType)
public QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactorycreateQualifierHierarchy in class AnnotatedTypeFactorypublic 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>public javax.lang.model.element.AnnotationMirror convertUBQualifierToAnnotation(UBQualifier qualifier)