RFR: 8373243 : EnumSet.spliterator() should specify and document its characteristics

Viktor Klang vklang at openjdk.org
Mon Dec 8 14:18:39 UTC 2025


On Mon, 8 Dec 2025 12:14:46 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Addresses https://bugs.openjdk.org/browse/JDK-8373243 by copying and adapting the specification from https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/LinkedHashSet.java#L186-L204
>> 
>> Since EnumSet is sealed and only permits two final classes, the verbiage around "Implementations should document the reporting of additional characteristic values." may be considered to get removed from this PR. Kept, for now, for symmetry reasons.
>
> src/java.base/share/classes/java/util/EnumSet.java line 512:
> 
>> 510:      * {@link Spliterator#DISTINCT}, {@link Spliterator#SORTED},
>> 511:      * {@link Spliterator#NONNULL}, and {@link Spliterator#ORDERED}.
>> 512:      * Implementations should document the reporting of additional characteristic values.
> 
> EnumSet is sealed and the permitted implementations are non-public/JDK-internal.  I'm wondering if the override should be specified "as if" the class were final.

I think I agree. So that'd mean removing "Implementations should document the reporting of additional characteristic values." _and_ making spliterator() **final** to ensure that it doesn't get invalidated by "accident". Does that sound reasonable to you?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28696#discussion_r2598805320


More information about the core-libs-dev mailing list