On Tue, 9 Mar 2021 03:27:29 GMT, Joe Darcy <da...@openjdk.org> wrote:
>> The existing documentation of Method.isBridge isn't terribly helpful to the >> reader. This RFE proposes to given a common example of how bridge methods >> are used. The JLS does *not* have a section discussing bridge methods in >> detail; bridge methods are a compilation technique for lowering the Java >> language to the JVM, they are not a language feature per se. The example >> given is not exhaustive; there can be and are other uses of bridge methods. >> >> Once the text is agreed to; I'll update the copyright year as well. > > 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"; } } ------------- PR: https://git.openjdk.java.net/jdk/pull/2852