Interface HeapManager
-
- All Known Implementing Classes:
SimpleHeapManager
public interface HeapManagerAllocation, string interning, and static-field services for the simulated heap.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclearStaticFields()Discards every stored static field value.StringextractString(ObjectInstance instance)Reads a guest string's character data back into a host string.ObjectgetStaticField(String owner, String name, String descriptor)booleanhasStaticField(String owner, String name, String descriptor)intidentityHashCode(ObjectInstance instance)ObjectInstanceinternString(String value)Returns the pooled guest string for a host string, allocating it on first request.booleanisNull(ObjectInstance instance)default booleanisUsingCompactStrings()ArrayInstancenewArray(String componentType, int length)Allocates a one-dimensional array with default-initialized elements.ArrayInstancenewMultiArray(String componentType, int[] dimensions)Allocates a nested array, filling every dimension but the innermost with sub-arrays.ObjectInstancenewObject(String className)Allocates an instance of a class, with every field unset.longobjectCount()voidputStaticField(String owner, String name, String descriptor, Object value)Stores a static field value, replacing any previous one.default voidsetUseCompactStrings(boolean compact)Selects the string layout used byinternString(java.lang.String); ignored unless overridden.
-
-
-
Method Detail
-
newObject
ObjectInstance newObject(String className)
Allocates an instance of a class, with every field unset.- Parameters:
className- the internal name of the class to instantiate- Returns:
- the new instance
-
newArray
ArrayInstance newArray(String componentType, int length)
Allocates a one-dimensional array with default-initialized elements.- Parameters:
componentType- the internal name or descriptor of the element typelength- the element count- Returns:
- the new array
- Throws:
HeapException- if length is negative
-
newMultiArray
ArrayInstance newMultiArray(String componentType, int[] dimensions)
Allocates a nested array, filling every dimension but the innermost with sub-arrays.- Parameters:
componentType- the internal name or descriptor of the innermost element typedimensions- the length of each dimension, outermost first- Returns:
- the outermost array
- Throws:
HeapException- if dimensions is null, empty, or holds a negative length
-
internString
ObjectInstance internString(String value)
Returns the pooled guest string for a host string, allocating it on first request.- Parameters:
value- the host string to intern- Returns:
- the guest
java/lang/Stringinstance
-
extractString
String extractString(ObjectInstance instance)
Reads a guest string's character data back into a host string.- Parameters:
instance- the guest string, may be null- Returns:
- the host string, or null if the instance is null or is not a string
-
isNull
boolean isNull(ObjectInstance instance)
- Parameters:
instance- the reference to test, may be null- Returns:
- true if the reference is null
-
identityHashCode
int identityHashCode(ObjectInstance instance)
- Parameters:
instance- the instance to identify, may be null- Returns:
- the instance's identity hash, or 0 for null
-
objectCount
long objectCount()
- Returns:
- how many objects are currently allocated
-
putStaticField
void putStaticField(String owner, String name, String descriptor, Object value)
Stores a static field value, replacing any previous one.- Parameters:
owner- the internal name of the declaring classname- the field namedescriptor- the field descriptorvalue- the value to store
-
getStaticField
Object getStaticField(String owner, String name, String descriptor)
- Parameters:
owner- the internal name of the declaring classname- the field namedescriptor- the field descriptor- Returns:
- the stored value, or null if the field was never written
-
hasStaticField
boolean hasStaticField(String owner, String name, String descriptor)
- Parameters:
owner- the internal name of the declaring classname- the field namedescriptor- the field descriptor- Returns:
- true if the field has been written
-
clearStaticFields
void clearStaticFields()
Discards every stored static field value.
-
setUseCompactStrings
default void setUseCompactStrings(boolean compact)
Selects the string layout used byinternString(java.lang.String); ignored unless overridden.- Parameters:
compact- true for the Java 9+ byte-array layout, false for the char-array layout
-
isUsingCompactStrings
default boolean isUsingCompactStrings()
- Returns:
- true if interned strings use the compact byte-array layout, false unless overridden
-
-