RFR: 8376698: Add Spliterator tests for TreeMap sub-maps

Oli Gillespie ogillespie at openjdk.org
Thu Jan 29 12:47:49 UTC 2026


Add missing cases to SpliteratorTraversingAndSplittingTest. This came up when I was fixing https://bugs.openjdk.org/browse/JDK-8372946, and I noticed the tests do not cover these sub-maps.

Two interesting parts:

1. These tests failed when first added because `SubMapKeyIterator` and `DescendingSubMapKeyIterator` do not eagerly throw `NullPointerException` for `null` action arguments. The spec says "Throws: NullPointerException - if the specified action is null", so I updated the implementation to match other spliterators.
2. Since the descending maps have the reverse expected iteration order, I added support in the test harness for descending maps.

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

Commit messages:
 - Switch to Objects.requireNonNull
 - Add tests and fix impl

Changes: https://git.openjdk.org/jdk/pull/29485/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29485&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8376698
  Stats: 30 lines in 2 files changed: 29 ins; 1 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/29485.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29485/head:pull/29485

PR: https://git.openjdk.org/jdk/pull/29485


More information about the core-libs-dev mailing list