On Mon, 22 Sep 2025 06:49:11 GMT, Per Minborg <[email protected]> wrote:

>> Tagir F. Valeev has updated the pull request incrementally with two 
>> additional commits since the last revision:
>> 
>>  - Remove extra asterisk to prevent jtreg comment from being parsed as 
>> javadoc
>>  - JDK-8368178 Add specialization of SequencedCollection methods to 
>> emptyList, singletonList and nCopies
>
> In theory, `EmptyList` and `SingletonList` could implement 
> `SequencedCollection`. Same for map.

@minborg `EmptyList` already implements it, as any other `List`:

public interface List<E> extends SequencedCollection<E> { ... }


For `EmptyMap` (and even `SingletonMap` and `SingletonSet`), it's possible, but 
it will require changing the public interface (`Collections::emptyMap` will 
have to return `SequencedMap`), which may produce binary compatibility issues. 
Probably we can invent a binary-compatible signature like this:


public static final <K,V,M extends Map<K, V> & SequencedMap<K, V>> M emptyMap() 
{ ... }

But it looks ugly.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27406#issuecomment-3317232072

Reply via email to