RFR: 8159746: (proxy) Support for default methods
Mandy Chung
mchung at openjdk.java.net
Tue Oct 6 23:42:14 UTC 2020
On Wed, 30 Sep 2020 19:11:37 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> The https://github.com/mlchung/jdk/pull/1 has been updated.
>
> @plevart I have merged your PR and made minor tweak.
>
> Please review CSR: https://bugs.openjdk.java.net/browse/JDK-8253870
Joe has given some feedback in the CSR review.
> should this functionality be housed in the InvocationHandler interface rather than the Proxy class? If I understand the
> intended usage of the new method, it should only be done in an InvocationHandler.
The primary usage of this new method is `InvocationHandler`. I agree that the new API should be defined in
`InvocationHandler`.
@plevart @AlanBateman any feedback or thought on moving the new API to `InvocationHandler`?
> Does the current spec handle a case like interface A declares a default method m, interface B extends A and separately
> interface B declare a default method m.
Yes
> Would invokeDefaultMethod on A::m do-what-is-wanted by call the default method inherited from A? Indirectly, this is
> also a question if the operation that are binary compatible with respect to moving around default methods and
> behaviorally compatible with the semantics of the new method.
If a proxy instance implements both A and B, `invokeDefaultMethod(o, A.class.getMethod("m"), params)` will invoke
`A::m`.
If a proxy instance implements B only, `invokeDefaultMethod(o, A.class.getMethod("m"), params)` will get IAE thrown.
This is consistent with a concrete class implements B that can only call `B.super::m` but not `A::m`.
I update the javadoc to clarify this.
> Any special cases for hidden classes?
No because proxy cannot implement a hidden proxy interface as specified in `Proxy::newProxyInstance`
IllegalArgumentException will be thrown if any of the following restrictions is violated:
- All of Class objects in the given interfaces array must represent non-hidden interfaces, not classes or primitive types.
-------------
PR: https://git.openjdk.java.net/jdk/pull/313
More information about the core-libs-dev
mailing list