On 9 April 2018 at 08:33, Alan Bateman <alan.bate...@oracle.com> wrote: >> 2. Java proxies cannot invoke default methods of proxied interfaces >> >> The Java proxy API does not currently allow the invocation of an >> overridden >> default method since >> the InvocationHandler API only supplies an instance of >> java.lang.reflection.Method. > > The issue of Proxies and default methods has come up on core-libs-dev a few > times.
I hit this problem just today but am on Java 8, so Java 9 solutions are no good. The standard Java 8 workaround requires setAccessible. I found an alternative that is useful in some cases, but was worth documenting (as I didn't find it described anywhere else): https://stackoverflow.com/a/49730826/38896 I do think Proxy should be enhanced to handle default methods without use of MethodHandle. Proxy is more of an entry level tool, whereas MH is lower level. Requiring MH to solve default methods seems wrong for the typical user of Proxy. Stephen