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 Mon Jul 14 19:55:43 2014
--- new/src/share/classes/java/lang/invoke/MethodHandle.java Mon Jul 14 19:55:43 2014
*** 1312,1324 ****
--- 1312,1342 ----
}
throw member.makeAccessException("cannot make variable arity", null);
}
/*non-public*/
! MethodHandle viewAsType(MethodType newType, boolean strict) {
// No actual conversions, just a new view of the same method.
return MethodHandleImpl.makePairwiseConvert(this, newType, 0);
+ // Note that this operation must not produce a DirectMethodHandle,
+ // because retyped DMHs, like any transformed MHs,
+ // cannot be cracked into MethodHandleInfo.
+ assert viewAsTypeChecks(newType, strict);
+ BoundMethodHandle mh = rebind();
+ assert(!((MethodHandle)mh instanceof DirectMethodHandle));
+ return mh.copyWith(newType, mh.form);
+ }
+
+ /*non-public*/
+ boolean viewAsTypeChecks(MethodType newType, boolean strict) {
+ if (strict) {
+ assert(type().isViewableAs(newType, true))
+ : Arrays.asList(this, newType);
+ } else {
+ assert(type().basicType().isViewableAs(newType.basicType(), true))
+ : Arrays.asList(this, newType);
+ }
+ return true;
}
// Decoding
/*non-public*/
*** 1370,1379 ****
--- 1388,1400 ----
//// Method handle implementation methods.
//// Sub-classes can override these default implementations.
//// All these methods assume arguments are already validated.
/*non-public*/
+ abstract MethodHandle copyWith(MethodType mt, LambdaForm lf);
+
+ /*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*) }
src/share/classes/java/lang/invoke/MethodHandle.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File