public class HotSpotConstantPool extends Object implements ConstantPool, HotSpotProxified
ConstantPool
for HotSpot.Modifier and Type | Class and Description |
---|---|
static class |
HotSpotConstantPool.Bytecodes
Subset of JVM bytecode opcodes used by
HotSpotConstantPool . |
private class |
HotSpotConstantPool.Cache
Represents a
ConstantPoolCache . |
private static class |
HotSpotConstantPool.JVM_CONSTANT
Enum of all
JVM_CONSTANT constants used in the VM. |
private static class |
HotSpotConstantPool.LookupTypeCacheElement |
static class |
HotSpotConstantPool.Options |
private class |
HotSpotConstantPool.ResolvedReferences
Hide the resolved references array in a private class so it cannot be accessed directly.
|
Modifier and Type | Field and Description |
---|---|
private HotSpotConstantPool.Cache |
cache
The constant pool cache of this constant pool.
|
private HotSpotConstantPool.LookupTypeCacheElement |
lastLookupType |
private long |
metaspaceConstantPool
Reference to the C++ ConstantPool object.
|
private HotSpotConstantPool.ResolvedReferences |
resolvedReferences
Resolved references of this constant pool.
|
Constructor and Description |
---|
HotSpotConstantPool(long metaspaceConstantPool) |
Modifier and Type | Method and Description |
---|---|
private void |
assertBounds(int index)
Asserts that the constant pool index
index is in the bounds of the constant pool. |
private void |
assertTag(int index,
HotSpotConstantPool.JVM_CONSTANT tag)
Asserts that the constant pool tag at index
index is equal to tag . |
private void |
assertTagIsFieldOrMethod(int index)
Asserts that the constant pool tag at index
index is a HotSpotConstantPool.JVM_CONSTANT.Fieldref ,
or a HotSpotConstantPool.JVM_CONSTANT.MethodRef , or a HotSpotConstantPool.JVM_CONSTANT.InterfaceMethodref . |
private static int |
decodeConstantPoolCacheIndex(int index)
Decode a constant pool cache index to a constant pool index.
|
private static int |
decodeInvokedynamicIndex(int i)
See
ConstantPool::decode_invokedynamic_index . |
private double |
getDoubleAt(int index)
Gets the double constant pool entry at index
index . |
private long |
getEntryAt(int index)
Gets the constant pool entry at index
index . |
private float |
getFloatAt(int index)
Gets the float constant pool entry at index
index . |
private HotSpotResolvedObjectType |
getHolder()
Gets the holder for this constant pool as
HotSpotResolvedObjectTypeImpl . |
private int |
getIntAt(int index)
Gets the integer constant pool entry at index
index . |
private static JavaType |
getJavaType(long metaspacePointer)
|
private int |
getKlassRefIndexAt(int index)
Gets the klass reference index constant pool entry at index
index . |
private int |
getKlassRefIndexAt(int index,
boolean cached)
Gets the klass reference index constant pool entry at index
index . |
private long |
getLongAt(int index)
Gets the long constant pool entry at index
index . |
private int |
getNameAndTypeAt(int index)
Gets the
JVM_CONSTANT_NameAndType constant pool entry at index index . |
private int |
getNameAndTypeRefIndexAt(int index)
Gets the
JVM_CONSTANT_NameAndType reference index constant pool entry at index
index . |
private String |
getNameRefAt(int index)
Gets the name of a
JVM_CONSTANT_NameAndType constant pool entry at index
index . |
private int |
getNameRefIndexAt(int index)
Gets the name reference index of a
JVM_CONSTANT_NameAndType constant pool entry at
index index . |
private String |
getSignatureRefAt(int index)
Gets the signature of a
JVM_CONSTANT_NameAndType constant pool entry at index
index . |
private int |
getSignatureRefIndexAt(int index)
Gets the signature reference index of a
JVM_CONSTANT_NameAndType constant pool entry
at index index . |
private HotSpotConstantPool.JVM_CONSTANT |
getTagAt(int index)
Gets the constant pool tag at index
index . |
private int |
getUncachedKlassRefIndexAt(int index)
Gets the uncached klass reference index constant pool entry at index
index . |
private static boolean |
isInvokedynamicIndex(int index)
See
ConstantPool::is_invokedynamic_index . |
private boolean |
isInvokeHandle(int methodRefCacheIndex,
HotSpotResolvedObjectTypeImpl klass) |
int |
length()
Returns the number of entries the constant pool.
|
void |
loadReferencedType(int cpi,
int opcode)
Ensures that the type referenced by the specified constant pool entry is loaded and
initialized.
|
JavaConstant |
lookupAppendix(int cpi,
int opcode)
Looks up the appendix at the specified index.
|
Object |
lookupConstant(int cpi)
Looks up a constant at the specified index.
|
JavaField |
lookupField(int cpi,
int opcode)
Looks up a reference to a field.
|
JavaMethod |
lookupMethod(int cpi,
int opcode)
Looks up a reference to a method.
|
Signature |
lookupSignature(int cpi)
Looks up a method signature.
|
JavaType |
lookupType(int cpi,
int opcode)
Looks up a reference to a type.
|
String |
lookupUtf8(int cpi)
Looks up an Utf8 string.
|
private static int |
rawIndexToConstantPoolIndex(int rawIndex,
int opcode)
Converts a raw index from the bytecodes to a constant pool index by adding a
constant . |
String |
toString() |
private final long metaspaceConstantPool
private volatile HotSpotConstantPool.LookupTypeCacheElement lastLookupType
private final HotSpotConstantPool.Cache cache
private final HotSpotConstantPool.ResolvedReferences resolvedReferences
public HotSpotConstantPool(long metaspaceConstantPool)
private HotSpotResolvedObjectType getHolder()
HotSpotResolvedObjectTypeImpl
.private static int rawIndexToConstantPoolIndex(int rawIndex, int opcode)
constant
.rawIndex
- index from the bytecodeopcode
- bytecode to convert the index forprivate static int decodeConstantPoolCacheIndex(int index)
ConstantPool::decode_cpcache_index
.index
- constant pool cache indexprivate static boolean isInvokedynamicIndex(int index)
ConstantPool::is_invokedynamic_index
.private static int decodeInvokedynamicIndex(int i)
ConstantPool::decode_invokedynamic_index
.private HotSpotConstantPool.JVM_CONSTANT getTagAt(int index)
index
.index
- constant pool indexprivate long getEntryAt(int index)
index
.index
- constant pool indexprivate int getIntAt(int index)
index
.index
- constant pool indexprivate long getLongAt(int index)
index
.index
- constant pool indexprivate float getFloatAt(int index)
index
.index
- constant pool indexprivate double getDoubleAt(int index)
index
.index
- constant pool indexprivate int getNameAndTypeAt(int index)
JVM_CONSTANT_NameAndType
constant pool entry at index index
.index
- constant pool indexJVM_CONSTANT_NameAndType
constant pool entryprivate int getNameAndTypeRefIndexAt(int index)
JVM_CONSTANT_NameAndType
reference index constant pool entry at index
index
.index
- constant pool indexJVM_CONSTANT_NameAndType
reference constant pool entryprivate String getNameRefAt(int index)
JVM_CONSTANT_NameAndType
constant pool entry at index
index
.index
- constant pool indexString
private int getNameRefIndexAt(int index)
JVM_CONSTANT_NameAndType
constant pool entry at
index index
.index
- constant pool indexprivate String getSignatureRefAt(int index)
JVM_CONSTANT_NameAndType
constant pool entry at index
index
.index
- constant pool indexString
private int getSignatureRefIndexAt(int index)
JVM_CONSTANT_NameAndType
constant pool entry
at index index
.index
- constant pool indexprivate int getKlassRefIndexAt(int index, boolean cached)
index
. See
ConstantPool::klass_ref_index_at
.index
- constant pool indexcached
- whether to go through the constant pool cacheprivate int getKlassRefIndexAt(int index)
index
. See
ConstantPool::klass_ref_index_at
.index
- constant pool indexprivate int getUncachedKlassRefIndexAt(int index)
index
. See:
ConstantPool::uncached_klass_ref_index_at
.index
- constant pool indexprivate void assertBounds(int index)
index
is in the bounds of the constant pool.index
- constant pool indexprivate void assertTag(int index, HotSpotConstantPool.JVM_CONSTANT tag)
index
is equal to tag
.index
- constant pool indextag
- expected tagprivate void assertTagIsFieldOrMethod(int index)
index
is a HotSpotConstantPool.JVM_CONSTANT.Fieldref
,
or a HotSpotConstantPool.JVM_CONSTANT.MethodRef
, or a HotSpotConstantPool.JVM_CONSTANT.InterfaceMethodref
.index
- constant pool indexpublic int length()
ConstantPool
length
in interface ConstantPool
public Object lookupConstant(int cpi)
ConstantPool
lookupConstant
in interface ConstantPool
cpi
- the constant pool indexConstant
or JavaType
instance representing the constant pool
entrypublic String lookupUtf8(int cpi)
ConstantPool
lookupUtf8
in interface ConstantPool
cpi
- the constant pool indexcpi
in this constant poolpublic Signature lookupSignature(int cpi)
ConstantPool
lookupSignature
in interface ConstantPool
cpi
- the constant pool indexcpi
in this constant poolpublic JavaConstant lookupAppendix(int cpi, int opcode)
ConstantPool
lookupAppendix
in interface ConstantPool
cpi
- the constant pool indexopcode
- the opcode of the instruction for which the lookup is being performed or
-1
null
private static JavaType getJavaType(long metaspacePointer)
metaspacePointer
- either a metaspace Klass or a metaspace Symbolpublic JavaMethod lookupMethod(int cpi, int opcode)
ConstantPool
opcode
is non-negative, then resolution checks
specific to the bytecode it denotes are performed if the method is already resolved. Should
any of these checks fail, an unresolved method reference is returned.lookupMethod
in interface ConstantPool
cpi
- the constant pool indexopcode
- the opcode of the instruction for which the lookup is being performed or
-1
cpi
in this poolpublic JavaType lookupType(int cpi, int opcode)
ConstantPool
opcode
is non-negative, then resolution checks
specific to the bytecode it denotes are performed if the type is already resolved. Should any
of these checks fail, an unresolved type reference is returned.lookupType
in interface ConstantPool
cpi
- the constant pool indexopcode
- the opcode of the instruction for which the lookup is being performed or
-1
public JavaField lookupField(int cpi, int opcode)
ConstantPool
opcode
is non-negative, then resolution checks
specific to the bytecode it denotes are performed if the field is already resolved. Should
any of these checks fail, an unresolved field reference is returned.lookupField
in interface ConstantPool
cpi
- the constant pool indexopcode
- the opcode of the instruction for which the lookup is being performed or
-1
cpi
in this poolpublic void loadReferencedType(int cpi, int opcode)
ConstantPool
loadReferencedType
in interface ConstantPool
cpi
- the index of the constant pool entry that references the typeopcode
- the opcode of the instruction that references the typeprivate boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass)