public abstract class AccumulationAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
New accumulation checkers should extend this class and implement a constructor, which should
take a BaseTypeChecker and call both the constructor defined in this class and GenericAnnotatedTypeFactory.postInit().
| Modifier and Type | Class and Description |
|---|---|
protected class |
AccumulationAnnotatedTypeFactory.AccumulationQualifierHierarchy
All accumulation analyses share a similar type hierarchy.
|
protected class |
AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
This tree annotator implements the following rule(s):
RRA
If a method returns its receiver, and the receiver has an accumulation type, then the
default type of the method's return value is the type of the receiver.
|
GenericAnnotatedTypeFactory.ScanStateAnnotatedTypeFactory.ParameterizedExecutableType| Modifier and Type | Field and Description |
|---|---|
AccumulationChecker |
accumulationChecker
The typechecker associated with this factory.
|
AnnotationMirror |
bottom
The canonical bottom annotation for this accumulation checker.
|
AnnotationMirror |
top
The canonical top annotation for this accumulation checker: an instance of the accumulator
annotation with no arguments.
|
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| Modifier | Constructor and Description |
|---|---|
protected |
AccumulationAnnotatedTypeFactory(BaseTypeChecker checker,
Class<? extends Annotation> accumulator,
Class<? extends Annotation> bottom)
Create an annotated type factory for an accumulation checker.
|
protected |
AccumulationAnnotatedTypeFactory(BaseTypeChecker checker,
Class<? extends Annotation> accumulator,
Class<? extends Annotation> bottom,
@Nullable Class<? extends Annotation> predicate)
Create an annotated type factory for an accumulation checker.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
convertToPredicate(AnnotationMirror anno)
Converts the given annotation mirror to a predicate.
|
AnnotationMirror |
createAccumulatorAnnotation(List<String> values)
Creates a new instance of the accumulator annotation that contains the elements of
values. |
AnnotationMirror |
createAccumulatorAnnotation(String value)
Creates a new instance of the accumulator annotation that contains exactly one value.
|
protected AnnotationMirror |
createPredicateAnnotation(String p)
Creates a new predicate annotation from the given string.
|
protected QualifierHierarchy |
createQualifierHierarchy()
Returns the
QualifierHierarchy to be used by this checker. |
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based on the contents of a
tree. |
protected boolean |
evaluatePredicate(AnnotationMirror subAnno,
String pred)
Evaluates whether the accumulator annotation
subAnno makes the predicate pred
true. |
protected boolean |
evaluatePredicate(List<String> trueVariables,
String pred)
Evaluates whether treating the variables in
trueVariables as true literals (and
all other names as false literals) makes the predicate pred evaluate to true. |
List<String> |
getAccumulatedValues(AnnotationMirror anno)
Returns all the values that anno has accumulated.
|
boolean |
isAccumulatorAnnotation(AnnotationMirror anm)
Is the given annotation an accumulator annotation? Returns false if the argument is
bottom. |
protected boolean |
isPredicate(AnnotationMirror anno)
Returns true if anno is a predicate annotation.
|
protected boolean |
isPredicateSubtype(String p,
String q)
Extension point for subtyping behavior between predicates.
|
boolean |
returnsThis(MethodInvocationTree tree)
Returns true if the return type of the given method invocation tree has an @This annotation
from the Returns Receiver Checker.
|
createFlowAnalysisaddAnnotationsFromDefaultForType, addCheckedCodeDefaults, addCheckedStandardDefaults, addComputedTypeAnnotations, addComputedTypeAnnotations, addComputedTypeAnnotations, addDefaultAnnotations, addSharedCFGForTree, addUncheckedStandardDefaults, analyze, applyInferredAnnotations, applyQualifierParameterDefaults, applyQualifierParameterDefaults, checkAndPerformFlowAnalysis, checkForDefaultQualifierInHierarchy, constructorFromUse, constructorFromUsePreSubstitution, createAndInitQualifierDefaults, createCFGVisualizer, createContractsFromMethod, createDefaultForTypeAnnotator, createDefaultForUseTypeAnnotator, createDependentTypesHelper, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, createRequiresOrEnsuresQualifier, createTypeAnnotator, 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, methodFromUsePreSubstitution, parseJavaExpressionString, performFlowAnalysis, postAnalyze, postAsMemberOf, postDirectSuperTypes, postInit, preProcessClassTree, setRoot, 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, createQualifierUpperBounds, createSupportedTypeQualifiers, 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, wpiAdjustForUpdateNonFieldpublic final AccumulationChecker accumulationChecker
public final AnnotationMirror top
public final AnnotationMirror bottom
protected AccumulationAnnotatedTypeFactory(BaseTypeChecker checker, Class<? extends Annotation> accumulator, Class<? extends Annotation> bottom, @Nullable Class<? extends Annotation> predicate)
checker - the checkeraccumulator - the accumulator type in the hierarchy. Must be an annotation with a single
argument named "value" whose type is a String array.bottom - the bottom type in the hierarchy, which must be a subtype of accumulator.
The bottom type should be an annotation with no arguments.predicate - the predicate annotation. Either null (if predicates are not supported), or an
annotation with a single element named "value" whose type is a String.protected AccumulationAnnotatedTypeFactory(BaseTypeChecker checker, Class<? extends Annotation> accumulator, Class<? extends Annotation> bottom)
checker - the checkeraccumulator - the accumulator type in the hierarchy. Must be an annotation with a single
argument named "value" whose type is a String array.bottom - the bottom type in the hierarchy, which must be a subtype of accumulator.
The bottom type should be an annotation with no arguments.public AnnotationMirror createAccumulatorAnnotation(List<String> values)
values.values - the arguments to the annotation. The values can contain duplicates and can be in
any order.values's
arguments; this is top if values is emptypublic AnnotationMirror createAccumulatorAnnotation(String value)
value - the argument to the annotationvalue as its
argumentpublic boolean returnsThis(MethodInvocationTree tree)
tree - a method invocation treepublic boolean isAccumulatorAnnotation(AnnotationMirror anm)
bottom.anm - an annotation mirrorprotected 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 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 List<String> getAccumulatedValues(AnnotationMirror anno)
anno - an accumulator annotation; must not be bottomprotected boolean isPredicateSubtype(String p, String q)
p - a predicateq - another predicateprotected boolean evaluatePredicate(AnnotationMirror subAnno, String pred)
subAnno makes the predicate pred
true.subAnno - an accumulator annotationpred - a predicateprotected boolean evaluatePredicate(List<String> trueVariables, String pred)
trueVariables as true literals (and
all other names as false literals) makes the predicate pred evaluate to true.trueVariables - a list of names that should be replaced with truepred - a predicateprotected AnnotationMirror createPredicateAnnotation(String p)
p - a valid predicateprotected String convertToPredicate(AnnotationMirror anno)
anno - an annotationprotected boolean isPredicate(AnnotationMirror anno)
anno - an annotation