On Wed, 7 Oct 2020 21:31:29 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> I'm thinking a static method `InvocationHandler::invokeDefaultMethod` and no 
>> new method in `Proxy` class.   Proxy class
>> will still have the package-private methods for 
>> `InvocationHandler::invokeDefaultMethod` implementation to use.
>> It may seem to be cleaner to be a default method at the use site called from 
>> InvocationHandler.  However, it's not
>> really a method meant to be overridden.
>
> Thanks for the input Peter.
> 
>> I'm in favour of following the bytecode (method handles) behaviour here even 
>> though it allows more than Java language
>> allows.
> 
> The proposal intends to follow the bytecode behavior.   I can clarify in the 
> javadoc.

`invokeDefaultMethod` is moved to a static method in `InvocationHandler`.
 I also add `@throws IllegalAccessException` if the specified default method is
inaccessible to the caller (access check was missing in the previous version).
The declaring interface of the default method must be exported to the caller to
use.  If it's a non-public interface, the caller class must be in the same 
runtime
package as the interface.  The example in javadoc includes the case when
the proxy interface is modified.

-------------

PR: https://git.openjdk.java.net/jdk/pull/313

Reply via email to