Factory methods for SequencedSet and SequencedMap
David Alayachew
davidalayachew at gmail.com
Sun Jan 19 14:59:19 UTC 2025
That's the missing link. Thanks Archie.
Man, I still don't get the decision-making in 1995 to make it not
overridable. It is what it is.
On Sat, Jan 18, 2025, 10:06 AM Archie Cobbs <archie.cobbs at gmail.com> wrote:
> On Fri, Jan 17, 2025 at 7:50 PM David Alayachew <davidalayachew at gmail.com>
> wrote:
>
>> 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?
>>
> 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).
>
> 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.
>
> 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.
>
> -Archie
>
> --
> Archie L. Cobbs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250119/6584cdd6/attachment-0001.htm>
More information about the core-libs-dev
mailing list