declare namespace java { namespace lang { namespace invoke { /** * A MethodHandle is a reference to a Java-level method. It is typed according to the method's signature and can be * invoked in three ways: *
* In the case of #invokeExact, if the arguments do not match, based on a check of the MethodHandle's {@link #type()}, * a WrongMethodTypeException will be thrown. *
* In the case of #invoke, each of the arguments will be converted to the correct type, before the call is initiated. * If the conversion cannot occur, a WrongMethodTypeException will be thrown. *
* Similar to #invoke, #invokeWithArguments will convert each of the arguments and place them on the stack before * the call is initiated. If the conversion cannot occur, a WrongMethodTypeException will be thrown. *
* A MethodHandle can be created using the MethodHandles factory. * @since 1.7 */ // @ts-ignore abstract class MethodHandle extends java.lang.Object { /** * Invoke the receiver MethodHandle against the supplied arguments. The types of the arguments * must be an exact match for the MethodType of the MethodHandle. * @return The return value of the method * @throws Throwable - To ensure type safety, must be marked as throwing Throwable. * @throws WrongMethodTypeException - If the resolved method type is not exactly equal to the MethodHandle's type */ // @ts-ignore public invokeExact(...args: java.lang.Object[] | any[]): any /** * Invoke the receiver MethodHandle against the supplied arguments. If the types of the arguments * are not an exact match for the MethodType of the MethodHandle, conversions will be applied as * possible. The signature and the MethodHandle's MethodType must have the same number of arguments. * @return The return value of the method. May be converted according to the conversion rules. * @throws Throwable - To ensure type safety, must be marked as throwing Throwable. * @throws WrongMethodTypeException - If the resolved method type cannot be converted to the MethodHandle's type * @throws ClassCastException - if a conversion fails */ // @ts-ignore public invoke(...args: java.lang.Object[] | any[]): any /** * The MethodType of the MethodHandle. Invocation must match this MethodType. * @return the MethodType of the MethodHandle. */ // @ts-ignore public type(): java.lang.invoke.MethodType /** * Produce a MethodHandle that has an array of type arrayClass as its last argument and replaces the * array with spreadCount arguments from the array before calling the original MethodHandle. The * MethodType of new the methodhandle and the original methodhandle will differ only in the regards to the * last arguments. *
* The array must contain exactly spreadCount arguments to be passed to the original methodhandle. The array
* may be null in the case when spreadCount is zero. Incorrect argument array size will cause the method to
* throw an
* invoke acts as normally unless the arities differ. In that case, the trailing
* arguments are converted as though by a call to {@link #asCollector(int)} before invoking the underlying
* methodhandle.
* @param arrayParameter - the type of the array to collect the arguments into
* @return a varargs-collector methodhandle.
* @throws IllegalArgumentException - if the arrayParameter is not an array class or cannot be assigned to the last parameter of the MethodType
*/
// @ts-ignore
public asVarargsCollector(arrayParameter: java.lang.Class
* This is identical to the current method handle if {@link #isVarargsCollector()} is false.
*
* If the current method is a varargs collector, then the returned handle will be the same
* but without the varargs nature.
* @return a fixed arity version of the current method handle
*/
// @ts-ignore
public asFixedArity(): java.lang.invoke.MethodHandle
// @ts-ignore
public bindTo(value: java.lang.Object | any): java.lang.invoke.MethodHandle
// @ts-ignore
public toString(): string
}
}
}
}
IllegalArgumentException
instead of invoking the target.
* @param arrayClass - the source array for the spread arguments
* @param spreadCount - how many arguments to spread from the arrayClass
* @return a MethodHandle able to replace to the last parameter with spreadCount number of arguments
* @throws IllegalArgumentException - if arrayClass is not an array, the methodhandle has too few or too many parameters to satisfy spreadCount
* @throws WrongMethodTypeException - if it cannot convert from one MethodType to the new type.
*/
// @ts-ignore
public asSpreader(arrayClass: java.lang.Class