On Fri, 21 Jan 2022 22:49:38 GMT, Mandy Chung <mch...@openjdk.org> wrote:
> The MethodHandle of a default method should be made as a fixed arity method > handle because it is invoked via Proxy's invocation handle with a non-vararg > array of arguments. On the other hand, the `InvocationHandle::invokeDefault` > method was added in Java 16 to invoke a default method of a proxy instance. > This patch simply converts the implementation to call > `InvocationHandle::invokeDefault` instead. When testing this patch from a named module and not-exported package, I get the following exception: Exception in thread "main" java.lang.reflect.UndeclaredThrowableException at jdk.proxy1/com.sun.proxy.jdk.proxy1.$Proxy0.toString(Unknown Source) at test.openjdk/test.openjdk.ProxyTest.main(ProxyTest.java:22) Caused by: java.lang.IllegalAccessException: class java.lang.invoke.MethodHandleProxies$1 (in module java.base) cannot access interface test.openjdk.ProxyTest$Test (in module test.openjdk) because module test.openjdk does not export test.openjdk to module java.base at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394) at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) at java.base/java.lang.reflect.InvocationHandler.invokeDefault(InvocationHandler.java:278) at java.base/java.lang.invoke.MethodHandleProxies$1.invoke(MethodHandleProxies.java:202) ... 2 more [My test code](https://gist.github.com/DasBrain/60dbc1c9075b15635d9c87e8295f1c1a). Running without the patch results in the wrong output for default varargs methods, so this is a regression. ------------- PR: https://git.openjdk.java.net/jdk/pull/7185