8179918: EnumSet spliterator should report SORTED, ORDERED, NONNULL#28568
8179918: EnumSet spliterator should report SORTED, ORDERED, NONNULL#28568kilink wants to merge 6 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back kilink! A progress list of the required criteria for merging this PR into |
|
@kilink This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 136 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@viktorklang-ora) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
|
Hi @kilink, This PR is currently missing a test case or two. |
I've added a basic unit test that verifies the spliterator characteristics as well as the encounter order, let me know if you think that's sufficient. Thanks! |
| Spliterator<?> spliterator = enumSet.spliterator(); | ||
| assertTrue(spliterator.hasCharacteristics(Spliterator.DISTINCT), "Missing DISTINCT"); | ||
| assertTrue(spliterator.hasCharacteristics(Spliterator.SORTED), "Missing SORTED"); | ||
| assertTrue(spliterator.hasCharacteristics(Spliterator.ORDERED), "Missing ORDERED"); | ||
| assertTrue(spliterator.hasCharacteristics(Spliterator.NONNULL), "Missing NONNULL"); |
There was a problem hiding this comment.
Thanks for adding the test. I think it makes sense to check the enumSet.spliterator().characteristics() being exactly DISTINCT | SORTED | ORDERED | NONNULL (since this test otherwise would still pass if further characteristics are added).
There was a problem hiding this comment.
Okay, I also check for SIZED / SUBSIZED since those get added by Spliterators.spliterator. I left each check split out though to make it easier to see exactly why the test fails if there's a regression.
5750b26 to
bcc973e
Compare
|
@kilink Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
| public void testSpliteratorCharacteristics() { | ||
| assertSpliteratorCharacteristics(EnumSet.allOf(Empty.class)); | ||
| assertSpliteratorCharacteristics(EnumSet.allOf(Small.class)); | ||
| assertSpliteratorCharacteristics(EnumSet.allOf(Large.class)); |
There was a problem hiding this comment.
For the sake of completeness, it probably makes sense to test the characteristics of EnumSet.of(…), EnumSet.range(…), and EnumSet.noneOf(…) as well.
viktorklang-ora
left a comment
There was a problem hiding this comment.
Thanks for this, @kilink!
|
/integrate |
|
Thank you for the review / feedback @viktorklang-ora . Would you be willing to sponsor this change? Thanks! |
|
/sponsor |
|
Going to push as commit 5f083ab.
Your commit was automatically rebased without conflicts. |
|
@viktorklang-ora @kilink Pushed as commit 5f083ab. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
Hmm. Catching up on reviews, should the behavior change here get a CSR? More broader, should there be an implSpec change under a follow-up bug and CSR that requires this behavior? |
|
@jddarcy Seems reasonable! Chasing down the super-implementation, Set::spliterator() states that overloads should report their characteristics (even if the documentation linked does seem to unnecessarily convolutedly state which characteristics the default implementation provides). I can open up a new Issue and handle the CSR-bits if @kilink doesn't mind? |
Sounds good to me, thanks! Also, apologies, it hadn't occurred to me that this would require an update to the javadocs. The existing docs do specify that the Iterator returns elements in their natural order, and that null is not permitted, so one could say that it's implied that the spliterator would also have those characteristics. But I do see now that you pointed it out that Set indicates implementations should document any additional characteristics. |
I noticed that the Spliterator for EnumSet does not report SORTED, ORDERED, or NONNULL characteristics, all of which are inherent to API of EnumSet. I found there's an existing ticket for this as well.
The ticket also mentions optimized
forEach, etc, which I presume means avoiding the default implementation that uses the iterator and just iterating over the bitset directly; I can add that here or perhaps in a follow up if it's still deemed worthwhile.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28568/head:pull/28568$ git checkout pull/28568Update a local copy of the PR:
$ git checkout pull/28568$ git pull https://git.openjdk.org/jdk.git pull/28568/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28568View PR using the GUI difftool:
$ git pr show -t 28568Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28568.diff
Using Webrev
Link to Webrev Comment