Top Description Fields Constructors Methods
org.aspectj.apache.bcel.classfile

public Class ConstantPool

extends Object
implements Node
Class Inheritance
All Implemented Interfaces
org.aspectj.apache.bcel.classfile.Node
Imports
java.io.DataInputStream, .DataOutputStream, .IOException, java.util.HashMap, .Map, org.aspectj.apache.bcel.Constants, org.aspectj.apache.bcel.generic.ArrayType, .ObjectType

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.

Field Summary

Modifier and TypeField and Description
private Map<String, Integer>
private Map<String, Integer>
private Constant[]
private int
private Map<String, Integer>

Constructor Summary

AccessConstructor and Description
public
public
ConstantPool(Constant[] constants)

pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public int
public int
public int
addClass(String classname)

public int
public int
addConstantDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex)

public int
addDouble(double d)

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

public int
addFloat(float f)

public int
addInteger(int n)

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

public int
addInvokeDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex)

public int
addLong(long l)

public int
addMethodHandle(byte referenceKind, int referenceIndex)

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

public int
addMethodType(int descriptorIndex)

public int
addNameAndType(String name, String signature)

public int
public int
private void
public String
constantToString(Constant c)

Resolve constant to a string representation.

public String
constantToString(int index, byte tag)

public String
constantToString(int index)

public ConstantPool

Returns:

deep copy of this constant pool
copy
()

public void
private static final String
public Constant
getConstant(int index, byte tag)

public Constant
getConstant(int index)

public ConstantModule
getConstantModule(int index)

public ConstantPackage
getConstantPackage(int index)

public Constant[]
public String

Returns:

Contents of string reference
getConstantString
(int
Index in constant pool
index
,
byte
Tag of expected constant, either ConstantClass or ConstantString
tag
)

Get string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects.

public String
public ConstantUtf8
getConstantUtf8(int index)

public ConstantPool
public int
public String
getModuleName(int moduleIndex)

public String
getPackageName(int packageIndex)

public int
public int
lookupClass(String classname)

public int
lookupDouble(double d)

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

public int
lookupFloat(float f)

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

public int
lookupLong(long l)

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

public int
lookupNameAndType(String searchName, String searchTypeSignature)

public int
public int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

fieldCacheback to summary
private Map<String, Integer> fieldCache
methodCacheback to summary
private Map<String, Integer> methodCache
poolback to summary
private Constant[] pool
poolSizeback to summary
private int poolSize
utf8Cacheback to summary
private Map<String, Integer> utf8Cache

Constructor Detail

ConstantPoolback to summary
public ConstantPool()
ConstantPoolback to summary
public ConstantPool(Constant[] constants)
ConstantPoolback to summary
pack-priv ConstantPool(DataInputStream file) throws IOException

Method Detail

acceptback to summary
public void accept(ClassVisitor v)

Implements org.aspectj.apache.bcel.classfile.Node.accept.

Annotations
@Override
addArrayClassback to summary
public int addArrayClass(ArrayType type)
addClassback to summary
public int addClass(ObjectType type)
addClassback to summary
public int addClass(String classname)
addConstantback to summary
public int addConstant(Constant c, ConstantPool cp)
addConstantDynamicback to summary
public int addConstantDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex)
addDoubleback to summary
public int addDouble(double d)
addFieldrefback to summary
public int addFieldref(String class_name, String field_name, String signature)
addFloatback to summary
public int addFloat(float f)
addIntegerback to summary
public int addInteger(int n)
addInterfaceMethodrefback to summary
public int addInterfaceMethodref(String class_name, String method_name, String signature)
addInvokeDynamicback to summary
public int addInvokeDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex)
addLongback to summary
public int addLong(long l)
addMethodHandleback to summary
public int addMethodHandle(byte referenceKind, int referenceIndex)
addMethodrefback to summary
public int addMethodref(String class_name, String method_name, String signature)
addMethodTypeback to summary
public int addMethodType(int descriptorIndex)
addNameAndTypeback to summary
public int addNameAndType(String name, String signature)
addStringback to summary
public int addString(String str)
addUtf8back to summary
public int addUtf8(String n)
adjustSizeback to summary
private void adjustSize()
constantToStringback to summary
public String constantToString(Constant c)

Resolve constant to a string representation.

constantToStringback to summary
public String constantToString(int index, byte tag)
constantToStringback to summary
public String constantToString(int index)
copyback to summary
public ConstantPool copy()
Returns:ConstantPool

deep copy of this constant pool

dumpback to summary
public void dump(DataOutputStream file) throws IOException
escapeback to summary
private static final String escape(String str)
getConstantback to summary
public Constant getConstant(int index, byte tag)
getConstantback to summary
public Constant getConstant(int index)
getConstantModuleback to summary
public ConstantModule getConstantModule(int index)
getConstantPackageback to summary
public ConstantPackage getConstantPackage(int index)
getConstantPoolback to summary
public Constant[] getConstantPool()
getConstantStringback to summary
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:int

Index in constant pool

tag:byte

Tag of expected constant, either ConstantClass or ConstantString

Returns:String

Contents of string reference

See Also
ConstantClass, ConstantString
getConstantString_CONSTANTClassback to summary
public String getConstantString_CONSTANTClass(int index)
getConstantUtf8back to summary
public ConstantUtf8 getConstantUtf8(int index)
getFinalConstantPoolback to summary
public ConstantPool getFinalConstantPool()
getLengthback to summary
public int getLength()
getModuleNameback to summary
public String getModuleName(int moduleIndex)
getPackageNameback to summary
public String getPackageName(int packageIndex)
getSizeback to summary
public int getSize()
lookupClassback to summary
public int lookupClass(String classname)
lookupDoubleback to summary
public int lookupDouble(double d)
lookupFieldrefback to summary
public int lookupFieldref(String searchClassname, String searchFieldname, String searchSignature)
lookupFloatback to summary
public int lookupFloat(float f)
lookupIntegerback to summary
public int lookupInteger(int n)
lookupInterfaceMethodrefback to summary
public int lookupInterfaceMethodref(String searchClassname, String searchMethodName, String searchSignature)
lookupLongback to summary
public int lookupLong(long l)
lookupMethodrefback to summary
public int lookupMethodref(String searchClassname, String searchMethodName, String searchSignature)
lookupNameAndTypeback to summary
public int lookupNameAndType(String searchName, String searchTypeSignature)
lookupStringback to summary
public int lookupString(String s)
lookupUtf8back to summary
public int lookupUtf8(String string)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override