MethodHandles.DropArguments Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
DropArguments(MethodHandle, Int32, Class[]) |
Produces a method handle which will discard some dummy arguments before calling some other specified target method handle. |
DropArguments(MethodHandle, Int32, IList<Class>) |
Produces a method handle which will discard some placeholder arguments before calling some other specified target method handle. |
DropArguments(MethodHandle, Int32, Class[])
Produces a method handle which will discard some dummy arguments before calling some other specified target method handle.
[Android.Runtime.Register("dropArguments", "(Ljava/lang/invoke/MethodHandle;I[Ljava/lang/Class;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=26)]
public static Java.Lang.Invoke.MethodHandle? DropArguments (Java.Lang.Invoke.MethodHandle? target, int pos, params Java.Lang.Class[]? valueTypes);
[<Android.Runtime.Register("dropArguments", "(Ljava/lang/invoke/MethodHandle;I[Ljava/lang/Class;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=26)>]
static member DropArguments : Java.Lang.Invoke.MethodHandle * int * Java.Lang.Class[] -> Java.Lang.Invoke.MethodHandle
Parameters
- target
- MethodHandle
the method handle to invoke after the arguments are dropped
- pos
- Int32
position of first argument to drop (zero for the leftmost)
- valueTypes
- Class[]
the type(s) of the argument(s) to drop
Returns
a method handle which drops arguments of the given types, before calling the original method handle
- Attributes
Remarks
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
DropArguments(MethodHandle, Int32, IList<Class>)
Produces a method handle which will discard some placeholder arguments before calling some other specified target method handle.
[Android.Runtime.Register("dropArguments", "(Ljava/lang/invoke/MethodHandle;ILjava/util/List;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=26)]
public static Java.Lang.Invoke.MethodHandle? DropArguments (Java.Lang.Invoke.MethodHandle? target, int pos, System.Collections.Generic.IList<Java.Lang.Class>? valueTypes);
[<Android.Runtime.Register("dropArguments", "(Ljava/lang/invoke/MethodHandle;ILjava/util/List;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=26)>]
static member DropArguments : Java.Lang.Invoke.MethodHandle * int * System.Collections.Generic.IList<Java.Lang.Class> -> Java.Lang.Invoke.MethodHandle
Parameters
- target
- MethodHandle
the method handle to invoke after the arguments are dropped
- pos
- Int32
position of first argument to drop (zero for the leftmost)
Returns
a method handle which drops arguments of the given types, before calling the original method handle
- Attributes
Remarks
Produces a method handle which will discard some placeholder arguments before calling some other specified target method handle. The type of the new method handle will be the same as the target's type, except it will also include the placeholder argument types, at some given position.
The pos
argument may range between zero and N, where N is the arity of the target. If pos
is zero, the placeholder arguments will precede the target's real arguments; if pos
is N they will come after.
<b>Example:</b> <blockquote>
{@code
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.*;
...
MethodHandle cat = lookup().findVirtual(String.class,
"concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
assertEquals(bigType, d0.type());
assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
}
</blockquote>
This method is also equivalent to the following code: <blockquote>
{@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
</blockquote>
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.