org.aspectj.apache.bcel.classfile
Class ConstantPool

java.lang.Object
  extended by org.aspectj.apache.bcel.classfile.ConstantPool
All Implemented Interfaces:
Node

public class ConstantPool
extends java.lang.Object
implements Node

This class represents the constant pool, i.e., a table of constants, of a parsed classfile. It may contain null references, due to the JVM specification that skips an entry after an 8-byte constant (double, long) entry.


Constructor Summary
ConstantPool()
           
ConstantPool(Constant[] constants)
           
 
Method Summary
 void accept(ClassVisitor v)
           
 int addArrayClass(ArrayType type)
           
 int addClass(ObjectType type)
           
 int addClass(java.lang.String classname)
           
 int addConstant(Constant c, ConstantPool cp)
           
 int addDouble(double d)
           
 int addFieldref(java.lang.String class_name, java.lang.String field_name, java.lang.String signature)
           
 int addFloat(float f)
           
 int addInteger(int n)
           
 int addInterfaceMethodref(java.lang.String class_name, java.lang.String method_name, java.lang.String signature)
           
 int addLong(long l)
           
 int addMethodref(java.lang.String class_name, java.lang.String method_name, java.lang.String signature)
           
 int addNameAndType(java.lang.String name, java.lang.String signature)
           
 int addString(java.lang.String str)
           
 int addUtf8(java.lang.String n)
           
 java.lang.String constantToString(Constant c)
          Resolve constant to a string representation.
 java.lang.String constantToString(int index)
           
 java.lang.String constantToString(int index, byte tag)
           
 ConstantPool copy()
           
 void dump(java.io.DataOutputStream file)
           
 Constant getConstant(int index)
           
 Constant getConstant(int index, byte tag)
           
 Constant[] getConstantPool()
           
 java.lang.String getConstantString_CONSTANTClass(int index)
           
 java.lang.String getConstantString(int index, byte tag)
          Get string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects.
 ConstantUtf8 getConstantUtf8(int index)
           
 ConstantPool getFinalConstantPool()
           
 int getLength()
           
 int getSize()
           
 int lookupClass(java.lang.String classname)
           
 int lookupDouble(double d)
           
 int lookupFieldref(java.lang.String searchClassname, java.lang.String searchFieldname, java.lang.String searchSignature)
           
 int lookupFloat(float f)
           
 int lookupInteger(int n)
           
 int lookupInterfaceMethodref(java.lang.String searchClassname, java.lang.String searchMethodName, java.lang.String searchSignature)
           
 int lookupLong(long l)
           
 int lookupMethodref(java.lang.String searchClassname, java.lang.String searchMethodName, java.lang.String searchSignature)
           
 int lookupNameAndType(java.lang.String searchName, java.lang.String searchTypeSignature)
           
 int lookupString(java.lang.String s)
           
 int lookupUtf8(java.lang.String string)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantPool

public ConstantPool()

ConstantPool

public ConstantPool(Constant[] constants)
Method Detail

getSize

public int getSize()

getConstant

public Constant getConstant(int index,
                            byte tag)

getConstant

public Constant getConstant(int index)

copy

public ConstantPool copy()
Returns:
deep copy of this constant pool

getConstantString

public java.lang.String getConstantString(int index,
                                          byte tag)
                                   throws ClassFormatException
Get string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects. I.e. these classes have an index field that points to another entry of the constant pool of type `ConstantUtf8' which contains the real data.

Parameters:
index - Index in constant pool
tag - Tag of expected constant, either ConstantClass or ConstantString
Returns:
Contents of string reference
Throws:
ClassFormatException
See Also:
ConstantClass, ConstantString

constantToString

public java.lang.String constantToString(Constant c)
Resolve constant to a string representation.


constantToString

public java.lang.String constantToString(int index,
                                         byte tag)

constantToString

public java.lang.String constantToString(int index)

accept

public void accept(ClassVisitor v)
Specified by:
accept in interface Node

getConstantPool

public Constant[] getConstantPool()

dump

public void dump(java.io.DataOutputStream file)
          throws java.io.IOException
Throws:
java.io.IOException

getConstantUtf8

public ConstantUtf8 getConstantUtf8(int index)

getConstantString_CONSTANTClass

public java.lang.String getConstantString_CONSTANTClass(int index)

getLength

public int getLength()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

lookupInteger

public int lookupInteger(int n)

lookupUtf8

public int lookupUtf8(java.lang.String string)

lookupClass

public int lookupClass(java.lang.String classname)

addUtf8

public int addUtf8(java.lang.String n)

addInteger

public int addInteger(int n)

addArrayClass

public int addArrayClass(ArrayType type)

addClass

public int addClass(ObjectType type)

addClass

public int addClass(java.lang.String classname)

addFieldref

public int addFieldref(java.lang.String class_name,
                       java.lang.String field_name,
                       java.lang.String signature)

lookupFieldref

public int lookupFieldref(java.lang.String searchClassname,
                          java.lang.String searchFieldname,
                          java.lang.String searchSignature)

addNameAndType

public int addNameAndType(java.lang.String name,
                          java.lang.String signature)

lookupNameAndType

public int lookupNameAndType(java.lang.String searchName,
                             java.lang.String searchTypeSignature)

addFloat

public int addFloat(float f)

lookupFloat

public int lookupFloat(float f)

addDouble

public int addDouble(double d)

lookupDouble

public int lookupDouble(double d)

addLong

public int addLong(long l)

lookupString

public int lookupString(java.lang.String s)

addString

public int addString(java.lang.String str)

lookupLong

public int lookupLong(long l)

addConstant

public int addConstant(Constant c,
                       ConstantPool cp)

addMethodref

public int addMethodref(java.lang.String class_name,
                        java.lang.String method_name,
                        java.lang.String signature)

addInterfaceMethodref

public int addInterfaceMethodref(java.lang.String class_name,
                                 java.lang.String method_name,
                                 java.lang.String signature)

lookupInterfaceMethodref

public int lookupInterfaceMethodref(java.lang.String searchClassname,
                                    java.lang.String searchMethodName,
                                    java.lang.String searchSignature)

lookupMethodref

public int lookupMethodref(java.lang.String searchClassname,
                           java.lang.String searchMethodName,
                           java.lang.String searchSignature)

getFinalConstantPool

public ConstantPool getFinalConstantPool()