public class UpperBoundAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
Modifier and Type | Class and Description |
---|---|
protected class |
UpperBoundAnnotatedTypeFactory.UpperBoundQualifierHierarchy
The qualifier hierarchy for the upperbound type system.
|
protected class |
UpperBoundAnnotatedTypeFactory.UpperBoundTreeAnnotator |
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
AnnotationMirror |
BOTTOM |
AnnotationMirror |
UNKNOWN |
analyses, cfgVisualizer, defaults, dependentTypesHelper, FLOW_BY_DEFAULT, flowResult, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, treeAnnotator, typeAnnotator
checker, elements, fromTreeCache, loader, processingEnv, qualHierarchy, reflectionResolver, root, shouldCache, trees, typeArgumentInference, typeFormatter, typeHierarchy, types, typeVarSubstitutor, uid, visitorState
Constructor and Description |
---|
UpperBoundAnnotatedTypeFactory(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
AnnotationMirror |
aliasedAnnotation(AnnotationMirror a)
Returns the canonical annotation for the passed annotation if it is an alias of a canonical
one in the framework.
|
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 Set<Class<? extends 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. |
static String[] |
getValue(AnnotationMirror anno)
Used to get the list of array names that an annotation applies to.
|
boolean |
hasLowerBoundTypeByClass(Node node,
Class<? extends Annotation> classOfType)
Returns true iff the given node has the passed Lower Bound qualifier according to the LBC.
|
boolean |
isMathMin(Tree methodTree) |
boolean |
isRandomNextInt(Tree methodTree) |
int |
minLenFromExpressionTree(ExpressionTree tree)
Queries the MinLen Checker to determine if there is a known minimum length for the array.
|
AnnotationMirror |
sameLenAnnotationFromExpressionTree(ExpressionTree tree)
Queries the SameLen Checker to return the type that the SameLen Checker associates with the
given expression tree.
|
Integer |
valMaxFromExpressionTree(ExpressionTree tree)
Finds the maximum value in the set of values represented by a value checker annotation.
|
Integer |
valMinFromExpressionTree(ExpressionTree tree)
Finds the minimum value in the set of values represented by a value checker annotation.
|
createFlowAnalysis
addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addTypeNameImplicit, addUncheckedCodeDefaults, addUncheckedStandardDefaults, analyze, analyze, applyInferredAnnotations, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, createCFGVisualizer, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createTypeAnnotator, fromNewClass, getAnnotatedTypeLhs, getAnnotatedTypeLhsNoTypeVarDefault, getAnnotationFromJavaExpressionString, getCFGVisualizer, getDependentTypesHelper, getEmptyStore, getFinalLocalValues, getInferredValueFor, getMethodReturnType, getMethodReturnType, getNodeForTree, getReceiverFromJavaExpressionString, getRegularExitStore, getResultingTypeOfConstructorMemberReference, getReturnStatementStores, getShouldDefaultTypeVarLocals, getSortedQualifierNames, getStoreAfter, getStoreBefore, getStoreBefore, getSupportedMonotonicTypeQualifiers, getTypeFactoryOfSubchecker, handleCFGViz, methodFromUse, performFlowAnalysis, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, typeVariablesFromUse
adaptGetClassReturnTypeToReceiver, addAliasedAnnotation, addAliasedDeclAnnotation, addInheritedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, checkInvalidOptionsInferSignatures, createAnnotatedTypeFormatter, createAnnotationFormatter, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createTypeArgumentInference, createTypeHierarchy, createTypeVariableSubstitutor, declarationFromElement, fromElement, fromElement, fromElement, getAnnotatedNullType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getAnnotationFormatter, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getBundledTypeQualifiersWithoutPolyAll, getBundledTypeQualifiersWithPolyAll, getContext, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotationNoAliases, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingMethod, getEnclosingType, getFnInterfaceFromTree, getFnInterfaceFromTree, getImplicitReceiverType, getNarrowedPrimitive, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSelfType, getStringType, getSupportedTypeQualifiers, getTreeUtils, getTypeArgumentInference, getTypeHierarchy, getTypeVarSubstitutor, getUnboxedType, getUninferredWildcardType, getVisitorState, getWholeProgramInference, initilizeReflectionResolution, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, methodFromUse, parseStubFiles, postAsMemberOf, postProcessClassTree, postTypeVarSubstitution, setPathHack, toAnnotatedType, toString, type, widenToUpperBound
public final AnnotationMirror UNKNOWN
public final AnnotationMirror BOTTOM
public UpperBoundAnnotatedTypeFactory(BaseTypeChecker checker)
protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
AnnotatedTypeFactory
Subclasses may override this method and 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.
Annotations located outside the qual subdirectory, or has other ElementType
values must be explicitly listed in code by overriding the AnnotatedTypeFactory.createSupportedTypeQualifiers()
method, as shown below.
Lastly, for checkers that do not want to support PolyAll
, it must also be
explicitly written in code, as shown 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 AnnotatedTypeFactory
public static String[] getValue(AnnotationMirror anno)
protected DependentTypesHelper createDependentTypesHelper()
GenericAnnotatedTypeFactory
DependentTypesHelper
and returns it.createDependentTypesHelper
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
DependentTypesHelper
public AnnotationMirror aliasedAnnotation(AnnotationMirror a)
AnnotatedTypeFactory
Returns an aliased type of the current one
aliasedAnnotation
in class AnnotatedTypeFactory
a
- the qualifier to check for an aliaspublic int minLenFromExpressionTree(ExpressionTree tree)
public AnnotationMirror sameLenAnnotationFromExpressionTree(ExpressionTree tree)
public Integer valMaxFromExpressionTree(ExpressionTree tree)
public Integer valMinFromExpressionTree(ExpressionTree tree)
public boolean isMathMin(Tree methodTree)
public boolean isRandomNextInt(Tree methodTree)
public boolean hasLowerBoundTypeByClass(Node node, Class<? extends Annotation> classOfType)
public QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactory
createQualifierHierarchy
in class AnnotatedTypeFactory
public TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactory
TreeAnnotator
that adds annotations to a type based on the contents of a
tree.
Subclasses may override this method to specify a more appropriate TreeAnnotator
.
The default tree annotator is a ListTreeAnnotator
of the following:
PropagationTreeAnnotator
: Propagates annotations from subtrees.
ImplicitsTreeAnnotator
: Adds annotations based on ImplicitFor
meta-annotations
createTreeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
public AnnotationMirror convertUBQualifierToAnnotation(UBQualifier qualifier)