net.sf.transjvm.jvm
Class ConstantPool

java.lang.Object
  extended by net.sf.transjvm.jvm.ConstantPool

public class ConstantPool
extends java.lang.Object

Author:
Mark Shannon

Field Summary
 int uniqueID
          An unique identifier for a ConstantPool.
 
Constructor Summary
ConstantPool()
           
 
Method Summary
 int getClassRef(java.lang.String name)
          Returns an index for the named class.
 int getClassRef(UTF name)
          Returns an index for the named class.
 int getDouble(double d)
          Returns an index for the double d
 int getFieldRef(int classRef, java.lang.String name, UTF descriptor)
          Returns an index for the specified field.
 int getFloat(float f)
          Returns an index for the float f
 int getInteger(int i)
          Returns an index for the integer i
 int getInterfaceMethodRef(int classRef, java.lang.String name, UTF descriptor)
          Returns an index for the specified interface method.
 int getLong(long l)
          Returns an index for the long l
 int getMethodRef(int classRef, java.lang.String name, UTF descriptor)
          Returns an index for the specified method.
 int getString(java.lang.String s)
          Returns an index for the String s
 int getUtf(java.lang.String s)
          Returns an UTF index for the String s
 int getUtf(UTF utf)
          Returns an index for the UTF utf
 int size()
          The size (in bytes not entries) of this ConstantPool
 void writeTo(byte[] bytes, int offset)
          Writes this ConstantPool to a byte array starting at offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uniqueID

public final int uniqueID
An unique identifier for a ConstantPool. For any two ConstantPools cp1 and cp2: cp1.uniqueID == cp2.uniqueID if and only if cp1 == cp2. Primarily a cheap way for Objects to keep tags on which ConstantPool(s) they have been written to without unintentional object retentions or WeakReferences.

Constructor Detail

ConstantPool

public ConstantPool()
Method Detail

writeTo

public void writeTo(byte[] bytes,
                    int offset)
Writes this ConstantPool to a byte array starting at offset.

Parameters:
bytes - The array to write to.
offset - Offset from start of array to write to.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if size() + offset > bytes.length

size

public int size()
The size (in bytes not entries) of this ConstantPool


getUtf

public int getUtf(java.lang.String s)
Returns an UTF index for the String s


getUtf

public int getUtf(UTF utf)
Returns an index for the UTF utf


getString

public int getString(java.lang.String s)
Returns an index for the String s


getInteger

public int getInteger(int i)
Returns an index for the integer i


getLong

public int getLong(long l)
Returns an index for the long l


getFloat

public int getFloat(float f)
Returns an index for the float f


getDouble

public int getDouble(double d)
Returns an index for the double d


getClassRef

public int getClassRef(java.lang.String name)
Returns an index for the named class.


getClassRef

public int getClassRef(UTF name)
Returns an index for the named class.


getFieldRef

public int getFieldRef(int classRef,
                       java.lang.String name,
                       UTF descriptor)
Returns an index for the specified field.


getMethodRef

public int getMethodRef(int classRef,
                        java.lang.String name,
                        UTF descriptor)
Returns an index for the specified method.


getInterfaceMethodRef

public int getInterfaceMethodRef(int classRef,
                                 java.lang.String name,
                                 UTF descriptor)
Returns an index for the specified interface method.



Copyright 2004-5, Mark Shannon