<div dir="auto">That's the missing link. Thanks Archie.<div dir="auto"><br></div><div dir="auto">Man, I still don't get the decision-making in 1995 to make it not overridable. It is what it is.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sat, Jan 18, 2025, 10:06 AM Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com">archie.cobbs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Jan 17, 2025 at 7:50 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank" rel="noreferrer">davidalayachew@gmail.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p dir="ltr">I guess my next question is, there is no bridge method, which is why this fails. Why not add a bridge method? What is stopping Java from doing this?</p></blockquote><div>In Java class files it's possible to have two methods that differ only in their return type, but that's not allowed in Java source files (you'll get a "method already defined" error).</div><div><br></div><div>So the only way bridge methods can be created is if the compiler adds them itself. When you override a superclass instance method with a narrower (covariant) return type, this is what happens automatically on your behalf.</div><div><br></div><div>Static methods are also "inherited" by subclasses but there isn't the same concept of "overriding" - instead there is "hiding". So the compiler adding bridge methods would be inappropriate - or at the very least, they would change the semantics of the language incompatibly.<br></div><br><div>-Archie<br></div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>
</blockquote></div>