1874 || filterType.returnType() != targetType.parameterType(pos)) |
1874 || filterType.returnType() != targetType.parameterType(pos)) |
1875 throw newIllegalArgumentException("target and filter types do not match", targetType, filterType); |
1875 throw newIllegalArgumentException("target and filter types do not match", targetType, filterType); |
1876 return MethodHandleImpl.makeCollectArguments(target, filter, pos, false); |
1876 return MethodHandleImpl.makeCollectArguments(target, filter, pos, false); |
1877 } |
1877 } |
1878 |
1878 |
|
1879 // FIXME: Make this public in M1. |
|
1880 /*non-public*/ static |
|
1881 MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle collector) { |
|
1882 MethodType targetType = target.type(); |
|
1883 MethodType filterType = collector.type(); |
|
1884 if (filterType.returnType() != void.class && |
|
1885 filterType.returnType() != targetType.parameterType(pos)) |
|
1886 throw newIllegalArgumentException("target and filter types do not match", targetType, filterType); |
|
1887 return MethodHandleImpl.makeCollectArguments(target, collector, pos, false); |
|
1888 } |
|
1889 |
1879 /** |
1890 /** |
1880 * Adapts a target method handle by post-processing |
1891 * Adapts a target method handle by post-processing |
1881 * its return value (if any) with a filter (another method handle). |
1892 * its return value (if any) with a filter (another method handle). |
1882 * The result of the filter is returned from the adapter. |
1893 * The result of the filter is returned from the adapter. |
1883 * <p> |
1894 * <p> |