RFR: 8373243 : EnumSet.spliterator() should specify and document its characteristics [v3]
ExE Boss
duke at openjdk.org
Wed Feb 25 11:09:57 UTC 2026
On Tue, 27 Jan 2026 15:45:38 GMT, Viktor Klang <vklang at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/EnumSet.java line 524:
>>
>>> 522: */
>>> 523: @Override
>>> 524: public final Spliterator<E> spliterator() {
>>
>> Maybe keep this method non‑`final` so that specialised implementations may be provided by `SimpleEnumSet` or `JumboEnumSet` in the future without needing to remove the `final` modifier.
>> Suggestion:
>>
>> public Spliterator<E> spliterator() {
>
> On the contrary, I think adding `final` here serves as a good indicator to anyone possibly wanting to override spliterator() that they need to consider the behavior of the superclass' implementation. AS EnumSet is `sealed` there is no risk to non-jdk code and dropping the `final`-modifier later is trivial.
Changing `final`ness of a public method on a **JDK**‑`sealed` hierarchy still requires a **CSR**, since it’s considered a part of the **JavaSE API** specification.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28696#discussion_r2851083060
More information about the core-libs-dev
mailing list