Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8020146 JCK issues for java.util.stream
  3. JDK-8020014

Collections.nCopies(0, T).spliterator() is not ORDERED as expected

    XMLWordPrintable

Details

    Description

      Method Collections.nCopies() returns List spliterator of which is expected to be ORDERED.
      This is not so in the case of an empty list.
      Consider the following code:

              boolean ordered = Collections.nCopies(0, new Object()).spliterator().hasCharacteristics(Spliterator.ORDERED);
              System.out.println("ordered = " + ordered);
       

      The output will be:

      ordered = false


      The following JCK tests will fail due to this:

      api/java_util/Collections/ncopies/index.html#NCopiesSpliteratorEmpty[characteristics_ORDERED]
      api/java_util/Collections/ncopies/index.html#NCopiesSpliteratorEmpty[forEachRemaining_NPE]
      api/java_util/Collections/ncopies/index.html#NCopiesSpliteratorEmpty[hasCharacteristics_ORDERED]
      api/java_util/Collections/ncopies/index.html#NCopiesSpliteratorEmpty[tryAdvance_NPE]
      api/java_util/Collections/ncopies/index.html#NCopiesStream[checkSpliterator]
      api/java_util/Collections/ncopies/index.html#NCopiesParallelStream[checkSpliterator]


      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: