Condividi tramite


MethodHandle.BindTo(Object) Method

Definition

Binds a value x to the first argument of a method handle, without invoking it.

[Android.Runtime.Register("bindTo", "(Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;", "GetBindTo_Ljava_lang_Object_Handler", ApiSince=26)]
public virtual Java.Lang.Invoke.MethodHandle? BindTo (Java.Lang.Object? x);
[<Android.Runtime.Register("bindTo", "(Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;", "GetBindTo_Ljava_lang_Object_Handler", ApiSince=26)>]
abstract member BindTo : Java.Lang.Object -> Java.Lang.Invoke.MethodHandle
override this.BindTo : Java.Lang.Object -> Java.Lang.Invoke.MethodHandle

Parameters

x
Object

the value to bind to the first argument of the target

Returns

a new method handle which prepends the given value to the incoming argument list, before calling the original method handle

Attributes

Remarks

Binds a value x to the first argument of a method handle, without invoking it. The new method handle adapts, as its target, the current method handle by binding it to the given argument. The type of the bound handle will be the same as the type of the target, except that a single leading reference parameter will be omitted.

When called, the bound handle inserts the given value x as a new leading argument to the target. The other arguments are also passed unchanged. What the target eventually returns is returned unchanged by the bound handle.

The reference x must be convertible to the first parameter type of the target.

(<em>Note:</em> Because method handles are immutable, the target method handle retains its original type and behavior.)

Java documentation for java.lang.invoke.MethodHandle.bindTo(java.lang.Object).

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