RFR 8043328 and 8043327: errors in stream docs

Paul Sandoz paul.sandoz at oracle.com
Wed Jul 2 08:25:26 UTC 2014


Hi,

Stuarts recent doc fix from Raoul reminded me about a few others:

  https://bugs.openjdk.java.net/browse/JDK-8043328
  Typo in documentation of package java.util.stream

  https://bugs.openjdk.java.net/browse/JDK-8043327
  Collectors.toMap studentToGPA example uses Functions.identity()

See below for patch.

Stuart, are you planning to back port your doc fix to 8u-dev? If so we could do all three in one go.

Paul.

diff -r 4623ea09772f src/share/classes/java/util/stream/Collectors.java
--- a/src/share/classes/java/util/stream/Collectors.java	Wed Jul 02 08:41:59 2014 +0200
+++ b/src/share/classes/java/util/stream/Collectors.java	Wed Jul 02 10:23:57 2014 +0200
@@ -1220,7 +1220,7 @@
      * students to their grade point average:
      * <pre>{@code
      *     Map<Student, Double> studentToGPA
-     *         students.stream().collect(toMap(Functions.identity(),
+     *         students.stream().collect(toMap(Function.identity(),
      *                                         student -> computeGPA(student)));
      * }</pre>
      * And the following produces a {@code Map} mapping a unique identifier to
@@ -1228,7 +1228,7 @@
      * <pre>{@code
      *     Map<String, Student> studentIdToStudent
      *         students.stream().collect(toMap(Student::getId,
-     *                                         Functions.identity());
+     *                                         Function.identity());
      * }</pre>
      *
      * @implNote
@@ -1390,7 +1390,7 @@
      * students to their grade point average:
      * <pre>{@code
      *     Map<Student, Double> studentToGPA
-     *         students.stream().collect(toMap(Functions.identity(),
+     *         students.stream().collect(toMap(Function.identity(),
      *                                         student -> computeGPA(student)));
      * }</pre>
      * And the following produces a {@code Map} mapping a unique identifier to
@@ -1398,7 +1398,7 @@
      * <pre>{@code
      *     Map<String, Student> studentIdToStudent
      *         students.stream().collect(toConcurrentMap(Student::getId,
-     *                                                   Functions.identity());
+     *                                                   Function.identity());
      * }</pre>
      *
      * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and
diff -r 4623ea09772f src/share/classes/java/util/stream/package-info.java
--- a/src/share/classes/java/util/stream/package-info.java	Wed Jul 02 08:41:59 2014 +0200
+++ b/src/share/classes/java/util/stream/package-info.java	Wed Jul 02 10:23:57 2014 +0200
@@ -468,7 +468,7 @@
  * <pre>{@code
  *     int sumOfWeights = widgets.stream()
  *                               .reduce(0,
- *                                       (sum, b) -> sum + b.getWeight())
+ *                                       (sum, b) -> sum + b.getWeight(),
  *                                       Integer::sum);
  * }</pre>
  * though the explicit map-reduce form is more readable and therefore should



More information about the core-libs-dev mailing list