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 classstatic classConstantPool.ConstValue_Cell<T extends ConstValue<?>>CONSTANT_Cell represents CONSTANT_Class(7), CONSTANT_String(8), CONSTANT_MethodType(16), CONSTANT_Module(19), CONSTANT_Package(20) constantsstatic classThe CONSTANT_Class(7) structure represents constant objects of the type Stringstatic classThe CONSTANT_Double(6) represents 8-byte numeric (double) constantsstatic classThe 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 classThe CONSTANT_Fieldref(9) structure is used to represent a fieldstatic classCONSTANT_Float(4) structure represents 4-byte numeric (float) constantsstatic classCONSTANT_Integer(3) structure represents 4-byte numeric (int) constantsstatic classThe CONSTANT_InterfaceMethodref(11) structure is used to represent an interface methodstatic classThe 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 classThe CONSTANT_Long_info(5) represents 8-byte numeric (long) constantsstatic classConstantPool.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 classThe CONSTANT_Methodref(10) structure is used to represent a methodstatic classThe CONSTANT_MethodType(16) structure represents a method typestatic classThe CONSTANT_Module(19) structure represents a modulestatic classThe CONSTANT_NameAndType(12) structure is used to represent a field or method, without indicating which class or interface type it belongs tostatic classThe CONSTANT_Package(20) structure represents a method typestatic classConstantPool.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 classThe CONSTANT_String(8) structure represents a class or an interfacestatic classCONSTANT_UTF8(1) is used to represent constant objects of the type: Stringstatic classCONSTANT_ZERO: Zero Constant Value presents Constant 0.static enum -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Hashtable<ConstValue<?>, ConstCell<?>> private final ConstantPool.ConstValue_UTF8private final CPVisitor(package private) static final intprivate final ConstCell<?> (package private) static final intprivate final CPVisitorprivate final ConstCell<?> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidcheckAndFixCPRef(ConstCell item) protected voidprivate voidprivate voiddelete(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 intfindVacantSlot(int cellSize) voidvoidgetCell(int cpx) getConstPollCellByIndex(int cpIndex) getItemizedCell(ConstCell<?> cell) getPoolCellsByType(ClassFileConst.ConstType... types) protected voidprotected voidprivate booleanhandleIndexCell(ConstCell refCell) Updates reference cell if there is an attached cell but cpIndex is missing.protected voidprotected voidprivate booleanhandleRefCell(ConstCell refCell) Updates reference cell if there is cpIndex but a cell is not attached.private booleanprivate ConstCell<?> itemizeCell(ConstCell<?> cell) protected voiditerator()lookupUTF8Cell(Function<String, Boolean> rule) voidvoidRemoves ClassCell entry from the Constant Poolvoidprotected ConstCell<?> specifyCell(ConstCell<?> cell) private voidtraverseConstantCell(ConstCell<?> constCell, Consumer<ConstCell<?>> op) protected ConstCelluncheckedGetCell(int cpx) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
-