"

2013 FRC Java API

"

com.sun.squawk
Class ObjectMemoryLoader

java.lang.Object
  extended by com.sun.squawk.ObjectMemoryLoader

public class ObjectMemoryLoader
extends Object

This class facilitates loading a serialized object graph from a URI and relocating it.


Method Summary
static void addFilePath(String path)
          Expecting a string that looks something like "c:\dev\1${File.separatorChar}c:\windows".
protected  int getHash(byte[] arr)
          Calculates the hash of an array of bytes.
static int hash(byte[] arr)
           
static ObjectMemoryFile load(DataInputStream dis, String uri, boolean loadIntoReadOnlyMemory)
          Loads an object memory from a given input stream.
static ObjectMemoryFile load(String uri, boolean loadIntoReadOnlyMemory)
          Loads an object memory from a given input stream.
static ObjectMemoryFile loadHeader(DataInputStream dis, String uri)
          Loads the header of an object memory file from a given input stream.
protected  byte[] loadMemory(int size)
          Loads the 'memory' component of the object memory from the input stream.
protected  BitSet loadOopMap(int size)
          Loads the 'oopmap' component of the object memory from the input stream.
protected  Address relocateMemory(ObjectMemory parent, byte[] buffer, BitSet oopMap)
          Relocates the memory.
static void setFilePath(String path)
          Expecting a string that looks something like "c:\dev\1${File.separatorChar}c:\windows".
protected  void skipMemoryPadding(String parentURI, int memorySize)
          Skips the padding that precedes the 'memory' item to ensure that it is word aligned with respect to the start of the object memory file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHash

protected int getHash(byte[] arr)
Calculates the hash of an array of bytes.

Parameters:
arr - the byte array to hash
Returns:
the hash of arr

hash

public static int hash(byte[] arr)

loadHeader

public static ObjectMemoryFile loadHeader(DataInputStream dis,
                                          String uri)
Loads the header of an object memory file from a given input stream.

Parameters:
dis - the data input stream from which to read
uri - a URI identifying the object memory being loaded
Returns:
the ObjectMemoryFile instance encapsulating only the header information in the stream (i.e. the ObjectMemoryFile.objectMemory field is null)

load

public static ObjectMemoryFile load(DataInputStream dis,
                                    String uri,
                                    boolean loadIntoReadOnlyMemory)
Loads an object memory from a given input stream. If the URI describing the source of the input stream corresponds to the URI of an object memory already present in the system, then that object memory is returned instead.

Parameters:
dis - the data input stream from which to read
uri - a URI identifying the object memory being loaded
loadIntoReadOnlyMemory - specifies if the object memory should be put into read-only memory
Returns:
the ObjectMemoryFile instance encapsulating the loaded/resolved object memory

load

public static ObjectMemoryFile load(String uri,
                                    boolean loadIntoReadOnlyMemory)
                             throws IOException
Loads an object memory from a given input stream. If the URI describing the source of the input stream corresponds to the URI of an object memory already present in the system, then that object memory is returned instead.

Parameters:
uri - a URI identifying the object memory being loaded
loadIntoReadOnlyMemory - specifies if the object memory should be put into read-only memory
Returns:
the ObjectMemoryFile instance encapsulating the loaded/resolved object memory
Throws:
IOException

skipMemoryPadding

protected void skipMemoryPadding(String parentURI,
                                 int memorySize)
Skips the padding that precedes the 'memory' item to ensure that it is word aligned with respect to the start of the object memory file.

Parameters:
parentURI - the value of the 'parent_uri' item in the object memory file
memorySize - the value of the 'size' item in the object memory file

addFilePath

public static void addFilePath(String path)
Expecting a string that looks something like "c:\dev\1${File.separatorChar}c:\windows".

Parameters:
path - entries

setFilePath

public static void setFilePath(String path)
Expecting a string that looks something like "c:\dev\1${File.separatorChar}c:\windows".

Parameters:
path - entries

loadOopMap

protected BitSet loadOopMap(int size)
Loads the 'oopmap' component of the object memory from the input stream.

Parameters:
size - the size of memory as specified by the 'size' element of the objct memory
Returns:
the bit set encapsulating the oop map

loadMemory

protected byte[] loadMemory(int size)
Loads the 'memory' component of the object memory from the input stream.

Parameters:
size - the size of memory as specified by the 'size' element of the objct memory
Returns:
the contents of the 'memory' component

relocateMemory

protected Address relocateMemory(ObjectMemory parent,
                                 byte[] buffer,
                                 BitSet oopMap)
Relocates the memory.

Parameters:
parent - the loaded/resolved parent object memory
buffer - the contents of the 'memory' component
oopMap - the bit set encapsulating the 'oopmap' component
Returns:
the address of the relocated memory buffer

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"