Class CFAbstractStore<V extends CFAbstractValue<V>,S extends CFAbstractStore<V,S>>  
- All Implemented Interfaces:
- Store<S>,- org.plumelib.util.UniqueId
- Direct Known Subclasses:
- CFStore,- InitializationStore,- KeyForStore,- LockStore
When adding a new field to track values for a code construct (similar to 
 localVariableValues and thisValue), it is important to review all constructors and
 methods in this class for locations where the new field must be handled (such as the copy
 constructor and clearValue), as well as all constructors/methods in subclasses of {code
 CFAbstractStore}. Note that this includes not only overridden methods in the subclasses, but new
 methods in the subclasses as well. Also check if
 BaseTypeVisitor#getJavaExpressionContextFromNode(Node) needs to be updated. Failing to do so may
 result in silent failures that are time consuming to debug.
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.checkerframework.dataflow.analysis.StoreStore.FlowRule, Store.Kind
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final CFAbstractAnalysis<V,S, ?> The analysis class this store belongs to.protected final Map<ArrayAccess,V> Information collected about array elements, using the internal representationArrayAccess.Information collected about classname.class values, using the internal representationClassName.protected Map<FieldAccess,V> Information collected about fields, using the internal representationFieldAccess.protected final Map<LocalVariable,V> Information collected about local variables (including method parameters).protected final Map<MethodCall,V> Information collected about method calls, using the internal representationMethodCall.protected final booleanShould the analysis use sequential Java semantics (i.e., assume that only one thread is running at all times)?protected VInformation collected about the current object.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCFAbstractStore(CFAbstractAnalysis<V, S, ?> analysis, boolean sequentialSemantics) Creates a new CFAbstractStore.protectedCFAbstractStore(CFAbstractStore<V, S> other) Copy constructor.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanCan the objectsaandbbe aliases? Returns a conservative answer (i.e., returnstrueif not enough information is available to determine aliasing).static booleanReturns true ifexprcan be stored in this store.voidclearValue(JavaExpression expr) Remove any knowledge about the expressionexpr(correctly deciding where to remove the information depending on the type of the expressionexpr).protected voidcomputeNewValueAndInsert(JavaExpression expr, @Nullable V value, BinaryOperator<V> merger, boolean permitNondeterministic) Inserts the result of applyingmergertovalueand the previous value forexpr.copy()Returns an exact copy of this store.booleanReturns true if this is equal to the given argument.getFieldValue(FieldAccess fieldAccess) Returns the current abstract value of a field access, ornullif no information is available.Returns information about fields.longgetUid()Returns the current abstract value of a field access, ornullif no information is available.Returns the current abstract value of a field access, ornullif no information is available.Returns the current abstract value of a local variable, ornullif no information is available.Returns the current abstract value of a method call, ornullif no information is available.Returns the current abstract value of the current object, ornullif no information is available.getValue(JavaExpression expr) Returns the current abstract value of a Java expression, ornullif no information is available.inthashCode()voidinitializeMethodParameter(LocalVariableNode p, @Nullable V value) Set the abstract value of a method parameter (only adds the information to the store, does not remove any other knowledge).voidinitializeThisValue(AnnotationMirror a, TypeMirror underlyingType) Set the value of the current object.final voidinsertOrRefine(JavaExpression expr, AnnotationMirror newAnno) Add the annotationnewAnnofor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).protected voidinsertOrRefine(JavaExpression expr, AnnotationMirror newAnno, boolean permitNondeterministic) final voidinsertOrRefinePermitNondeterministic(JavaExpression expr, AnnotationMirror newAnno) LikeinsertOrRefine(JavaExpression, AnnotationMirror), but permits nondeterministic expressions to be inserted.voidinsertThisValue(AnnotationMirror a, TypeMirror underlyingType) final voidinsertValue(JavaExpression expr, @Nullable V value) Add the abstract valuevaluefor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).protected voidinsertValue(JavaExpression expr, @Nullable V value, boolean permitNondeterministic) voidinsertValue(JavaExpression expr, AnnotationMirror a) Add the annotationafor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).final voidinsertValuePermitNondeterministic(JavaExpression expr, @Nullable V value) LikeinsertValue(JavaExpression, CFAbstractValue), but updates the store even ifexpris nondeterministic.voidLikeinsertValue(JavaExpression, AnnotationMirror), but permits nondeterministic expressions to be stored.protected StringinternalVisualize(CFGVisualizer<V, S, ?> viz) Adds a representation of the internal information of this Store to visualizerviz.protected booleanisMonotonicUpdate(FieldAccess fieldAcc, V value) Return true if fieldAcc is an update of a monotonic qualifier to its target qualifier.protected booleanisSideEffectFree(AnnotatedTypeFactory atypeFactory, ExecutableElement method) Deprecated.leastUpperBound(S other) Compute the least upper bound of two stores.protected voidremoveConflicting(ArrayAccess arrayAccess, @Nullable V val) Remove any information in the store that might not be true any more afterarrayAccesshas been assigned a new value (with the abstract valueval).protected voidremoveConflicting(FieldAccess fieldAccess, @Nullable V val) Remove any information in this store that might not be true any more afterfieldAccesshas been assigned a new value (with the abstract valueval).protected voidRemove any information in this store that might not be true any more afterlocalVarhas been assigned a new value.voidreplaceValue(JavaExpression expr, @Nullable V value) Completely replaces the abstract valuevaluefor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).protected booleanshouldInsert(JavaExpression expr, @Nullable V value, boolean permitNondeterministic) Returns true if the given (expression, value) pair can be inserted in the store, namely if the value is non-null and the expression does not contain unknown or a nondeterministic expression.protected booleansupersetOf(CFAbstractStore<V, S> other) Returns true iff thisCFAbstractStorecontains a superset of the map entries of the argumentCFAbstractStore.toString()protected voidupdateForArrayAssignment(ArrayAccess arrayAccess, @Nullable V val) Update the information in the store by considering an assignment with targetn, where the target is an array access.voidupdateForAssignment(Node n, @Nullable V val) Update the information in the store by considering an assignment with targetn.protected voidupdateForFieldAccessAssignment(FieldAccess fieldAccess, @Nullable V val) Update the information in the store by considering a field assignment with targetn, where the right hand side has the abstract valueval.protected voidupdateForLocalVariableAssignment(LocalVariable receiver, @Nullable V val) Set the abstract value of a local variable in the store.voidupdateForMethodCall(MethodInvocationNode methodInvocationNode, AnnotatedTypeFactory atypeFactory, V val) Remove any information that might not be valid any more after a method call, and add information guaranteed by the method.visualize(CFGVisualizer<?, S, ?> viz) Delegate visualization responsibility to a visualizer.widenedUpperBound(S previous) Compute an upper bound of two stores that is wider than the least upper bound of the two stores.Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.plumelib.util.UniqueIdgetClassAndUid
- 
Field Details- 
analysisprotected final CFAbstractAnalysis<V extends CFAbstractValue<V>,S extends CFAbstractStore<V, analysisS>, ?> The analysis class this store belongs to.
- 
localVariableValuesInformation collected about local variables (including method parameters).
- 
thisValueInformation collected about the current object.
- 
fieldValuesInformation collected about fields, using the internal representationFieldAccess.
- 
arrayValuesInformation collected about array elements, using the internal representationArrayAccess.
- 
methodValuesInformation collected about method calls, using the internal representationMethodCall.
- 
classValuesInformation collected about classname.class values, using the internal representationClassName.
- 
sequentialSemanticsprotected final boolean sequentialSemanticsShould the analysis use sequential Java semantics (i.e., assume that only one thread is running at all times)?
 
- 
- 
Constructor Details- 
CFAbstractStoreCreates a new CFAbstractStore.- Parameters:
- analysis- the analysis class this store belongs to
- sequentialSemantics- should the analysis use sequential Java semantics?
 
- 
CFAbstractStoreCopy constructor.- Parameters:
- other- a CFAbstractStore to copy into this
 
 
- 
- 
Method Details- 
getFieldValuesReturns information about fields. Clients should not side-effect the returned value, which is aliased to internal state.- Returns:
- information about fields
 
- 
getUidpublic long getUid()- Specified by:
- getUidin interface- org.plumelib.util.UniqueId
 
- 
initializeMethodParameterSet the abstract value of a method parameter (only adds the information to the store, does not remove any other knowledge). Any previous information is erased; this method should only be used to initialize the abstract value.
- 
initializeThisValueSet the value of the current object. Any previous information is erased; this method should only be used to initialize the value.
- 
isSideEffectFree@Deprecated protected boolean isSideEffectFree(AnnotatedTypeFactory atypeFactory, ExecutableElement method) Indicates whether the given method is side-effect-free as far as the current store is concerned. In some cases, a store for a checker allows for other mechanisms to specify whether a method is side-effect-free. For example, unannotated methods may be considered side-effect-free by default.- Parameters:
- atypeFactory- the type factory used to retrieve annotations on the method element
- method- the method element
- Returns:
- whether the method is side-effect-free
 
- 
updateForMethodCallpublic void updateForMethodCall(MethodInvocationNode methodInvocationNode, AnnotatedTypeFactory atypeFactory, V val) Remove any information that might not be valid any more after a method call, and add information guaranteed by the method.- If the method is side-effect-free (as indicated by SideEffectFreeorPure), then no information needs to be removed.
- Otherwise, all information about field accesses a.fneeds to be removed, except if the methodncannot modifya.f(e.g., ifais a local variable orthis, andfis final).
- Furthermore, if the field has a monotonic annotation, then its information can also be kept.
 valin the store.- Parameters:
- methodInvocationNode- method whose information is being updated
- atypeFactory- AnnotatedTypeFactory of the associated checker
- val- abstract value of the method call
 
- If the method is side-effect-free (as indicated by 
- 
insertValueAdd the annotationafor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).This method does not take care of removing other information that might be influenced by changes to certain parts of the state. If there is already a value vpresent forexpr, then the stronger of the new and old value are taken (according to the lattice). Note that this happens per hierarchy, and if the store already contains information about a hierarchy other thanas hierarchy, that information is preserved.If expris nondeterministic, this method does not insertvalueinto the store.- Parameters:
- expr- an expression
- a- an annotation for the expression
 
- 
insertValuePermitNondeterministicLikeinsertValue(JavaExpression, AnnotationMirror), but permits nondeterministic expressions to be stored.For an explanation of when to permit nondeterministic expressions, see insertValuePermitNondeterministic(JavaExpression, CFAbstractValue).- Parameters:
- expr- an expression
- a- an annotation for the expression
 
- 
insertOrRefineAdd the annotationnewAnnofor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).This method does not take care of removing other information that might be influenced by changes to certain parts of the state. If there is already a value vpresent forexpr, then the greatest lower bound of the new and old value is inserted into the store.Note that this happens per hierarchy, and if the store already contains information about a hierarchy other than newAnno's hierarchy, that information is preserved.If expris nondeterministic, this method does not insertvalueinto the store.- Parameters:
- expr- an expression
- newAnno- the expression's annotation
 
- 
insertOrRefinePermitNondeterministicpublic final void insertOrRefinePermitNondeterministic(JavaExpression expr, AnnotationMirror newAnno) LikeinsertOrRefine(JavaExpression, AnnotationMirror), but permits nondeterministic expressions to be inserted.For an explanation of when to permit nondeterministic expressions, see insertValuePermitNondeterministic(JavaExpression, CFAbstractValue).- Parameters:
- expr- an expression
- newAnno- the expression's annotation
 
- 
insertOrRefineprotected void insertOrRefine(JavaExpression expr, AnnotationMirror newAnno, boolean permitNondeterministic) Helper function forinsertOrRefine(JavaExpression, AnnotationMirror)andinsertOrRefinePermitNondeterministic(org.checkerframework.dataflow.expression.JavaExpression, javax.lang.model.element.AnnotationMirror).- Parameters:
- expr- an expression
- newAnno- the expression's annotation
- permitNondeterministic- whether nondeterministic expressions may be inserted into the store
 
- 
canInsertJavaExpressionReturns true ifexprcan be stored in this store.
- 
insertValueAdd the abstract valuevaluefor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr).This method does not take care of removing other information that might be influenced by changes to certain parts of the state. If there is already a value vpresent forexpr, then the stronger of the new and old value are taken (according to the lattice). Note that this happens per hierarchy, and if the store already contains information about a hierarchy for whichvaluedoes not contain information, then that information is preserved.If expris nondeterministic, this method does not insertvalueinto the store.- Parameters:
- expr- the expression to insert in the store
- value- the value of the expression
 
- 
insertValuePermitNondeterministicLikeinsertValue(JavaExpression, CFAbstractValue), but updates the store even ifexpris nondeterministic.Usually, nondeterministic JavaExpressions should not be stored in a Store. For example, in the body of if (nondet() == 3) {...}, the store should not record that the value ofnondet()is 3, because it might not be 3 the next timenondet()is executed.However, contracts can mention a nondeterministic JavaExpression. For example, a contract might have a postcondition that nondet()is odd. This means that the next call tonondet()will return odd. Such a postcondition may be evicted from the store by calling a side-effecting method.- Parameters:
- expr- the expression to insert in the store
- value- the value of the expression
 
- 
shouldInsert@EnsuresNonNullIf(expression="#2", result=true) protected boolean shouldInsert(JavaExpression expr, @Nullable V value, boolean permitNondeterministic) Returns true if the given (expression, value) pair can be inserted in the store, namely if the value is non-null and the expression does not contain unknown or a nondeterministic expression.This method returning true does not guarantee that the value will be inserted; the implementation of insertValue(JavaExpression, CFAbstractValue, boolean)might still not insert it.- Parameters:
- expr- the expression to insert in the store
- value- the value of the expression
- permitNondeterministic- if false, returns false if- expris nondeterministic; if true, permits nondeterministic expressions to be placed in the store
- Returns:
- true if the given (expression, value) pair can be inserted in the store
 
- 
insertValueHelper method forinsertValue(JavaExpression, CFAbstractValue)andinsertValuePermitNondeterministic(org.checkerframework.dataflow.expression.JavaExpression, javax.lang.model.element.AnnotationMirror).Every overriding implementation should start with if (!shouldInsert) { return; }- Parameters:
- expr- the expression to insert in the store
- value- the value of the expression
- permitNondeterministic- if false, does nothing if- expris nondeterministic; if true, permits nondeterministic expressions to be placed in the store
 
- 
computeNewValueAndInsertprotected void computeNewValueAndInsert(JavaExpression expr, @Nullable V value, BinaryOperator<V> merger, boolean permitNondeterministic) Inserts the result of applyingmergertovalueand the previous value forexpr.- Parameters:
- expr- the JavaExpression
- value- the value of the JavaExpression
- merger- the function used to merge- valueand the previous value of- expr
- permitNondeterministic- if false, does nothing if- expris nondeterministic; if true, permits nondeterministic expressions to be placed in the store
 
- 
isMonotonicUpdateReturn true if fieldAcc is an update of a monotonic qualifier to its target qualifier. (e.g. @MonotonicNonNull to @NonNull). Always returns false ifsequentialSemanticsis true.- Returns:
- true if fieldAcc is an update of a monotonic qualifier to its target qualifier (e.g. @MonotonicNonNull to @NonNull)
 
- 
insertThisValue
- 
replaceValueCompletely replaces the abstract valuevaluefor the expressionexpr(correctly deciding where to store the information depending on the type of the expressionexpr). Any previous information is discarded.This method does not take care of removing other information that might be influenced by changes to certain parts of the state. 
- 
clearValueRemove any knowledge about the expressionexpr(correctly deciding where to remove the information depending on the type of the expressionexpr).
- 
getValueReturns the current abstract value of a Java expression, ornullif no information is available.- Returns:
- the current abstract value of a Java expression, or nullif no information is available
 
- 
getValueReturns the current abstract value of a field access, ornullif no information is available.- Parameters:
- n- the node whose abstract value to return
- Returns:
- the current abstract value of a field access, or nullif no information is available
 
- 
getFieldValueReturns the current abstract value of a field access, ornullif no information is available.- Parameters:
- fieldAccess- the field access to look up in this store
- Returns:
- current abstract value of a field access, or nullif no information is available
 
- 
getValueReturns the current abstract value of a method call, ornullif no information is available.- Parameters:
- n- a method call
- Returns:
- the current abstract value of a method call, or nullif no information is available
 
- 
getValueReturns the current abstract value of a field access, ornullif no information is available.- Parameters:
- n- the node whose abstract value to return
- Returns:
- the current abstract value of a field access, or nullif no information is available
 
- 
updateForAssignmentUpdate the information in the store by considering an assignment with targetn.- Parameters:
- n- the left-hand side of an assignment
- val- the right-hand value of an assignment
 
- 
updateForFieldAccessAssignmentUpdate the information in the store by considering a field assignment with targetn, where the right hand side has the abstract valueval.- Parameters:
- val- the abstract value of the value assigned to- n(or- nullif the abstract value is not known).
 
- 
updateForArrayAssignmentUpdate the information in the store by considering an assignment with targetn, where the target is an array access.See removeConflicting(ArrayAccess,CFAbstractValue), as it is called first by this method.
- 
updateForLocalVariableAssignmentSet the abstract value of a local variable in the store. Overwrites any value that might have been available previously.- Parameters:
- val- the abstract value of the value assigned to- n(or- nullif the abstract value is not known).
 
- 
removeConflictingRemove any information in this store that might not be true any more afterfieldAccesshas been assigned a new value (with the abstract valueval). This includes the following steps (assume thatfieldAccessis of the form a.f for some a.- Update the abstract value of other field accesses b.g where the field
       is equal (that is, f=g), and the receiver b might alias the receiver of
       fieldAccess, a. This update will raise the abstract value for such field accesses to at leastval(or the old value, if that was less precise). However, this is only necessary if the field g is not final.
- Remove any abstract values for field accesses b.g where fieldAccessmight alias any expression in the receiver b.
- Remove any information about method calls.
- Remove any abstract values an array access b[i] where fieldAccessmight alias any expression in the receiver a or index i.
 - Parameters:
- val- the abstract value of the value assigned to- n(or- nullif the abstract value is not known).
 
- Update the abstract value of other field accesses b.g where the field
       is equal (that is, f=g), and the receiver b might alias the receiver of
       
- 
removeConflictingRemove any information in the store that might not be true any more afterarrayAccesshas been assigned a new value (with the abstract valueval). This includes the following steps (assume thatarrayAccessis of the form a[i] for some a.- Remove any abstract value for other array access b[j] where a and b can be aliases, or where either b or j contains a modifiable alias of a[i].
- Remove any abstract values for field accesses b.g where a[i] might alias any expression in the receiver b and there is an array expression somewhere in the receiver.
- Remove any information about method calls.
 - Parameters:
- val- the abstract value of the value assigned to- n(or- nullif the abstract value is not known).
 
- 
removeConflictingRemove any information in this store that might not be true any more afterlocalVarhas been assigned a new value. This includes the following steps:- Remove any abstract values for field accesses b.g where localVarmight alias any expression in the receiver b.
- Remove any abstract values for array accesses a[i] where localVarmight alias the receiver a.
- Remove any information about method calls where the receiver or any of the
       parameters contains localVar.
 
- Remove any abstract values for field accesses b.g where 
- 
canAliasCan the objectsaandbbe aliases? Returns a conservative answer (i.e., returnstrueif not enough information is available to determine aliasing).- Specified by:
- canAliasin interface- Store<V extends CFAbstractValue<V>>
 
- 
getValueReturns the current abstract value of a local variable, ornullif no information is available.- Parameters:
- n- the local variable
- Returns:
- the current abstract value of a local variable, or nullif no information is available
 
- 
getValueReturns the current abstract value of the current object, ornullif no information is available.- Parameters:
- n- a reference to "this"
- Returns:
- the current abstract value of the current object, or nullif no information is available
 
- 
copyDescription copied from interface:StoreReturns an exact copy of this store.- Specified by:
- copyin interface- Store<V extends CFAbstractValue<V>>
- Returns:
- an exact copy of this store
 
- 
leastUpperBoundDescription copied from interface:StoreCompute the least upper bound of two stores.Important: This method must fulfill the following contract: - Does not change this.
- Does not change other.
- Returns a fresh object which is not aliased yet.
- Returns an object of the same (dynamic) type as this, even if the signature is more permissive.
- Is commutative.
 - Specified by:
- leastUpperBoundin interface- Store<V extends CFAbstractValue<V>>
 
- Does not change 
- 
widenedUpperBoundDescription copied from interface:StoreCompute an upper bound of two stores that is wider than the least upper bound of the two stores. Used to jump to a higher abstraction to allow faster termination of the fixed point computations inAnalysis.previousmust be the previous store.A particular analysis might not require widening and should implement this method by calling leastUpperBound. Important: This method must fulfill the following contract: - Does not change this.
- Does not change previous.
- Returns a fresh object which is not aliased yet.
- Returns an object of the same (dynamic) type as this, even if the signature is more permissive.
- Is commutative.
 - Specified by:
- widenedUpperBoundin interface- Store<V extends CFAbstractValue<V>>
- Parameters:
- previous- must be the previous store
 
- Does not change 
- 
supersetOfReturns true iff thisCFAbstractStorecontains a superset of the map entries of the argumentCFAbstractStore. Note that we test the entry keys and values by Java equality, not by any subtype relationship. This method is used primarily to simplify the equals predicate.
- 
equalsDescription copied from interface:StoreReturns true if this is equal to the given argument.
- 
hashCodepublic int hashCode()
- 
toString
- 
visualizeDescription copied from interface:StoreDelegate visualization responsibility to a visualizer.- Specified by:
- visualizein interface- Store<V extends CFAbstractValue<V>>
- Parameters:
- viz- the visualizer to visualize this store
- Returns:
- the String representation of this store
 
- 
internalVisualizeAdds a representation of the internal information of this Store to visualizerviz.- Parameters:
- viz- the visualizer
- Returns:
- a representation of the internal information of this Store
 
 
- 
AnnotationProvider.isSideEffectFree(javax.lang.model.element.ExecutableElement)