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)
ConstantReflectionProvider
true
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 ConstantReflectionProvider
public Integer readArrayLength(JavaConstant array)
ConstantReflectionProvider
null
if the constant is not an
array, or if the array length is not available at this point.readArrayLength
in interface ConstantReflectionProvider
public JavaConstant readArrayElement(JavaConstant array, int index)
ConstantReflectionProvider
null
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 ConstantReflectionProvider
public JavaConstant readConstantArrayElement(JavaConstant array, int index)
ConstantReflectionProvider
null
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 ConstantReflectionProvider
public JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset)
ConstantReflectionProvider
null
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 ConstantReflectionProvider
public JavaConstant readConstantFieldValue(JavaField field0, JavaConstant receiver)
ConstantReflectionProvider
static 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 ConstantReflectionProvider
receiver
- 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)
ConstantReflectionProvider
readFieldValue
in interface ConstantReflectionProvider
receiver
- 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)
ConstantReflectionProvider
ConstantReflectionProvider.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 ConstantReflectionProvider
receiver
- 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)
ConstantReflectionProvider
primitive
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 ConstantReflectionProvider
public JavaConstant unboxPrimitive(JavaConstant source)
ConstantReflectionProvider
object
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 ConstantReflectionProvider
public JavaConstant forString(String value)
ConstantReflectionProvider
JavaConstant
.forString
in interface ConstantReflectionProvider
public ResolvedJavaType asJavaType(Constant constant)
ConstantReflectionProvider
ResolvedJavaType
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 ConstantReflectionProvider
public MethodHandleAccessProvider getMethodHandleAccess()
ConstantReflectionProvider
MethodHandle
.getMethodHandleAccess
in interface ConstantReflectionProvider
public MemoryAccessProvider getMemoryAccessProvider()
ConstantReflectionProvider
getMemoryAccessProvider
in interface ConstantReflectionProvider