On Tue, 21 Feb 2023 03:39:46 GMT, Tingjun Yuan <d...@openjdk.org> wrote:

>> Currently, the two subclasses of `java.util.EnumSet` optimize bulk 
>> operations when the argument is also a `EnumSet`, but there is no such 
>> optimization for wrapper sets (returned by `Collections.unmodifiableSet`, 
>> `Collections.synchronizedSet`, etc.) and immutable sets (returned by 
>> `Set.of` methods) of `Enum`s.
>> 
>> This PR introduces optimization classes for these situations.  No public 
>> APIs are changed.
>
> Tingjun Yuan has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Set.copyOf: need defensive copy

Also, in JEP 441, there is pattern matching support for different enums 
implementing one interface in one switch, see the enum constants section there. 
I wonder how useful this is, and how often do we have interfaces with more than 
one enum implementations (e.g. StandardOptions/ExtendedOptions)

src/java.base/share/classes/java/util/ImmutableCollections.java line 1110:

> 1108:         static final JavaLangAccess JLA = 
> SharedSecrets.getJavaLangAccess();
> 1109: 
> 1110:         @Stable

Useless

src/java.base/share/classes/java/util/ImmutableCollections.java line 1174:

> 1172:     static final class ImmutableRegularEnumSet<E extends Enum<E>> 
> extends AbstractImmutableEnumSet<E>
> 1173:             implements RegularEnumSetCompatible<E>, Serializable {
> 1174:         @Stable

Useless

src/java.base/share/classes/java/util/ImmutableCollections.java line 1267:

> 1265:         final long[] elements;
> 1266: 
> 1267:         @Stable

Useless

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

PR Review: https://git.openjdk.org/jdk/pull/12498#pullrequestreview-1351490416
PR Review Comment: https://git.openjdk.org/jdk/pull/12498#discussion_r1144062917
PR Review Comment: https://git.openjdk.org/jdk/pull/12498#discussion_r1144064197
PR Review Comment: https://git.openjdk.org/jdk/pull/12498#discussion_r1144062709

Reply via email to