Class ConstantPool
java.lang.Object
org.apache.tomcat.util.bcel.classfile.ConstantPool
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:
-
Method Summary
Modifier and TypeMethodDescription<T extends Constant>
TgetConstant
(int index) Gets constant from constant pool.<T extends Constant>
TgetConstant
(int index, byte tag) Gets constant from constant pool and check whether it has the expected type.<T extends Constant>
TgetConstant
(int index, Class<T> castTo) Gets constant from constant pool.getConstantInteger
(int index) Gets constant from constant pool and check whether it has the expected type.getConstantUtf8
(int index) Gets constant from constant pool and check whether it has the expected type.
-
Method Details
-
getConstant
Gets constant from constant pool.- Type Parameters:
T
- AConstant
subclass- Parameters:
index
- Index in constant pool- Returns:
- Constant value
- Throws:
ClassFormatException
- if index is invalid- See Also:
-
getConstant
Gets constant from constant pool and check whether it has the expected type.- Type Parameters:
T
- AConstant
subclass- Parameters:
index
- Index in constant pooltag
- Tag of expected constant, i.e., its type- Returns:
- Constant value
- Throws:
ClassFormatException
- if constant type does not match tag- See Also:
-
getConstant
Gets constant from constant pool.- Type Parameters:
T
- AConstant
subclass- Parameters:
index
- Index in constant poolcastTo
- TheConstant
subclass to cast to.- Returns:
- Constant value
- Throws:
ClassFormatException
- if index is invalid- See Also:
-
getConstantInteger
Gets constant from constant pool and check whether it has the expected type.- Parameters:
index
- Index in constant pool- Returns:
- ConstantInteger value
- Throws:
ClassFormatException
- if constant type does not match tag- See Also:
-
getConstantUtf8
Gets constant from constant pool and check whether it has the expected type.- Parameters:
index
- Index in constant pool- Returns:
- ConstantUtf8 value
- Throws:
ClassFormatException
- if constant type does not match tag- See Also:
-