Class ConstantPool

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

public class ConstantPool extends 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 Details

    • ConstantPool

      public ConstantPool()
    • ConstantPool

      public ConstantPool(Constant[] constants)
  • Method Details

    • 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 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 String constantToString(Constant c)
      Resolve constant to a string representation.
    • constantToString

      public String constantToString(int index, byte tag)
    • constantToString

      public String constantToString(int index)
    • accept

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

      public Constant[] getConstantPool()
    • dump

      public void dump(DataOutputStream file) throws IOException
      Throws:
      IOException
    • getConstantUtf8

      public ConstantUtf8 getConstantUtf8(int index)
    • getConstantModule

      public ConstantModule getConstantModule(int index)
    • getConstantPackage

      public ConstantPackage getConstantPackage(int index)
    • getConstantString_CONSTANTClass

      public String getConstantString_CONSTANTClass(int index)
    • getLength

      public int getLength()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • lookupInteger

      public int lookupInteger(int n)
    • lookupUtf8

      public int lookupUtf8(String string)
    • lookupClass

      public int lookupClass(String classname)
    • addUtf8

      public int addUtf8(String n)
    • addInteger

      public int addInteger(int n)
    • addArrayClass

      public int addArrayClass(ArrayType type)
    • addClass

      public int addClass(ObjectType type)
    • addClass

      public int addClass(String classname)
    • addFieldref

      public int addFieldref(String class_name, String field_name, String signature)
    • lookupFieldref

      public int lookupFieldref(String searchClassname, String searchFieldname, String searchSignature)
    • addNameAndType

      public int addNameAndType(String name, String signature)
    • lookupNameAndType

      public int lookupNameAndType(String searchName, 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(String s)
    • addString

      public int addString(String str)
    • lookupLong

      public int lookupLong(long l)
    • addConstant

      public int addConstant(Constant c, ConstantPool cp)
    • addMethodHandle

      public int addMethodHandle(byte referenceKind, int referenceIndex)
    • addMethodType

      public int addMethodType(int descriptorIndex)
    • addMethodref

      public int addMethodref(String class_name, String method_name, String signature)
    • addInvokeDynamic

      public int addInvokeDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex)
    • addInterfaceMethodref

      public int addInterfaceMethodref(String class_name, String method_name, String signature)
    • lookupInterfaceMethodref

      public int lookupInterfaceMethodref(String searchClassname, String searchMethodName, String searchSignature)
    • lookupMethodref

      public int lookupMethodref(String searchClassname, String searchMethodName, String searchSignature)
    • getFinalConstantPool

      public ConstantPool getFinalConstantPool()
    • getModuleName

      public String getModuleName(int moduleIndex)
    • getPackageName

      public String getPackageName(int packageIndex)