public class ConstantPool extends Object implements Cloneable, Node, Iterable<Constant>
Constant,
ConstantPoolGen| Constructor and Description |
|---|
ConstantPool(Constant[] constantPool) |
ConstantPool(DataInput input)
Reads constants from given input stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
|
String |
constantToString(Constant c)
Resolves constant to a string representation.
|
String |
constantToString(int index,
byte tag)
Retrieves constant at `index' from constant pool and resolve it to a string representation.
|
ConstantPool |
copy() |
void |
dump(DataOutputStream file)
Dump constant pool to file stream in binary format.
|
<T extends Constant> |
getConstant(int index)
Gets constant from constant pool.
|
<T extends Constant> |
getConstant(int index,
byte tag)
Gets constant from constant pool and check whether it has the expected type.
|
<T extends Constant> |
getConstant(int index,
byte tag,
Class<T> castTo)
Gets constant from constant pool and check whether it has the expected type.
|
<T extends Constant> |
getConstant(int index,
Class<T> castTo)
Gets constant from constant pool.
|
ConstantInteger |
getConstantInteger(int index)
Gets constant from constant pool and check whether it has the expected type.
|
Constant[] |
getConstantPool() |
String |
getConstantString(int index,
byte tag)
Gets string from constant pool and bypass the indirection of `ConstantClass' and `ConstantString' objects.
|
ConstantUtf8 |
getConstantUtf8(int index)
Gets constant from constant pool and check whether it has the expected type.
|
int |
getLength() |
Iterator<Constant> |
iterator() |
void |
setConstant(int index,
Constant constant) |
void |
setConstantPool(Constant[] constantPool) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic ConstantPool(Constant[] constantPool)
constantPool - Array of constantspublic ConstantPool(DataInput input) throws IOException
input - Input streamIOException - if problem in readUnsignedShort or readConstantpublic void accept(Visitor v)
public String constantToString(Constant c) throws IllegalArgumentException
c - Constant to be printedIllegalArgumentException - if c is unknown constant typepublic String constantToString(int index, byte tag)
index - of constant in constant pooltag - expected typepublic ConstantPool copy()
public void dump(DataOutputStream file) throws IOException
file - Output file streamIOException - if problem in writeShort or dumppublic <T extends Constant> T getConstant(int index) throws ClassFormatException
index - Index in constant poolClassFormatException - if index is invalidConstantpublic <T extends Constant> T getConstant(int index, byte tag) throws ClassFormatException
index - Index in constant pooltag - Tag of expected constant, i.e., its typeClassFormatException - if constant type does not match tagConstantpublic <T extends Constant> T getConstant(int index, byte tag, Class<T> castTo) throws ClassFormatException
index - Index in constant pooltag - Tag of expected constant, i.e., its typeClassFormatException - if constant type does not match tagConstantpublic <T extends Constant> T getConstant(int index, Class<T> castTo) throws ClassFormatException
T - A Constant subclassindex - Index in constant poolcastTo - The Constant subclass to cast to.ClassFormatException - if index is invalidConstantpublic ConstantInteger getConstantInteger(int index)
index - Index in constant poolClassFormatException - if constant type does not match tagConstantIntegerpublic Constant[] getConstantPool()
Constantpublic String getConstantString(int index, byte tag) throws IllegalArgumentException
index - Index in constant pooltag - Tag of expected constant, either ConstantClass or ConstantStringIllegalArgumentException - if tag is invalidConstantClass,
ConstantStringpublic ConstantUtf8 getConstantUtf8(int index) throws ClassFormatException
index - Index in constant poolClassFormatException - if constant type does not match tagConstantUtf8public int getLength()
public void setConstant(int index, Constant constant)
constant - Constant to setpublic void setConstantPool(Constant[] constantPool)
constantPool - Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.