MethodHandles.ReflectAs(Class, MethodHandle) Method

Definition

Performs an unchecked "crack" of a direct method handle.

[Android.Runtime.Register("reflectAs", "(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;)Ljava/lang/reflect/Member;", "", ApiSince=26)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.reflect.Member" })]
public static Java.Lang.Object? ReflectAs (Java.Lang.Class? expected, Java.Lang.Invoke.MethodHandle? target);
[<Android.Runtime.Register("reflectAs", "(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;)Ljava/lang/reflect/Member;", "", ApiSince=26)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.reflect.Member" })>]
static member ReflectAs : Java.Lang.Class * Java.Lang.Invoke.MethodHandle -> Java.Lang.Object

Parameters

expected
Class

a class object representing the desired result type T

target
MethodHandle

a direct method handle to crack into symbolic reference components

Returns

a reference to the method, constructor, or field object

Attributes

Remarks

Performs an unchecked "crack" of a direct method handle. The result is as if the user had obtained a lookup object capable enough to crack the target method handle, called java.lang.invoke.MethodHandles.Lookup#revealDirect Lookup.revealDirect on the target to obtain its symbolic reference, and then called java.lang.invoke.MethodHandleInfo#reflectAs MethodHandleInfo.reflectAs to resolve the symbolic reference to a member.

If there is a security manager, its checkPermission method is called with a ReflectPermission("suppressAccessChecks") permission.

Added in 1.8.

Java documentation for java.lang.invoke.MethodHandles.reflectAs(java.lang.Class<T>, java.lang.invoke.MethodHandle).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to