public class TruffleConstantReflectionProvider extends Object implements ConstantReflectionProvider
| Modifier and Type | Field and Description |
|---|---|
private ConstantReflectionProvider |
graalConstantReflection |
private MetaAccessProvider |
metaAccess |
| Constructor and Description |
|---|
TruffleConstantReflectionProvider(ConstantReflectionProvider graalConstantReflection,
MetaAccessProvider metaAccess) |
| Modifier and Type | Method and Description |
|---|---|
ResolvedJavaType |
asJavaType(Constant constant)
Returns the
ResolvedJavaType for a Class object (or any other object regarded
as a class by the VM) encapsulated in the given constant. |
JavaConstant |
boxPrimitive(JavaConstant source)
|
Boolean |
constantEquals(Constant x,
Constant y)
Compares two constants for equality.
|
JavaConstant |
forString(String value)
Gets a string as a
JavaConstant. |
MemoryAccessProvider |
getMemoryAccessProvider()
Gets raw memory access.
|
MethodHandleAccessProvider |
getMethodHandleAccess()
Gets access to the internals of
MethodHandle. |
JavaConstant |
readArrayElement(JavaConstant array,
int index)
Reads a value from the given array at the given index.
|
Integer |
readArrayLength(JavaConstant array)
Returns the length of the array constant.
|
JavaConstant |
readConstantArrayElement(JavaConstant array,
int index)
Reads a value from the given array at the given index if it is a stable array.
|
JavaConstant |
readConstantArrayElementForOffset(JavaConstant array,
long offset)
Reads a value from the given array at the given offset if it is a stable array.
|
JavaConstant |
readConstantFieldValue(JavaField field0,
JavaConstant receiver)
Gets the constant value of this field.
|
JavaConstant |
readFieldValue(JavaField field,
JavaConstant receiver)
Gets the current value of this field for a given object, if available.
|
JavaConstant |
readStableFieldValue(JavaField field,
JavaConstant receiver,
boolean isDefaultStable)
Gets the current value of this field for a given object, if available.
|
JavaConstant |
unboxPrimitive(JavaConstant source)
|
private boolean |
verifyFieldValue(ResolvedJavaField field,
JavaConstant constant) |
private final ConstantReflectionProvider graalConstantReflection
private final MetaAccessProvider metaAccess
public TruffleConstantReflectionProvider(ConstantReflectionProvider graalConstantReflection, MetaAccessProvider metaAccess)
public Boolean constantEquals(Constant x, Constant y)
ConstantReflectionProvidertrue if the two constants represent the same run time value,
false if they are different. Returns null if the constants
cannot be compared at this point.constantEquals in interface ConstantReflectionProviderpublic Integer readArrayLength(JavaConstant array)
ConstantReflectionProvidernull if the constant is not an
array, or if the array length is not available at this point.readArrayLength in interface ConstantReflectionProviderpublic JavaConstant readArrayElement(JavaConstant array, int index)
ConstantReflectionProvidernull if the constant
is not an array, if the index is out of bounds, or if the value is not available at this
point.readArrayElement in interface ConstantReflectionProviderpublic JavaConstant readConstantArrayElement(JavaConstant array, int index)
ConstantReflectionProvidernull if the constant is not a stable array, if it is a default value, if the index is
out of bounds, or if the value is not available at this point.readConstantArrayElement in interface ConstantReflectionProviderpublic JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset)
ConstantReflectionProvidernull if the constant is not a stable array, if it is a default value, if the offset
is out of bounds, or if the value is not available at this point.readConstantArrayElementForOffset in interface ConstantReflectionProviderpublic JavaConstant readConstantFieldValue(JavaField field0, JavaConstant receiver)
ConstantReflectionProviderstatic final field may not be
considered constant if its declaring class is not yet initialized or if it is a well known
field that can be updated via other means (e.g., System.setOut(java.io.PrintStream)).readConstantFieldValue in interface ConstantReflectionProviderreceiver - object from which this field's value is to be read. This value is ignored if
this field is static.null if this field is not considered
constant by the runtimeprivate boolean verifyFieldValue(ResolvedJavaField field, JavaConstant constant)
public JavaConstant readFieldValue(JavaField field, JavaConstant receiver)
ConstantReflectionProviderreadFieldValue in interface ConstantReflectionProviderreceiver - object from which this field's value is to be read. This value is ignored if
this field is static.null if the value is not available (e.g., because
the field holder is not yet initialized).public JavaConstant readStableFieldValue(JavaField field, JavaConstant receiver, boolean isDefaultStable)
ConstantReflectionProviderConstantReflectionProvider.readFieldValue(JavaField, JavaConstant) but treats array fields as stable.
There is no guarantee that the same value will be returned by this method for a field unless
the field is considered to be constant by the runtime.readStableFieldValue in interface ConstantReflectionProviderreceiver - object from which this field's value is to be read. This value is ignored if
this field is static.isDefaultStable - if true, default values are considered stablenull if the value is not available (e.g., because
the field holder is not yet initialized).public JavaConstant boxPrimitive(JavaConstant source)
ConstantReflectionProviderprimitive constant to a boxed
object constant, according to the Java boxing rules. Returns null
if the source is is not a primitive constant, or the boxed value is not available at this
point.boxPrimitive in interface ConstantReflectionProviderpublic JavaConstant unboxPrimitive(JavaConstant source)
ConstantReflectionProviderobject constant to a primitive constant, according to the Java unboxing rules. Returns null if the source
is is not an object constant that can be unboxed, or the unboxed value is not available at
this point.unboxPrimitive in interface ConstantReflectionProviderpublic JavaConstant forString(String value)
ConstantReflectionProviderJavaConstant.forString in interface ConstantReflectionProviderpublic ResolvedJavaType asJavaType(Constant constant)
ConstantReflectionProviderResolvedJavaType for a Class object (or any other object regarded
as a class by the VM) encapsulated in the given constant. Returns null if the
constant does not encapsulate a class, or if the type is not available at this point.asJavaType in interface ConstantReflectionProviderpublic MethodHandleAccessProvider getMethodHandleAccess()
ConstantReflectionProviderMethodHandle.getMethodHandleAccess in interface ConstantReflectionProviderpublic MemoryAccessProvider getMemoryAccessProvider()
ConstantReflectionProvidergetMemoryAccessProvider in interface ConstantReflectionProvider