Sdílet prostřednictvím


MethodHandles.Lookup.FindStatic(Class, String, MethodType) Method

Definition

Produces a method handle for a static method.

[Android.Runtime.Register("findStatic", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=26)]
public Java.Lang.Invoke.MethodHandle FindStatic (Java.Lang.Class refc, string name, Java.Lang.Invoke.MethodType type);
[<Android.Runtime.Register("findStatic", "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=26)>]
member this.FindStatic : Java.Lang.Class * string * Java.Lang.Invoke.MethodType -> Java.Lang.Invoke.MethodHandle

Parameters

refc
Class

the class from which the method is accessed

name
String

the name of the method

type
MethodType

the type of the method

Returns

the desired method handle

Attributes

Remarks

Produces a method handle for a static method. The type of the method handle will be that of the method. (Since static methods do not take receivers, there is no additional receiver argument inserted into the method handle type, as there would be with #findVirtual findVirtual or #findSpecial findSpecial.) The method and all its argument types must be accessible to the lookup object.

The returned method handle will have MethodHandle#asVarargsCollector variable arity if and only if the method's variable arity modifier bit (0x0080) is set.

If the returned method handle is invoked, the method's class will be initialized, if it has not already been initialized.

<b>Example:</b> <blockquote>

{@code
            import static java.lang.invoke.MethodHandles.*;
            import static java.lang.invoke.MethodType.*;
            ...
            MethodHandle MH_asList = publicLookup().findStatic(Arrays.class,
              "asList", methodType(List.class, Object[].class));
            assertEquals("[x, y]", MH_asList.invoke("x", "y").toString());
            }

</blockquote>

Java documentation for java.lang.invoke.MethodHandles.Lookup.findStatic(java.lang.Class<?>, java.lang.String, java.lang.invoke.MethodType).

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