Package org.openjdk.asmtools.jasm
Class ConstantPool
java.lang.Object
org.openjdk.asmtools.jasm.ConstantPool
ConstantPool is the class responsible for maintaining constants for a given class file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
ConstantPool.ConstValue_Cell<T extends ConstValue<?>>
CONSTANT_Cell represents CONSTANT_Class(7), CONSTANT_String(8), CONSTANT_MethodType(16), CONSTANT_Module(19), CONSTANT_Package(20) constantsstatic class
The CONSTANT_Class(7) structure represents constant objects of the type Stringstatic class
The CONSTANT_Double(6) represents 8-byte numeric (double) constantsstatic class
The CONSTANT_Dynamic (17) structure is used to represent a dynamically-computed constant, an arbitrary value that is produced by invocation of a bootstrap method in the course of a ldc instruction, among others.static class
The CONSTANT_Fieldref(9) structure is used to represent a fieldstatic class
CONSTANT_Float(4) structure represents 4-byte numeric (float) constantsstatic class
CONSTANT_Integer(3) structure represents 4-byte numeric (int) constantsstatic class
The CONSTANT_InterfaceMethodref(11) structure is used to represent an interface methodstatic class
The CONSTANT_InvokeDynamic_info(18) structure is used to represent a dynamically-computed call site, an instance of java.lang.invoke.CallSite that is produced by invocation of a bootstrap method in the course of an invokedynamic instruction.static class
The CONSTANT_Long_info(5) represents 8-byte numeric (long) constantsstatic class
ConstantPool.ConstValue_MethodHandle<P extends ConstantPool.ConstValue_Pair<ConstantPool.ConstValue_Class,
ConstantPool.ConstValue_NameAndType>> The CONSTANT_MethodHandle(15) structure is used to represent a method handle T : ConstValue_MethodRef, ConstValue_InterfaceMethodRef or ConstValue_FieldRefstatic class
The CONSTANT_Methodref(10) structure is used to represent a methodstatic class
The CONSTANT_MethodType(16) structure represents a method typestatic class
The CONSTANT_Module(19) structure represents a modulestatic class
The CONSTANT_NameAndType(12) structure is used to represent a field or method, without indicating which class or interface type it belongs tostatic class
The CONSTANT_Package(20) structure represents a method typestatic class
ConstantPool.ConstValue_Pair<L extends ConstValue,
R extends ConstValue> ConstValue_Pair represents CONSTANT_NameAndType(12), CONSTANT_Fieldref(9), CONSTANT_Methodref(10), and CONSTANT_InterfaceMethodref(11) structuresstatic class
The CONSTANT_String(8) structure represents a class or an interfacestatic class
CONSTANT_UTF8(1) is used to represent constant objects of the type: Stringstatic class
CONSTANT_ZERO: Zero Constant Value presents Constant 0.static enum
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Hashtable<ConstValue<?>,
ConstCell<?>> private final ConstantPool.ConstValue_UTF8
private final CPVisitor
(package private) static final int
private final ConstCell<?>
(package private) static final int
private final CPVisitor
private final ConstCell<?>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
checkAndFixCPRef
(ConstCell item) protected void
private void
private void
delete
(int cpx) findCell
(ClassFileConst.ConstType tag, ConstCell value) findCell
(ClassFileConst.ConstType tag, ConstCell left, ConstCell right) findCell
(ClassFileConst.ConstType tag, NameInfo nameInfo) <T extends ConstValue>
ConstCell<T>findCell
(T ref) findClassCell
(String name) findClassCell
(NameInfo nameInfo) findDoubleCell
(Long value) findFloatCell
(Integer value) findIntegerCell
(Integer value) findLongCell
(Long value) findModuleCell
(String name) findModuleCell
(NameInfo nameInfo) findPackageCell
(String name) findPackageCell
(NameInfo nameInfo) findUTF8Cell
(String value) private int
findVacantSlot
(int cellSize) void
void
getCell
(int cpx) getConstPollCellByIndex
(int cpIndex) getItemizedCell
(ConstCell<?> cell) getPoolCellsByType
(ClassFileConst.ConstType... types) protected void
protected void
private boolean
handleIndexCell
(ConstCell refCell) Updates reference cell if there is an attached cell but cpIndex is missing.protected void
protected void
private boolean
handleRefCell
(ConstCell refCell) Updates reference cell if there is cpIndex but a cell is not attached.private boolean
private ConstCell<?>
itemizeCell
(ConstCell<?> cell) protected void
iterator()
lookupUTF8Cell
(Function<String, Boolean> rule) void
void
Removes ClassCell entry from the Constant Poolvoid
protected ConstCell<?>
specifyCell
(ConstCell<?> cell) private void
traverseConstantCell
(ConstCell<?> constCell, Consumer<ConstCell<?>> op) protected ConstCell
uncheckedGetCell
(int cpx) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
PROCESSED
static final int PROCESSED- See Also:
-
NON_PROCESSED
static final int NON_PROCESSED- See Also:
-
emptyConstValue
-
nullConst
-
zeroConst
-
pool
-
environment
-
ConstantPoolHashByValue
Hashtable<ConstValue<?>,ConstCell<?>> ConstantPoolHashByValue -
indexFixerConstantPool
-
referenceFixerConstantPool
-
-
Constructor Details
-
ConstantPool
Main constructor- Parameters:
environment
- The error reporting environment
-
-
Method Details
-
iterator
-
handleClassRef
-
handleMemberRef
-
handleRefCell
Updates reference cell if there is cpIndex but a cell is not attached.- Parameters:
refCell
- a constant cell- Returns:
- true if the cell is fixed
-
handleClassIndex
-
handleMemberIndex
-
handleIndexCell
Updates reference cell if there is an attached cell but cpIndex is missing.- Parameters:
refCell
- a constant cell- Returns:
- true if the cell is fixed
-
fixRefsInPool
public void fixRefsInPool() -
fixIndexesInPool
public void fixIndexesInPool() -
checkGlobals
protected void checkGlobals() -
checkAndFixCPRef
-
checkAndFixCPIndexes
-
printPool
public void printPool() -
getBounds
-
getConstPollCellByIndex
-
cpool_set
-
delete
private void delete(int cpx) -
traverseConstantCell
-
uncheckedGetCell
-
getCell
-
setCell
-
getItemizedCell
-
itemizeCell
-
itemizePool
protected void itemizePool() -
specifyCell
-
findVacantSlot
private int findVacantSlot(int cellSize) -
findCell
-
findIntegerCell
-
findFloatCell
-
findLongCell
-
findDoubleCell
-
findUTF8Cell
-
lookupUTF8Cell
-
findClassCell
-
findClassCell
-
findModuleCell
-
findModuleCell
-
findPackageCell
-
findPackageCell
-
findCell
-
findCell
-
findCell
-
write
- Throws:
IOException
-
getPoolCellsByType
-
getPoolValuesByRefType
-
removeClassCell
Removes ClassCell entry from the Constant Pool- Parameters:
cell
- the Constant Pool cell ConstCell
-
isAllowedToBeDelete
- Returns:
- true if the class name belongs to JDK public API
-