8024408: Specifications for Collection/List/Set/SortedSet.spliterator() need to document if all the (subclass) instances are required to return SIZED spliterators
authorpsandoz
Tue, 01 Oct 2013 12:19:20 +0200
changeset 20489 cce02e4a6cbe
parent 20488 a2718559a91c
child 20490 a76d16f4ad0a
8024408: Specifications for Collection/List/Set/SortedSet.spliterator() need to document if all the (subclass) instances are required to return SIZED spliterators Reviewed-by: alanb
jdk/src/share/classes/java/util/Collection.java
jdk/src/share/classes/java/util/Set.java
jdk/src/share/classes/java/util/SortedSet.java
jdk/test/java/util/Spliterator/SpliteratorCharacteristics.java
--- a/jdk/src/share/classes/java/util/Collection.java	Mon Sep 30 16:15:49 2013 -0700
+++ b/jdk/src/share/classes/java/util/Collection.java	Tue Oct 01 12:19:20 2013 +0200
@@ -503,12 +503,10 @@
     /**
      * Creates a {@link Spliterator} over the elements in this collection.
      *
-     * <p>The returned {@code Spliterator} must report the characteristic
-     * {@link Spliterator#SIZED}; implementations should document any additional
-     * characteristic values reported by the returned spliterator.  If
-     * this collection contains no elements then the returned spliterator is
-     * only required to report {@link Spliterator#SIZED} and is not required to
-     * report additional characteristic values (if any).
+     * Implementations should document characteristic values reported by the
+     * spliterator.  Such characteristic values are not required to be reported
+     * if the spliterator reports {@link Spliterator#SIZED} and this collection
+     * contains no elements.
      *
      * <p>The default implementation should be overridden by subclasses that
      * can return a more efficient spliterator.  In order to
@@ -534,9 +532,11 @@
      * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
      * from the collections's {@code Iterator}.  The spliterator inherits the
      * <em>fail-fast</em> properties of the collection's iterator.
+     * <p>
+     * The created {@code Spliterator} reports {@link Spliterator#SIZED}.
      *
      * @implNote
-     * The returned {@code Spliterator} additionally reports
+     * The created {@code Spliterator} additionally reports
      * {@link Spliterator#SUBSIZED}.
      *
      * <p>If a spliterator covers no elements then the reporting of additional
--- a/jdk/src/share/classes/java/util/Set.java	Mon Sep 30 16:15:49 2013 -0700
+++ b/jdk/src/share/classes/java/util/Set.java	Tue Oct 01 12:19:20 2013 +0200
@@ -386,15 +386,18 @@
     /**
      * Creates a {@code Spliterator} over the elements in this set.
      *
-     * <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and
-     * {@link Spliterator#DISTINCT}.  Implementations should document the
-     * reporting of additional characteristic values.
+     * <p>The {@code Spliterator} reports {@link Spliterator#DISTINCT}.
+     * Implementations should document the reporting of additional
+     * characteristic values.
      *
      * @implSpec
      * The default implementation creates a
      * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
      * from the set's {@code Iterator}.  The spliterator inherits the
      * <em>fail-fast</em> properties of the set's iterator.
+     * <p>
+     * The created {@code Spliterator} additionally reports
+     * {@link Spliterator#SIZED}.
      *
      * @implNote
      * The created {@code Spliterator} additionally reports
--- a/jdk/src/share/classes/java/util/SortedSet.java	Mon Sep 30 16:15:49 2013 -0700
+++ b/jdk/src/share/classes/java/util/SortedSet.java	Tue Oct 01 12:19:20 2013 +0200
@@ -223,10 +223,10 @@
     /**
      * Creates a {@code Spliterator} over the elements in this sorted set.
      *
-     * <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
-     * {@link Spliterator#DISTINCT}, {@link Spliterator#SORTED} and
-     * {@link Spliterator#ORDERED}.  Implementations should document the
-     * reporting of additional characteristic values.
+     * <p>The {@code Spliterator} reports {@link Spliterator#DISTINCT},
+     * {@link Spliterator#SORTED} and {@link Spliterator#ORDERED}.
+     * Implementations should document the reporting of additional
+     * characteristic values.
      *
      * <p>The spliterator's comparator (see
      * {@link java.util.Spliterator#getComparator()}) must be {@code null} if
@@ -240,6 +240,9 @@
      * from the sorted set's {@code Iterator}.  The spliterator inherits the
      * <em>fail-fast</em> properties of the set's iterator.  The
      * spliterator's comparator is the same as the sorted set's comparator.
+     * <p>
+     * The created {@code Spliterator} additionally reports
+     * {@link Spliterator#SIZED}.
      *
      * @implNote
      * The created {@code Spliterator} additionally reports
--- a/jdk/test/java/util/Spliterator/SpliteratorCharacteristics.java	Mon Sep 30 16:15:49 2013 -0700
+++ b/jdk/test/java/util/Spliterator/SpliteratorCharacteristics.java	Tue Oct 01 12:19:20 2013 +0200
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8020156 8020009 8022326 8012913 8024405
+ * @bug 8020156 8020009 8022326 8012913 8024405 8024408
  * @run testng SpliteratorCharacteristics
  */
 
@@ -46,6 +46,7 @@
 import java.util.Spliterators;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.function.Supplier;
@@ -185,6 +186,11 @@
                                  Spliterator.SIZED | Spliterator.DISTINCT);
     }
 
+    public void testWeakHashMap() {
+        assertMapCharacteristics(new WeakHashMap<>(),
+                                 Spliterator.DISTINCT);
+    }
+
     public void testHashSet() {
         assertSetCharacteristics(new HashSet<>(),
                                  Spliterator.SIZED | Spliterator.DISTINCT);