Class InitializationStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
java.lang.Object
org.checkerframework.framework.flow.CFAbstractStore<V,S>
org.checkerframework.checker.initialization.InitializationStore<V,S>
- Type Parameters:
V- the type of values in the abstract storeS- the type of the abstract store
- All Implemented Interfaces:
Store<S>,org.plumelib.util.UniqueId
- Direct Known Subclasses:
NullnessStore
public class InitializationStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
extends CFAbstractStore<V,S>
A store that extends
CFAbstractStore and additionally tracks which fields of the 'self'
reference have been initialized.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.checkerframework.dataflow.analysis.Store
Store.FlowRule, Store.Kind -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Set<VariableElement> The set of fields that are initialized.protected final Map<FieldAccess, V> The set of fields that have the 'invariant' annotation, and their value.Fields inherited from class org.checkerframework.framework.flow.CFAbstractStore
analysis, arrayValues, classValues, fieldValues, iteratedCollectionElements, localVariableValues, methodCallExpressions, sequentialSemantics, thisValue -
Constructor Summary
ConstructorsConstructorDescriptionInitializationStore(CFAbstractAnalysis<V, S, ?> analysis, boolean sequentialSemantics) Creates a new InitializationStore.InitializationStore(S other) A copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidMarks the field identified by the elementfas initialized (the caller needs to ensure that the field belongs to the current class, or is a static field).voidaddInitializedField(FieldAccess field) Marks the field identified by the elementfieldas initialized if it belongs to the current class, or is static (in which case there is no aliasing issue and we can just add all static fields).protected intReturns the contribution of the keys ofCFAbstractStore.fieldValuestoCFAbstractStore.hashCode().CFAbstractAnalysis<V, S, ?> Returns the analysis associated with this store.voidinsertValue(JavaExpression je, V value, boolean permitNondeterministic) protected StringinternalVisualize(CFGVisualizer<V, S, ?> viz) Adds a representation of the internal information of this Store to visualizerviz.booleanReturns true if the field identified by the elementfis initialized.leastUpperBound(S other) Computes the least upper bound of two stores.protected booleansupersetOf(CFAbstractStore<V, S> o) Returns true iff thisCFAbstractStorecontains a superset of the map entries of the argumentCFAbstractStore.voidRemoves any information that might not be valid any more after a method call, and adds information guaranteed by the method.Methods inherited from class org.checkerframework.framework.flow.CFAbstractStore
canAlias, canInsertJavaExpression, clearValue, computeNewValueAndInsert, copy, equals, getFieldValue, getFieldValues, getIteratedCollectionElement, getUid, getValue, getValue, getValue, getValue, getValue, getValue, hashCode, initializeMethodParameter, initializeThisValue, insertOrRefine, insertOrRefine, insertOrRefinePermitNondeterministic, insertThisValue, insertValue, insertValue, insertValuePermitNondeterministic, insertValuePermitNondeterministic, isMonotonicUpdate, newFieldValueAfterMethodCall, newMonotonicFieldValueAfterMethodCall, removeConflicting, removeConflicting, removeConflicting, replaceValue, replaceValue, shouldInsert, toString, updateForArrayAssignment, updateForAssignment, updateForFieldAccessAssignment, updateForLocalVariableAssignment, visualize, widenedUpperBoundMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.plumelib.util.UniqueId
getClassAndUid
-
Field Details
-
initializedFields
The set of fields that are initialized. -
invariantFields
The set of fields that have the 'invariant' annotation, and their value.
-
-
Constructor Details
-
InitializationStore
Creates a new InitializationStore.- Parameters:
analysis- the analysis class this store belongs tosequentialSemantics- true if the analysis should use sequential Java semantics
-
InitializationStore
A copy constructor.
-
-
Method Details
-
insertValue
Helper method forCFAbstractStore.insertValue(JavaExpression, CFAbstractValue)andCFAbstractStore.insertValuePermitNondeterministic(org.checkerframework.dataflow.expression.JavaExpression, javax.lang.model.element.AnnotationMirror).Every overriding implementation should start with
if (!shouldInsert) { return; }If the receiver is a field, and has an invariant annotation, then it can be considered initialized.
- Overrides:
insertValuein classCFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V, S>> - Parameters:
je- the expression to insert in the storevalue- the value of the expressionpermitNondeterministic- if false, does nothing ifexpris nondeterministic; if true, permits nondeterministic expressions to be placed in the store
-
updateForMethodCall
Removes any information that might not be valid any more after a method call, and adds information guaranteed by the method.- If the method is side-effect-free (as determined by
AnnotatedTypeFactory.isSideEffectFree(javax.lang.model.element.ExecutableElement)), then no information needs to be removed. - Otherwise, all information about field accesses
a.fneeds to be removed, except if the method cannot modifya.f. This unmodifiability property holds ifais a local variable orthis, andfis final, or ifa.fhas aMonotonicQualifierin the current store. Subclasses can change this behavior by overridingCFAbstractStore.newFieldValueAfterMethodCall(FieldAccess, GenericAnnotatedTypeFactory, CFAbstractValue). - Furthermore, if the field has a monotonic annotation, then its information can also be kept.
valin the store.Additionally, the
InitializationStorekeeps all field values for fields that have the 'invariant' annotation.- Overrides:
updateForMethodCallin classCFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V, S>> - Parameters:
n- method whose information is being updatedval- abstract value of the method call, or null to store no value for the method call
- If the method is side-effect-free (as determined by
-
addInitializedField
Marks the field identified by the elementfieldas initialized if it belongs to the current class, or is static (in which case there is no aliasing issue and we can just add all static fields).- Parameters:
field- a field that is initialized
-
addInitializedField
Marks the field identified by the elementfas initialized (the caller needs to ensure that the field belongs to the current class, or is a static field).- Parameters:
f- a field that is initialized
-
isFieldInitialized
Returns true if the field identified by the elementfis initialized.- Parameters:
f- a field- Returns:
- true if the field
fis initialized
-
supersetOf
Description copied from class:CFAbstractStoreReturns 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.- Overrides:
supersetOfin classCFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V, S>> - Parameters:
o- a store- Returns:
- true iff this store contains a superset of the map entries of
other
-
fieldValuesKeysHashCode
protected int fieldValuesKeysHashCode()Description copied from class:CFAbstractStoreReturns the contribution of the keys ofCFAbstractStore.fieldValuestoCFAbstractStore.hashCode(). The result is the hash code of a set of field accesses, as defined bySet.hashCode(): the sum of the hash codes of its elements.A subclass whose
supersetOfignores some entries offieldValuesmust override this method to ignore the same entries, so thathashCoderemains consistent withequals.- Overrides:
fieldValuesKeysHashCodein classCFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V, S>> - Returns:
- the contribution of the keys of
fieldValuestohashCode
-
leastUpperBound
Description copied from interface:StoreComputes 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 interfaceStore<V extends CFAbstractValue<V>>- Overrides:
leastUpperBoundin classCFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V, S>>
- Does not change
-
internalVisualize
Description copied from class:CFAbstractStoreAdds a representation of the internal information of this Store to visualizerviz.- Overrides:
internalVisualizein classCFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V, S>> - Parameters:
viz- the visualizer- Returns:
- a representation of the internal information of this
Store
-
getAnalysis
Returns the analysis associated with this store.- Returns:
- the analysis associated with this store
-