src/java.base/share/classes/java/lang/invoke/MethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Wed Nov 19 14:27:38 2014
--- new/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Wed Nov 19 14:27:37 2014

*** 865,883 **** --- 865,879 ---- */ public MethodHandle asSpreader(Class<?> arrayType, int arrayLength) { MethodType postSpreadType = asSpreaderChecks(arrayType, arrayLength); int arity = type().parameterCount(); int spreadArgPos = arity - arrayLength; if (USE_LAMBDA_FORM_EDITOR) { MethodHandle afterSpread = this.asType(postSpreadType); BoundMethodHandle mh = afterSpread.rebind(); LambdaForm lform = mh.editor().spreadArgumentsForm(1 + spreadArgPos, arrayType, arrayLength); MethodType preSpreadType = postSpreadType.replaceParameterTypes(spreadArgPos, arity, arrayType); return mh.copyWith(preSpreadType, lform); } else { return MethodHandleImpl.makeSpreadArguments(this, arrayType, spreadArgPos, arrayLength); } } /** * See if {@code asSpreader} can be validly called with the given arguments. * Return the type of the method handle call after spreading but before conversions.
*** 994,1020 **** --- 990,1008 ---- * @see #asVarargsCollector */ public MethodHandle asCollector(Class<?> arrayType, int arrayLength) { asCollectorChecks(arrayType, arrayLength); int collectArgPos = type().parameterCount() - 1; if (USE_LAMBDA_FORM_EDITOR) { BoundMethodHandle mh = rebind(); MethodType resultType = type().asCollectorType(arrayType, arrayLength); MethodHandle newArray = MethodHandleImpl.varargsArray(arrayType, arrayLength); LambdaForm lform = mh.editor().collectArgumentArrayForm(1 + collectArgPos, newArray); if (lform != null) { return mh.copyWith(resultType, lform); } lform = mh.editor().collectArgumentsForm(1 + collectArgPos, newArray.type().basicType()); return mh.copyWithExtendL(resultType, lform, newArray); } else { MethodHandle target = this; if (arrayType != type().parameterType(collectArgPos)) target = MethodHandleImpl.makePairwiseConvert(this, type().changeParameterType(collectArgPos, arrayType), true); MethodHandle collector = MethodHandleImpl.varargsArray(arrayType, arrayLength); return MethodHandles.collectArguments(target, collectArgPos, collector); } } /** * See if {@code asCollector} can be validly called with the given arguments. * Return false if the last parameter is not an exact match to arrayType.

src/java.base/share/classes/java/lang/invoke/MethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File