[9] RFR (S) 8050173: Generalize BMH.copyWith API to all method handles
http://cr.openjdk.java.net/~vlivanov/8050173/webrev.00/ https://bugs.openjdk.java.net/browse/JDK-8050173 Added j.l.i.MethodHandle.copyWith(MethodType, LambdaForm) and provided implementation for all subclasses. Also, some cleanups: * rewrote MH.viewAsType on top of MH.copyWith; * extended MH.viewAsType to do strict checks w/ assertions turned on (new parameter: boolean strict); * extended MT.isViewableAs to accept both interface preserving and interface erasing conversions (new parameter: boolean keepInterfaces). Testing: jdk/java/lang/invoke, jdk/java/util/streams, nashorn, octane w/ "-ea -esa" and COMPILE_THRESHOLD={0,30}. Reviewed-by: vlivanov, ? Contributed-by: john.r.rose@oracle.com Thanks! Best regards, Vladimir Ivanov
On Jul 14, 2014, at 4:37 PM, Vladimir Ivanov <vladimir.x.ivanov@oracle.com> wrote:
http://cr.openjdk.java.net/~vlivanov/8050173/webrev.00/ https://bugs.openjdk.java.net/browse/JDK-8050173
Added j.l.i.MethodHandle.copyWith(MethodType, LambdaForm) and provided implementation for all subclasses.
Also, some cleanups: * rewrote MH.viewAsType on top of MH.copyWith; * extended MH.viewAsType to do strict checks w/ assertions turned on (new parameter: boolean strict); * extended MT.isViewableAs to accept both interface preserving and interface erasing conversions (new parameter: boolean keepInterfaces).
Testing: jdk/java/lang/invoke, jdk/java/util/streams, nashorn, octane w/ "-ea -esa" and COMPILE_THRESHOLD={0,30}.
Reviewed-by: vlivanov, ? Contributed-by: john.r.rose@oracle.com
Looks good, just one comment. MethodHandles.restrictReceiver This method has: 1578 private MethodHandle restrictReceiver(MemberName method, MethodHandle mh, Class<?> caller) throws IllegalAccessException { ... 1589 assert(mh instanceof DirectMethodHandle); // DirectMethodHandle.copyWith Why not make the second parameter be "DirectMethodHandle mh" ? Paul.
http://cr.openjdk.java.net/~vlivanov/8050173/webrev.00/ https://bugs.openjdk.java.net/browse/JDK-8050173
Added j.l.i.MethodHandle.copyWith(MethodType, LambdaForm) and provided implementation for all subclasses.
Also, some cleanups: * rewrote MH.viewAsType on top of MH.copyWith; * extended MH.viewAsType to do strict checks w/ assertions turned on (new parameter: boolean strict); * extended MT.isViewableAs to accept both interface preserving and interface erasing conversions (new parameter: boolean keepInterfaces).
Testing: jdk/java/lang/invoke, jdk/java/util/streams, nashorn, octane w/ "-ea -esa" and COMPILE_THRESHOLD={0,30}.
Reviewed-by: vlivanov, ? Contributed-by: john.r.rose@oracle.com
Looks good, just one comment.
MethodHandles.restrictReceiver
This method has:
1578 private MethodHandle restrictReceiver(MemberName method, MethodHandle mh, Class<?> caller) throws IllegalAccessException { ... 1589 assert(mh instanceof DirectMethodHandle); // DirectMethodHandle.copyWith
Why not make the second parameter be "DirectMethodHandle mh" ? Good point! While prototyping this I spotted uncovered corner case (restrict a receiver on a MH with bound caller).
Updated webrev: http://cr.openjdk.java.net/~vlivanov/8050173/webrev.01/ Diff: http://cr.openjdk.java.net/~vlivanov/8050173/webrev.00.01/ Reordered restrictReceiver and maybeBindCaller operations. Best regards, Vladimir Ivanov
On Sep 5, 2014, at 3:15 PM, Vladimir Ivanov <vladimir.x.ivanov@oracle.com> wrote:
Looks good, just one comment.
MethodHandles.restrictReceiver
This method has:
1578 private MethodHandle restrictReceiver(MemberName method, MethodHandle mh, Class<?> caller) throws IllegalAccessException { ... 1589 assert(mh instanceof DirectMethodHandle); // DirectMethodHandle.copyWith
Why not make the second parameter be "DirectMethodHandle mh" ?
Good point! While prototyping this I spotted uncovered corner case (restrict a receiver on a MH with bound caller).
Updated webrev: http://cr.openjdk.java.net/~vlivanov/8050173/webrev.01/ Diff: http://cr.openjdk.java.net/~vlivanov/8050173/webrev.00.01/
Reordered restrictReceiver and maybeBindCaller operations.
Looks good, Paul.
On Jul 16, 2014, at 1:50 AM, Paul Sandoz <paul.sandoz@oracle.com> wrote:
Why not make the second parameter be "DirectMethodHandle mh" ?
Good suggestion; thanks. Makes the restrictReceiver logic less magic. — John
participants (3)
-
John Rose
-
Paul Sandoz
-
Vladimir Ivanov