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

collect/reduce accumulator functions marked misleadingly as associative

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The accumulator in the following Stream methods
      <R> R collect(Supplier<R> supplier,
                    BiConsumer<R,? super T> accumulator,
                    BiConsumer<R,R> combiner)

      and
      <U> U reduce(U identity,
                   BiFunction<U,? super T,U> accumulator,
                   BinaryOperator<U> combiner)

      are marked as associative in the javadoc description . But they cannot be associative as their input parameters are of different type (or at least they can be).
      This is a little bit confusing.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      accumulator - an non-interfering, stateless function for incorporating an additional element into a result
      ACTUAL -
      accumulator - an associative, non-interfering, stateless function for incorporating an additional element into a result

      URL OF FAULTY DOCUMENTATION :
      http://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html

            psandoz Paul Sandoz
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: