src/share/classes/java/lang/invoke/MethodHandles.java

Print this page

        

*** 1591,1601 **** * more than once in the array, and an incoming argument will be dropped * if its index does not appear in the array. * As in the case of {@link #dropArguments(MethodHandle,int,List) dropArguments}, * incoming arguments which are not mentioned in the reordering array * are may be any type, as determined only by {@code newType}. ! * <blockquote><pre> import static java.lang.invoke.MethodHandles.*; import static java.lang.invoke.MethodType.*; ... MethodType intfn1 = methodType(int.class, int.class); MethodType intfn2 = methodType(int.class, int.class, int.class); --- 1591,1601 ---- * more than once in the array, and an incoming argument will be dropped * if its index does not appear in the array. * As in the case of {@link #dropArguments(MethodHandle,int,List) dropArguments}, * incoming arguments which are not mentioned in the reordering array * are may be any type, as determined only by {@code newType}. ! * <blockquote><pre>{@code import static java.lang.invoke.MethodHandles.*; import static java.lang.invoke.MethodType.*; ... MethodType intfn1 = methodType(int.class, int.class); MethodType intfn2 = methodType(int.class, int.class, int.class);
*** 1607,1617 **** MethodHandle add = ... {int x, int y => x+y} ...; assert(add.type().equals(intfn2)); MethodHandle twice = permuteArguments(add, intfn1, 0, 0); assert(twice.type().equals(intfn1)); assert((int)twice.invokeExact(21) == 42); ! * </pre></blockquote> * @param target the method handle to invoke after arguments are reordered * @param newType the expected type of the new method handle * @param reorder an index array which controls the reordering * @return a method handle which delegates to the target after it * drops unused arguments and moves and/or duplicates the other arguments --- 1607,1617 ---- MethodHandle add = ... {int x, int y => x+y} ...; assert(add.type().equals(intfn2)); MethodHandle twice = permuteArguments(add, intfn1, 0, 0); assert(twice.type().equals(intfn1)); assert((int)twice.invokeExact(21) == 42); ! * }</pre></blockquote> * @param target the method handle to invoke after arguments are reordered * @param newType the expected type of the new method handle * @param reorder an index array which controls the reordering * @return a method handle which delegates to the target after it * drops unused arguments and moves and/or duplicates the other arguments