public interface SnippetReflectionProvider
This interface must not be used in Graal code that is not related to snippet processing.
Modifier and Type | Method and Description |
---|---|
<T> T |
asObject(Class<T> type,
JavaConstant constant)
Gets the object reference a given constant represents if it is of a given type.
|
Object |
asObject(ResolvedJavaType type,
JavaConstant constant)
Gets the object reference a given constant represents if it is of a given type.
|
JavaConstant |
forBoxed(Kind kind,
Object value)
Creates a boxed constant for the given kind from an Object.
|
JavaConstant |
forObject(Object object)
Creates a boxed
object constant. |
Object |
getInjectedNodeIntrinsicParameter(ResolvedJavaType type)
Gets the value to bind to an injected parameter in a node intrinsic.
|
Object |
getSubstitutionGuardParameter(Class<?> type)
Gets the value to bind to a parameter in a
SubstitutionGuard constructor. |
default Object |
invoke(ResolvedJavaMethod method,
Object receiver,
Object... args)
Invokes a given method via
Method.invoke(Object, Object...) . |
default Object |
newArray(ResolvedJavaType componentType,
int length)
Creates a new array with a given type as the component type and the specified length.
|
default Object |
readConstantFieldValue(JavaField field,
Object receiver)
Gets the constant value of this field.
|
static Class<?> |
resolveClassForSnippet(JavaType type)
Resolves a parameter or return type involved in snippet code to a
Class . |
JavaConstant forObject(Object object)
object
constant.object
- the object value to boxobject
<T> T asObject(Class<T> type, JavaConstant constant)
Kind.Object
.type
- the expected type of the object represented by constant
. If the object is
required to be of this type, then wrap the call to this method in
Objects.requireNonNull(Object)
.constant
- an object constantconstant
cast to type
if it is an
instance of
type
otherwise null
Object asObject(ResolvedJavaType type, JavaConstant constant)
Kind.Object
.type
- the expected type of the object represented by constant
. If the object is
required to be of this type, then wrap the call to this method in
Objects.requireNonNull(Object)
.constant
- an object constantconstant
if it is an
instance of
type
otherwise
null
JavaConstant forBoxed(Kind kind, Object value)
static Class<?> resolveClassForSnippet(JavaType type) throws ClassNotFoundException
Class
.ClassNotFoundException
default Object invoke(ResolvedJavaMethod method, Object receiver, Object... args)
Method.invoke(Object, Object...)
.default Object readConstantFieldValue(JavaField field, Object receiver)
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)
).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 runtimedefault Object newArray(ResolvedJavaType componentType, int length)
Array.newInstance(Class, int)
.Object getSubstitutionGuardParameter(Class<?> type)
SubstitutionGuard
constructor.type
- the type of a parameter in a SubstitutionGuard
constructorObject getInjectedNodeIntrinsicParameter(ResolvedJavaType type)
type
- the type of a parameter in a node intrinsic constructor