RFR: 8263102: Expand documention of Method.isBridge [v3]
Joe Darcy
darcy at openjdk.java.net
Tue Mar 9 19:16:11 UTC 2021
On Tue, 9 Mar 2021 07:19:27 GMT, Rémi Forax <github.com+828220+forax at openjdk.org> wrote:
>> Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Respond to review feedback.
>
> src/java.base/share/classes/java/lang/reflect/Method.java line 589:
>
>> 587: * different return type, the virtual machine does not.
>> 588: * A
>> 589: * common case where covariant overrides are used is for a {@link
>
> I think the example should be clearer because here, you don't show the code of EnumSet.clone().
> I wonder if it's not easier if all the code is visible
> interface I {
> Object m();
> }
> class A implements I {
> String m() { return "hello"; }
> }
> so you can explain that the VM do the dispatch on I::m()Object so the compiler has to insert a method A::m()Object,
> the bridge method with this pseudo-code
> class A implements I {
> /* bridge */ Object m() { return m(); } // calls m()String
> String m() { return "hello"; }
> }
Hi Remi,
Thanks for the feedback. I did consider that kind of approach of an example from scratch. I judged referencing instances of bridge methods in the base module to be helpful to demonstrate it wasn't too esoteric of a feature in terms of it is something you, as a developer, may already have seen. Also, given the likely audience of the reading Class.isBridge, I didn't think a stand-alone example was warranted.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2852
More information about the core-libs-dev
mailing list