Factory methods for SequencedSet and SequencedMap
Remi Forax
forax at univ-mlv.fr
Sun Jan 19 15:18:42 UTC 2025
What can be done is to have Set.of()/Map.of() to delegate to SequenceSet.of()/SequenceMap.of() so there is only one implementation at runtime.
Also, technically, there is a way to change the return type in a binary compatible way ... if union types are supported in the language.
In that case, Set.of() can be declared like this
static <E> Set<E> | SequenceSet<E> of(E... ) {
...
}
because of erasure, the binary descriptor will use Set, but the Signature will be Set<E> | SequenceSet<E> so the compiler will see the return type as a SequencedSet .
Obviously, union types is a far bigger features than adding SequenceSet/SequenceMap so it's a big if, but it may happen in the future.
Rémi
> From: "joe darcy" <joe.darcy at oracle.com>
> To: "core-libs-dev" <core-libs-dev at openjdk.org>
> Sent: Friday, January 17, 2025 6:30:40 PM
> Subject: Re: Factory methods for SequencedSet and SequencedMap
> On 1/16/2025 11:26 PM, Rafael Winterhalter wrote:
>> Would it even be possible to change the return types of Set.of(...) and
>> Map.of(...) without breaking binary compatibility?
> In short, no.
[...]
> -Joe
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250119/956b9066/attachment.htm>
More information about the core-libs-dev
mailing list