Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8024408

Specifications for Collection/List/Set/SortedSet.spliterator() need to document if all the (subclass) instances are required to return SIZED spliterators

    XMLWordPrintable

Details

    Description

      The current specs for the basic collections classes:

      http://download.java.net/jdk8/docs/api/java/util/List.html#spliterator%28%29
      http://download.java.net/jdk8/docs/api/java/util/Collection.html#spliterator%28%29
      http://download.java.net/jdk8/docs/api/java/util/Set.html#spliterator%28%29

      look like requiring all the subclasses to return SIZED spliterators while this may not be feasible or reasonable or make sense.

      For example:
      http://download.java.net/jdk8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html#entrySet%28%29
      may look as SIZED characteristic still should be present while it is not so.

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

      Another case - collection views of WeakHashMap don't report SIZED; consider the following code

      System.out.println( new Hashtable().entrySet().spliterator().hasCharacteristics(Spliterator.SIZED));
      System.out.println( new HashMap().entrySet().spliterator().hasCharacteristics(Spliterator.SIZED));
      System.out.println( new WeakHashMap().entrySet().spliterator().hasCharacteristics(Spliterator.SIZED));

      which will print out

      true
      true
      false


      The following JCK tests fail due to this case:
      api/java_util/WeakHashMap/EntrySetSpliterator.html#EntrySetSpliterator[characteristics_SIZED]
      api/java_util/WeakHashMap/EntrySetSpliterator.html#EntrySetSpliterator[hasCharacteristics_SIZED]
      api/java_util/WeakHashMap/KeySetSpliterator.html#KeySetSpliterator[characteristics_SIZED]
      api/java_util/WeakHashMap/KeySetSpliterator.html#KeySetSpliterator[hasCharacteristics_SIZED]
      api/java_util/WeakHashMap/ValuesSpliterator.html#ValuesSpliterator[characteristics_SIZED]
      api/java_util/WeakHashMap/ValuesSpliterator.html#ValuesSpliterator[hasCharacteristics_SIZED]

      Attachments

        Issue Links

          Activity

            People

              psandoz Paul Sandoz
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: