On Tue, 9 Mar 2021 19:13:24 GMT, Joe Darcy <da...@openjdk.org> wrote:
>> 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. @jddarcy, the problem i see is that `EnumSet` is not used a lot and `clone` has another layer of complexity because of CloneNotSupportedException, etc. So i'm not sure that using EnumSet.clone() is the right example here. Perhaps String.compareTo()/Comparable.compareTo() is a better example ? But generics are in the middle too. ------------- PR: https://git.openjdk.java.net/jdk/pull/2852