Class JvmShallowHeapAbstractState<ReferenceT,StateT extends LatticeAbstractState<StateT>>
- java.lang.Object
-
- proguard.analysis.cpa.jvm.state.heap.tree.JvmShallowHeapAbstractState<ReferenceT,StateT>
-
- All Implemented Interfaces:
LatticeAbstractState<JvmHeapAbstractState<StateT>>
,AbstractState
,JvmHeapAbstractState<StateT>
public class JvmShallowHeapAbstractState<ReferenceT,StateT extends LatticeAbstractState<StateT>> extends java.lang.Object implements JvmHeapAbstractState<StateT>
A shallow heap models objects as atomic abstract states thus having only one level of depth. Object fields are not modeled. References of wrong types are ignored.
-
-
Field Summary
Fields Modifier and Type Field Description protected StateT
defaultValue
protected java.lang.Class<ReferenceT>
referenceClass
MapAbstractState<ReferenceT,StateT>
referenceToObject
-
Constructor Summary
Constructors Constructor Description JvmShallowHeapAbstractState(MapAbstractState<ReferenceT,StateT> referenceToObject, java.lang.Class<ReferenceT> referenceClass, StateT defaultValue)
Create a shallow heap abstract state returning the specified value for all queries from an existing reference to abstract state map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JvmShallowHeapAbstractState<ReferenceT,StateT>
copy()
Creates a copy of itself.boolean
equals(java.lang.Object o)
void
expand(JvmHeapAbstractState<StateT> otherState)
Expands the state with all the entries from another heap state with reference not already known by the state.<T> StateT
getArrayElementOrDefault(T array, StateT index, StateT defaultValue)
Returns anarray
element at the specifiedindex
or thedefaultValue
, if the element is unset.<T> StateT
getFieldOrDefault(T object, java.lang.String fqn, StateT defaultValue)
Returns a fieldfqn
from a referenceobject
.int
hashCode()
boolean
isLessOrEqual(JvmHeapAbstractState<StateT> abstractState)
Compares itself to theabstractState
.JvmShallowHeapAbstractState<ReferenceT,StateT>
join(JvmHeapAbstractState<StateT> abstractState)
Computes a join over itself and theabstractState
.StateT
newArray(java.lang.String type, java.util.List<StateT> dimensions, JvmCfaNode creationCite)
Creates a new array of a given class with the given dimension sizes at a specific program point and returns a reference to it.StateT
newObject(java.lang.String className, JvmCfaNode creationCite)
Creates a new object of a given class at a specific program point and returns a reference to it.void
reduce(java.util.Set<java.lang.Object> referencesToKeep)
Discards all the references not in {@param referencesToKeep}.<T> void
setArrayElement(T array, StateT index, StateT value)
Sets thearray
elementvalue
at the specifiedindex
.<T> void
setField(T object, java.lang.String fqn, StateT value)
Sets avalue
to a fieldfqn
of a referencedobject
.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface proguard.analysis.cpa.interfaces.AbstractState
getPrecision, getStateByName
-
Methods inherited from interface proguard.analysis.cpa.jvm.state.heap.JvmHeapAbstractState
newObject
-
Methods inherited from interface proguard.analysis.cpa.defaults.LatticeAbstractState
isLess
-
-
-
-
Field Detail
-
referenceToObject
public final MapAbstractState<ReferenceT,StateT extends LatticeAbstractState<StateT>> referenceToObject
-
referenceClass
protected final java.lang.Class<ReferenceT> referenceClass
-
defaultValue
protected final StateT extends LatticeAbstractState<StateT> defaultValue
-
-
Constructor Detail
-
JvmShallowHeapAbstractState
public JvmShallowHeapAbstractState(MapAbstractState<ReferenceT,StateT> referenceToObject, java.lang.Class<ReferenceT> referenceClass, StateT defaultValue)
Create a shallow heap abstract state returning the specified value for all queries from an existing reference to abstract state map.- Parameters:
defaultValue
- the value to be returned by memory accessesreferenceClass
- the class of the reference used for addressingreferenceToObject
- the value to be returned by memory accesses
-
-
Method Detail
-
reduce
public void reduce(java.util.Set<java.lang.Object> referencesToKeep)
Discards all the references not in {@param referencesToKeep}.- Specified by:
reduce
in interfaceJvmHeapAbstractState<ReferenceT>
- Parameters:
referencesToKeep
- information on the references to keep or discard, based on the implementation. Unused in the default implementation
-
expand
public void expand(JvmHeapAbstractState<StateT> otherState)
Expands the state with all the entries from another heap state with reference not already known by the state.- Specified by:
expand
in interfaceJvmHeapAbstractState<ReferenceT>
- Parameters:
otherState
- a heap state from which expanding the heap (e.g. the state calling a method to recover information discarded from it)
-
getFieldOrDefault
public <T> StateT getFieldOrDefault(T object, java.lang.String fqn, StateT defaultValue)
Description copied from interface:JvmHeapAbstractState
Returns a fieldfqn
from a referenceobject
. If there is no abstract state representing the field, returns thedefaultValue
- Specified by:
getFieldOrDefault
in interfaceJvmHeapAbstractState<ReferenceT>
-
setField
public <T> void setField(T object, java.lang.String fqn, StateT value)
Description copied from interface:JvmHeapAbstractState
Sets avalue
to a fieldfqn
of a referencedobject
.- Specified by:
setField
in interfaceJvmHeapAbstractState<ReferenceT>
-
getArrayElementOrDefault
public <T> StateT getArrayElementOrDefault(T array, StateT index, StateT defaultValue)
Description copied from interface:JvmHeapAbstractState
Returns anarray
element at the specifiedindex
or thedefaultValue
, if the element is unset.- Specified by:
getArrayElementOrDefault
in interfaceJvmHeapAbstractState<ReferenceT>
-
setArrayElement
public <T> void setArrayElement(T array, StateT index, StateT value)
Description copied from interface:JvmHeapAbstractState
Sets thearray
elementvalue
at the specifiedindex
.- Specified by:
setArrayElement
in interfaceJvmHeapAbstractState<ReferenceT>
-
newObject
public StateT newObject(java.lang.String className, JvmCfaNode creationCite)
Description copied from interface:JvmHeapAbstractState
Creates a new object of a given class at a specific program point and returns a reference to it.- Specified by:
newObject
in interfaceJvmHeapAbstractState<ReferenceT>
-
newArray
public StateT newArray(java.lang.String type, java.util.List<StateT> dimensions, JvmCfaNode creationCite)
Description copied from interface:JvmHeapAbstractState
Creates a new array of a given class with the given dimension sizes at a specific program point and returns a reference to it.- Specified by:
newArray
in interfaceJvmHeapAbstractState<ReferenceT>
-
join
public JvmShallowHeapAbstractState<ReferenceT,StateT> join(JvmHeapAbstractState<StateT> abstractState)
Description copied from interface:LatticeAbstractState
Computes a join over itself and theabstractState
.- Specified by:
join
in interfaceLatticeAbstractState<ReferenceT>
-
isLessOrEqual
public boolean isLessOrEqual(JvmHeapAbstractState<StateT> abstractState)
Description copied from interface:LatticeAbstractState
Compares itself to theabstractState
.- Specified by:
isLessOrEqual
in interfaceLatticeAbstractState<ReferenceT>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfaceAbstractState
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceAbstractState
- Overrides:
hashCode
in classjava.lang.Object
-
copy
public JvmShallowHeapAbstractState<ReferenceT,StateT> copy()
Description copied from interface:AbstractState
Creates a copy of itself.- Specified by:
copy
in interfaceAbstractState
- Specified by:
copy
in interfaceJvmHeapAbstractState<ReferenceT>
-
-