When Java 21 introduced sequenced collections, I was really excited to start using them. But then I quickly found that there are various corners of the JDK where it seems like the new sequenced interfaces would naturally apply, but they weren't applied. I couldn't find any acknowledgement of this, or evidence that there is any future plan to further extend the use of the sequenced collection interfaces into more of the JDK. This kind of surprises me, as normally the authors of the JDK tend to keep things very consistent and complete.
A specific example is EnumSet. As far as I can tell, there is no fundamental reason why EnumSet couldn't/shouldn't implement SequencedSet. Is it just that nobody wanted to put in the effort to implement a reversed() method for EnumSet? Or is there something more problematic that prevents it?
Here is my summary of the comments and the sources they link to:
There is no (convincing) technical argument why
EnumSetcan't or shouldn't implementSequencedSet.Implementing
reversed()wouldn't be a major problem. It is just code.So why doesn't it?
Well ... unless someone like Stuart Marks gives us a definitive answer, we don't and cannot know what the real reasons were! My guess is that the reasons were some combination of:
But it doesn't really matter why. And as @Slaw pointed out, there is a OpenJDK bug report for this that you can track: https://bugs.openjdk.org/browse/JDK-6278287. This is evidence that the team are aware of this problem, though we can't tell you if there are plans to fix it.