Top Description Fields Constructors Methods
org.apache.tomcat.util.bcel.classfile

public Class ConstantPool

extends Object
Class Inheritance
Imports
java.io.DataInput, .IOException, org.apache.tomcat.util.bcel.Const

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. Those interested in generating constant pools programmatically should see ConstantPoolGen.
See Also
Constant

Field Summary

Modifier and TypeField and Description
private final Constant[]

Constructor Summary

AccessConstructor and Description
pack-priv
ConstantPool(final DataInput
Input stream
input
)

Reads constants from given input stream.

Method Summary

Modifier and TypeMethod and Description
public <
A Constant subclass
T extends Constant
>
T

Returns:

Constant value
getConstant
(final int
Index in constant pool
index
)

Gets constant from constant pool.

public <
A Constant subclass
T extends Constant
>
T

Returns:

Constant value
getConstant
(final int
Index in constant pool
index
,
final byte
Tag of expected constant, i.e., its type
tag
)

Gets constant from constant pool and check whether it has the expected type.

public <
A Constant subclass
T extends Constant
>
T

Returns:

Constant value
getConstant
(final int
Index in constant pool
index
,
final Class<T>
The Constant subclass to cast to.
castTo
)

Gets constant from constant pool.

public ConstantInteger

Returns:

ConstantInteger value
getConstantInteger
(final int
Index in constant pool
index
)

Gets constant from constant pool and check whether it has the expected type.

public ConstantUtf8

Returns:

ConstantUtf8 value
getConstantUtf8
(final int
Index in constant pool
index
)

Gets constant from constant pool and check whether it has the expected type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constantPoolback to summary
private final Constant[] constantPool

Constructor Detail

ConstantPoolback to summary
pack-priv ConstantPool(final DataInput input) throws IOException, ClassFormatException

Reads constants from given input stream.

Parameters
input:DataInput

Input stream

Exceptions
IOException:
if an I/O error occurs reading the the InputStream
ClassFormatException:
If the .class file is not valid

Method Detail

getConstantback to summary
public <T extends Constant> T getConstant(final int index) throws ClassFormatException

Gets constant from constant pool.

Parameters
<T>
A Constant subclass
index:int

Index in constant pool

Returns:T

Constant value

Annotations
@SuppressWarnings:unchecked
Exceptions
ClassFormatException:
if index is invalid
See Also
Constant
getConstantback to summary
public <T extends Constant> T getConstant(final int index, final byte tag) throws ClassFormatException

Gets constant from constant pool and check whether it has the expected type.

Parameters
<T>
A Constant subclass
index:int

Index in constant pool

tag:byte

Tag of expected constant, i.e., its type

Returns:T

Constant value

Exceptions
ClassFormatException:
if constant type does not match tag
See Also
Constant
getConstantback to summary
public <T extends Constant> T getConstant(final int index, final Class<T> castTo) throws ClassFormatException

Gets constant from constant pool.

Parameters
<T>
A Constant subclass
index:int

Index in constant pool

castTo:Class<T>

The Constant subclass to cast to.

Returns:T

Constant value

Exceptions
ClassFormatException:
if index is invalid
See Also
Constant
getConstantIntegerback to summary
public ConstantInteger getConstantInteger(final int index)

Gets constant from constant pool and check whether it has the expected type.

Parameters
index:int

Index in constant pool

Returns:ConstantInteger

ConstantInteger value

Exceptions
ClassFormatException:
if constant type does not match tag
See Also
ConstantInteger
getConstantUtf8back to summary
public ConstantUtf8 getConstantUtf8(final int index) throws ClassFormatException

Gets constant from constant pool and check whether it has the expected type.

Parameters
index:int

Index in constant pool

Returns:ConstantUtf8

ConstantUtf8 value

Exceptions
ClassFormatException:
if constant type does not match tag
See Also
ConstantUtf8