src/share/classes/java/lang/invoke/MethodHandle.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/classes/java/lang/invoke/MethodHandle.java	Tue Jul 15 17:49:28 2014
--- new/src/share/classes/java/lang/invoke/MethodHandle.java	Tue Jul 15 17:49:28 2014

*** 764,774 **** --- 764,774 ---- /** Override this to change asType behavior. */ /*non-public*/ MethodHandle asTypeUncached(MethodType newType) { if (!type.isConvertibleTo(newType)) throw new WrongMethodTypeException("cannot convert "+this+" to "+newType); ! return asTypeCache = convertArguments(newType); ! return asTypeCache = MethodHandleImpl.makePairwiseConvert(this, newType, 1); } /** * Makes an <em>array-spreading</em> method handle, which accepts a trailing array argument * and spreads its elements as positional arguments.
*** 977,987 **** --- 977,987 ---- public MethodHandle asCollector(Class<?> arrayType, int arrayLength) { asCollectorChecks(arrayType, arrayLength); int collectArgPos = type().parameterCount()-1; MethodHandle target = this; if (arrayType != type().parameterType(collectArgPos)) ! target = convertArguments(type().changeParameterType(collectArgPos, arrayType)); ! target = MethodHandleImpl.makePairwiseConvert(this, type().changeParameterType(collectArgPos, arrayType), 1); MethodHandle collector = MethodHandleImpl.varargsArray(arrayType, arrayLength); return MethodHandles.collectArguments(target, collectArgPos, collector); } /**
*** 1250,1267 **** --- 1250,1261 ---- * @throws ClassCastException if {@code x} cannot be converted * to the leading parameter type of the target * @see MethodHandles#insertArguments */ public MethodHandle bindTo(Object x) { Class<?> ptype; @SuppressWarnings("LocalVariableHidesMemberVariable") MethodType type = type(); if (type.parameterCount() == 0 || (ptype = type.parameterType(0)).isPrimitive()) throw newIllegalArgumentException("no leading reference parameter", x); x = ptype.cast(x); // throw CCE if needed return bindReceiver(x); + x = type.leadingReferenceParameter().cast(x); // throw CCE if needed + return bindArgumentL(0, x); } /** * Returns a string representation of the method handle, * starting with the string {@code "MethodHandle"} and
*** 1296,1305 **** --- 1290,1303 ---- //// Sub-classes can override these default implementations. //// All these methods assume arguments are already validated. // Other transforms to do: convert, explicitCast, permute, drop, filter, fold, GWT, catch + BoundMethodHandle bindArgumentL(int pos, Object value) { + return rebind().bindArgumentL(pos, value); + } + /*non-public*/ MethodHandle setVarargs(MemberName member) throws IllegalAccessException { if (!member.isVarargs()) return this; Class<?> arrayType = type().lastParameterType(); if (arrayType.isArray()) {
*** 1364,1404 **** --- 1362,1373 ---- //// Method handle implementation methods. //// Sub-classes can override these default implementations. //// All these methods assume arguments are already validated. /*non-public*/ MethodHandle convertArguments(MethodType newType) { // Override this if it can be improved. return MethodHandleImpl.makePairwiseConvert(this, newType, 1); } /*non-public*/ MethodHandle bindArgument(int pos, BasicType basicType, Object value) { // Override this if it can be improved. return rebind().bindArgument(pos, basicType, value); } /*non-public*/ MethodHandle bindReceiver(Object receiver) { // Override this if it can be improved. return bindArgument(0, L_TYPE, receiver); } /*non-public*/ MethodHandle dropArguments(MethodType srcType, int pos, int drops) { // Override this if it can be improved. return rebind().dropArguments(srcType, pos, drops); } /*non-public*/ MethodHandle permuteArguments(MethodType newType, int[] reorder) { // Override this if it can be improved. return rebind().permuteArguments(newType, reorder); } /*non-public*/ ! BoundMethodHandle rebind() { // Bind 'this' into a new invoker, of the known class BMH. MethodType type2 = type(); LambdaForm form2 = reinvokerForm(this); // form2 = lambda (bmh, arg*) { thismh = bmh[0]; invokeBasic(thismh, arg*) } return BoundMethodHandle.bindSingle(type2, form2, this);

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