fr.umlv.corosol.component.impl
Class DefaultJReferenceManager

java.lang.Object
  extended by fr.umlv.corosol.component.impl.DefaultJReferenceManager
All Implemented Interfaces:
JObject, JReferenceManager, JVMComponent

public class DefaultJReferenceManager
extends java.lang.Object
implements JReferenceManager

This is the default implementation of the JReferenceManager interface. The reference is read and written as int value into the specified heap.

Author:
Christophe Deleray

Constructor Summary
DefaultJReferenceManager()
          Creates a new DefaultJReferenceManager object.
 
Method Summary
 void assignReference(JHeapObject object)
          Assigns a new reference to the specified object and saves the association .
 void configure(JVirtualMachine jvm)
          Configures the reference manager via the specified JVM.
 java.lang.Class getComponentClass()
          Returns the class object describing this component.
 java.util.Iterator getObjects()
          Returns an iterator over all the referenced objects.
 JHeapObject readReference(JHeap heap, int index)
          Reads a reference value starting at the specified position in the specified heap and returns the object it referents to.
 void replace(JVMComponent component)
          Replaces the data of this heap by the data of the specified component.
 int sizeofReference(JHeap heap)
          Returns the size of a reference value the size in bytes into the specified Corosol heap.
 JHeapObject wrapNativeObject(java.lang.Object nativeObject)
          Returns the specified object (class instance or array) allocated into the underlaying JVM heap as a JHeapObject object and assigns a new reference to this new object.
 JReturnAddress wrapPC(int pc)
          Returns the returnAddress value corresponding to the specified program counter.
 void writeReference(JHeap heap, int index, JHeapObject object)
          Writes the reference of the specified object at the specified position in the specified heap.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultJReferenceManager

public DefaultJReferenceManager()
Creates a new DefaultJReferenceManager object.

Method Detail

getComponentClass

public java.lang.Class getComponentClass()
Returns the class object describing this component.

Specified by:
getComponentClass in interface JVMComponent

configure

public void configure(JVirtualMachine jvm)
Configures the reference manager via the specified JVM.

Specified by:
configure in interface JVMComponent
Parameters:
jvm - the Java Virtual Machine

replace

public void replace(JVMComponent component)
Replaces the data of this heap by the data of the specified component. The type of component must be the type of this JReferenceManager component.

Specified by:
replace in interface JVMComponent
Parameters:
component - a component to be used to initialize this heap

readReference

public JHeapObject readReference(JHeap heap,
                                 int index)
Reads a reference value starting at the specified position in the specified heap and returns the object it referents to.

Specified by:
readReference in interface JReferenceManager
Parameters:
heap - a Corosol heap
index - index at which the reference value is to be read
Returns:
the object which the reference is read in this heap

writeReference

public void writeReference(JHeap heap,
                           int index,
                           JHeapObject object)
Writes the reference of the specified object at the specified position in the specified heap.

Specified by:
writeReference in interface JReferenceManager
Parameters:
heap - a Corosol heap
index - index at which the reference value is to be writed
object - the object which reference is to be writed in the heap

sizeofReference

public int sizeofReference(JHeap heap)
Returns the size of a reference value the size in bytes into the specified Corosol heap.

Specified by:
sizeofReference in interface JReferenceManager
Parameters:
heap - a Corosol heap
Returns:
the size of a reference value into the specified heap

assignReference

public void assignReference(JHeapObject object)
Assigns a new reference to the specified object and saves the association .

Specified by:
assignReference in interface JReferenceManager
Parameters:
object - a heap object

wrapNativeObject

public JHeapObject wrapNativeObject(java.lang.Object nativeObject)
Returns the specified object (class instance or array) allocated into the underlaying JVM heap as a JHeapObject object and assigns a new reference to this new object.

Specified by:
wrapNativeObject in interface JReferenceManager
Parameters:
nativeObject - an object allocated into the underlaying JVM heap
Returns:
a JHeapObject wrapping the specified native object

wrapPC

public JReturnAddress wrapPC(int pc)
Returns the returnAddress value corresponding to the specified program counter.

Specified by:
wrapPC in interface JReferenceManager
Parameters:
pc - a program counter into the bytecode array
Returns:
a returnAddress

getObjects

public java.util.Iterator getObjects()
Returns an iterator over all the referenced objects.

Specified by:
getObjects in interface JReferenceManager