changeset 7721:334364b232d9

Disambiguate map and flatMap methods with mapToXxx for methods that change the type of the stream
author briangoetz
date Fri, 22 Mar 2013 16:10:01 -0400
parents 29664d18c7d1
children e7e7b0a6ee0b
files src/share/classes/java/util/stream/DelegatingStream.java src/share/classes/java/util/stream/DoublePipeline.java src/share/classes/java/util/stream/DoubleStream.java src/share/classes/java/util/stream/IntPipeline.java src/share/classes/java/util/stream/IntStream.java src/share/classes/java/util/stream/IntermediateOp.java src/share/classes/java/util/stream/LongPipeline.java src/share/classes/java/util/stream/LongStream.java src/share/classes/java/util/stream/Nodes.java src/share/classes/java/util/stream/ReferencePipeline.java src/share/classes/java/util/stream/Sink.java src/share/classes/java/util/stream/Stream.java src/share/classes/java/util/stream/StreamShape.java src/share/classes/java/util/stream/Streams.java src/share/classes/java/util/stream/package-info.java test-ng/boottests/java/util/stream/StreamReuseTest.java test-ng/tests/org/openjdk/tests/java/util/BitsetStreamTest.java test-ng/tests/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java test-ng/tests/org/openjdk/tests/java/util/stream/GroupByOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/IntPrimitiveOpsTests.java test-ng/tests/org/openjdk/tests/java/util/stream/LongPrimitiveOpsTests.java test-ng/tests/org/openjdk/tests/java/util/stream/MapOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/ToArrayOpTest.java test/java/io/BufferedReader/Lines.java test/java/nio/file/DirectoryStream/Entries.java test/java/nio/file/Files/StreamTest.java test/java/util/stream/Stream/IntStreamTest.java test/java/util/stream/Stream/IntegerStreamTest.java
diffstat 29 files changed, 108 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/DelegatingStream.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/DelegatingStream.java	Fri Mar 22 16:10:01 2013 -0400
@@ -92,16 +92,16 @@
         return delegate.map(mapper);
     }
 
-    public IntStream map(ToIntFunction<? super T> mapper) {
-        return delegate.map(mapper);
+    public IntStream mapToInt(ToIntFunction<? super T> mapper) {
+        return delegate.mapToInt(mapper);
     }
 
-    public LongStream map(ToLongFunction<? super T> mapper) {
-        return delegate.map(mapper);
+    public LongStream mapToLong(ToLongFunction<? super T> mapper) {
+        return delegate.mapToLong(mapper);
     }
 
-    public DoubleStream map(ToDoubleFunction<? super T> mapper) {
-        return delegate.map(mapper);
+    public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
+        return delegate.mapToDouble(mapper);
     }
 
     public <R> Stream<R> flatMap(Function<T, Stream<? extends R>> mapper) {
@@ -112,16 +112,16 @@
         return delegate.flatMap(mapper);
     }
 
-    public IntStream flatMap(FlatMapper.ToInt<? super T> mapper) {
-        return delegate.flatMap(mapper);
+    public IntStream flatMapToInt(FlatMapper.ToInt<? super T> mapper) {
+        return delegate.flatMapToInt(mapper);
     }
 
-    public LongStream flatMap(FlatMapper.ToLong<? super T> mapper) {
-        return delegate.flatMap(mapper);
+    public LongStream flatMapToLong(FlatMapper.ToLong<? super T> mapper) {
+        return delegate.flatMapToLong(mapper);
     }
 
-    public DoubleStream flatMap(FlatMapper.ToDouble<? super T> mapper) {
-        return delegate.flatMap(mapper);
+    public DoubleStream flatMapToDouble(FlatMapper.ToDouble<? super T> mapper) {
+        return delegate.flatMapToDouble(mapper);
     }
 
     public Stream<T> distinct() {
--- a/src/share/classes/java/util/stream/DoublePipeline.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/DoublePipeline.java	Fri Mar 22 16:10:01 2013 -0400
@@ -152,7 +152,7 @@
 
     @Override
     public Stream<Double> boxed() {
-        return map(Double::valueOf);
+        return mapToObj(Double::valueOf);
     }
 
     static Spliterator.OfDouble adapt(Spliterator<Double> s) {
@@ -186,7 +186,7 @@
     }
 
     @Override
-    public <U> Stream<U> map(DoubleFunction<U> mapper) {
+    public <U> Stream<U> mapToObj(DoubleFunction<U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToRef(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT, StreamShape.DOUBLE_VALUE,
                             (flags, sink) -> new Sink.ChainedDouble(sink) {
@@ -299,7 +299,7 @@
     public DoubleStream distinct() {
         // @@@ While functional and quick to implement this approach is not very efficient.
         //     An efficient version requires an double-specific map/set implementation.
-        return boxed().distinct().map(i -> (double) i);
+        return boxed().distinct().mapToDouble(i -> (double) i);
     }
 
     // Terminal ops from DoubleStream
@@ -351,7 +351,7 @@
 
     @Override
     public long count() {
-        return map(e -> null).map(e -> 1).sum();
+        return mapToObj(e -> null).mapToInt(e -> 1).sum();
     }
 
     @Override
--- a/src/share/classes/java/util/stream/DoubleStream.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/DoubleStream.java	Fri Mar 22 16:10:01 2013 -0400
@@ -56,7 +56,7 @@
 
     DoubleStream map(DoubleUnaryOperator mapper);
 
-    <U> Stream<U> map(DoubleFunction<U> mapper);
+    <U> Stream<U> mapToObj(DoubleFunction<U> mapper);
 
     IntStream map(DoubleToIntFunction mapper);
 
--- a/src/share/classes/java/util/stream/IntPipeline.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/IntPipeline.java	Fri Mar 22 16:10:01 2013 -0400
@@ -192,7 +192,7 @@
 
     @Override
     public Stream<Integer> boxed() {
-        return map(Integer::valueOf);
+        return mapToObj(Integer::valueOf);
     }
 
     @Override
@@ -208,7 +208,7 @@
     }
 
     @Override
-    public <U> Stream<U> map(IntFunction<U> mapper) {
+    public <U> Stream<U> mapToObj(IntFunction<U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToRef(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT, StreamShape.INT_VALUE,
                             (flags, sink) -> new Sink.ChainedInt(sink) {
@@ -321,7 +321,7 @@
     public IntStream distinct() {
         // @@@ While functional and quick to implement this approach is not very efficient.
         //     An efficient version requires an int-specific map/set implementation.
-        return boxed().distinct().map(i -> (int) i);
+        return boxed().distinct().mapToInt(i -> (int) i);
     }
 
     // Terminal ops from IntStream
--- a/src/share/classes/java/util/stream/IntStream.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/IntStream.java	Fri Mar 22 16:10:01 2013 -0400
@@ -85,7 +85,7 @@
      * @param mapper The function to be applied to each element
      * @return the new stream
      */
-    <U> Stream<U> map(IntFunction<U> mapper);
+    <U> Stream<U> mapToObj(IntFunction<U> mapper);
 
     /**
      * Transform this stream into one consisting of the result of applying the given function to the
--- a/src/share/classes/java/util/stream/IntermediateOp.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/IntermediateOp.java	Fri Mar 22 16:10:01 2013 -0400
@@ -59,9 +59,10 @@
  * @apiNote
  * As an example, consider the stream pipeline:
  * <pre>
- *     int oldestBob = people.stream().
- *                            filter(p -> p.getFirstName.equals("Bob")).
- *                            map(p -> p.getAge()).max();
+ *     int oldestBob = people.stream()
+ *                            .filter(p -> p.getFirstName.equals("Bob"))
+ *                            .mapToInt(p -> p.getAge())
+ *                            .max();
  * </pre>
  *
  * <p>This pipeline has two intermediate operations, filter and map.  The
--- a/src/share/classes/java/util/stream/LongPipeline.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/LongPipeline.java	Fri Mar 22 16:10:01 2013 -0400
@@ -182,7 +182,7 @@
 
     @Override
     public Stream<Long> boxed() {
-        return map(Long::valueOf);
+        return mapToObj(Long::valueOf);
     }
 
     @Override
@@ -198,7 +198,7 @@
     }
 
     @Override
-    public <U> Stream<U> map(LongFunction<U> mapper) {
+    public <U> Stream<U> mapToObj(LongFunction<U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToRef(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT, StreamShape.LONG_VALUE,
                             (flags, sink) -> new Sink.ChainedLong(sink) {
@@ -311,7 +311,7 @@
     public LongStream distinct() {
         // @@@ While functional and quick to implement this approach is not very efficient.
         //     An efficient version requires an long-specific map/set implementation.
-        return boxed().distinct().map(i -> (long) i);
+        return boxed().distinct().mapToLong(i -> (long) i);
     }
 
     // Terminal ops from LongStream
--- a/src/share/classes/java/util/stream/LongStream.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/LongStream.java	Fri Mar 22 16:10:01 2013 -0400
@@ -58,7 +58,7 @@
 
     LongStream map(LongUnaryOperator mapper);
 
-    <U> Stream<U> map(LongFunction<U> mapper);
+    <U> Stream<U> mapToObj(LongFunction<U> mapper);
 
     IntStream map(LongToIntFunction mapper);
 
--- a/src/share/classes/java/util/stream/Nodes.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/Nodes.java	Fri Mar 22 16:10:01 2013 -0400
@@ -818,7 +818,11 @@
         @Override
         public String toString() {
             if (count() < 32) {
-                return String.format("ConcNode[%s]", Arrays.stream(nodes).map(Object::toString).collect(toStringJoiner(",")).toString());
+                return String.format("ConcNode[%s]",
+                                     Arrays.stream(nodes)
+                                           .map(Object::toString)
+                                           .collect(toStringJoiner(","))
+                                           .toString());
             } else {
                 return String.format("ConcNode[size=%d]", count());
             }
@@ -1345,7 +1349,10 @@
         public String toString() {
             if (count() < 32)
                 return String.format("%s[%s]", this.getClass().getName(),
-                                     Arrays.stream(nodes).map(Object::toString).collect(toStringJoiner(",")).toString());
+                                     Arrays.stream(nodes)
+                                           .map(Object::toString)
+                                           .collect(toStringJoiner(","))
+                                           .toString());
             else
                 return String.format("%s[size=%d]", this.getClass().getName(), count());
         }
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Fri Mar 22 16:10:01 2013 -0400
@@ -170,7 +170,7 @@
     }
 
     @Override
-    public IntStream map(ToIntFunction<? super U> mapper) {
+    public IntStream mapToInt(ToIntFunction<? super U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToInt(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT, StreamShape.REFERENCE,
                             (flags, sink) -> new Sink.ChainedReference<U>(sink) {
@@ -182,7 +182,7 @@
     }
 
     @Override
-    public LongStream map(ToLongFunction<? super U> mapper) {
+    public LongStream mapToLong(ToLongFunction<? super U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToLong(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT, StreamShape.REFERENCE,
                              (flags, sink) -> new Sink.ChainedReference<U>(sink) {
@@ -194,7 +194,7 @@
     }
 
     @Override
-    public DoubleStream map(ToDoubleFunction<? super U> mapper) {
+    public DoubleStream mapToDouble(ToDoubleFunction<? super U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToDouble(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT, StreamShape.REFERENCE,
                                (flags, sink) -> new Sink.ChainedReference<U>(sink) {
@@ -224,7 +224,7 @@
     }
 
     @Override
-    public IntStream flatMap(FlatMapper.ToInt<? super U> mapper) {
+    public IntStream flatMapToInt(FlatMapper.ToInt<? super U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToInt(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED,
                             StreamShape.REFERENCE,
@@ -236,7 +236,7 @@
     }
 
     @Override
-    public DoubleStream flatMap(FlatMapper.ToDouble<? super U> mapper) {
+    public DoubleStream flatMapToDouble(FlatMapper.ToDouble<? super U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToDouble(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED,
                                StreamShape.REFERENCE,
@@ -248,7 +248,7 @@
     }
 
     @Override
-    public LongStream flatMap(FlatMapper.ToLong<? super U> mapper) {
+    public LongStream flatMapToLong(FlatMapper.ToLong<? super U> mapper) {
         Objects.requireNonNull(mapper);
         return chainedToLong(StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED,
                              StreamShape.REFERENCE,
@@ -433,6 +433,6 @@
 
     @Override
     public long count() {
-        return map(e -> 1L).sum();
+        return mapToLong(e -> 1L).sum();
     }
 }
--- a/src/share/classes/java/util/stream/Sink.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/Sink.java	Fri Mar 22 16:10:01 2013 -0400
@@ -60,7 +60,7 @@
  *     int longestStringLengthStartingWithA
  *         = strings.stream()
  *                  .filter(s -> s.startsWith("A"))
- *                  .map(String::length)
+ *                  .mapToInt(String::length)
  *                  .max();
  * </pre>
  *
--- a/src/share/classes/java/util/stream/Stream.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/Stream.java	Fri Mar 22 16:10:01 2013 -0400
@@ -102,7 +102,7 @@
      *               function to be applied to each element
      * @return the new stream
      */
-    IntStream map(ToIntFunction<? super T> mapper);
+    IntStream mapToInt(ToIntFunction<? super T> mapper);
 
     /**
      * Produce a {@code LongStream} consisting of the results of applying the given function
@@ -114,7 +114,7 @@
      *               function to be applied to each element
      * @return the new stream
      */
-    LongStream map(ToLongFunction<? super T> mapper);
+    LongStream mapToLong(ToLongFunction<? super T> mapper);
 
     /**
      * Produce a {@code DoubleStream} consisting of the results of applying the given function
@@ -126,7 +126,7 @@
      *               function to be applied to each element
      * @return the new stream
      */
-    DoubleStream map(ToDoubleFunction<? super T> mapper);
+    DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper);
 
     /**
      * Produce a {@code Stream} consisting of the results of replacing each element of this stream with the contents
@@ -190,7 +190,7 @@
      *               {@code FlatMapper.ToInt} that transforms each element into zero or more resulting values
      * @return the new stream
      */
-    IntStream flatMap(FlatMapper.ToInt<? super T> mapper);
+    IntStream flatMapToInt(FlatMapper.ToInt<? super T> mapper);
 
     /**
      * Produce a {@code LongStream} consisting of the results of replacing each element of this stream with zero
@@ -206,7 +206,7 @@
      *               {@code FlatMapper.ToLong} that transforms each element into zero or more resulting values
      * @return the new stream
      */
-    LongStream flatMap(FlatMapper.ToLong<? super T> mapper);
+    LongStream flatMapToLong(FlatMapper.ToLong<? super T> mapper);
 
     /**
      * Produce a {@code DoubleStream} consisting of the results of replacing each element of this stream with zero
@@ -222,7 +222,7 @@
      *               {@code FlatMapper.ToDouble} that transforms each element into zero or more resulting values
      * @return the new stream
      */
-    DoubleStream flatMap(FlatMapper.ToDouble<? super T> mapper);
+    DoubleStream flatMapToDouble(FlatMapper.ToDouble<? super T> mapper);
 
     /**
      * Produce a stream consisting of the distinct elements (according to {@link Object#equals(Object)}) of this stream.
--- a/src/share/classes/java/util/stream/StreamShape.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/StreamShape.java	Fri Mar 22 16:10:01 2013 -0400
@@ -47,7 +47,7 @@
  * input and output shape.  When representing primitive streams in this way, the
  * generic type parameter should correspond to the wrapper type for that
  * primitive type.  Accordingly, the {@code IntermediateOp} implementing
- * {@link Stream#map(ToIntFunction)} would have an output type parameter of
+ * {@link Stream#mapToInt(ToIntFunction)} would have an output type parameter of
  * {@code Integer} and an output shape of @{code INT_VALUE}.
  * @since 1.8
  */
--- a/src/share/classes/java/util/stream/Streams.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/Streams.java	Fri Mar 22 16:10:01 2013 -0400
@@ -1003,8 +1003,8 @@
      * A stream of equivalent values can be produced as follows:
      * <pre>
      *     long size = (long) Math.ceil((start - end) / step);
-     *     DoubleStream ds = Streams.longStream(0, size).doubles().
-     *         map(i -> start + step * i);
+     *     DoubleStream ds = Streams.longStream(0, size).doubles()
+     *         .map(i -> start + step * i);
      * </pre>
      *
      * @param start the (inclusive) initial value
--- a/src/share/classes/java/util/stream/package-info.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/src/share/classes/java/util/stream/package-info.java	Fri Mar 22 16:10:01 2013 -0400
@@ -28,7 +28,7 @@
  *
  * <pre>
  *     int sumOfWeights = blocks.stream().filter(b -> b.getColor() == RED)
- *                                       .map(b -> b.getWeight())
+ *                                       .mapToInt(b -> b.getWeight())
  *                                       .sum();
  * </pre>
  *
@@ -184,7 +184,7 @@
  *
  * <pre>
  *     int sumOfWeights = blocks.parallelStream().filter(b -> b.getColor() == RED)
- *                                               .map(b -> b.getWeight())
+ *                                               .mapToInt(b -> b.getWeight())
  *                                               .sum();
  * </pre>
  *
@@ -295,7 +295,7 @@
  * the sum of the weight of all blocks with:
  * <pre>
  *     int sumOfWeights = blocks.stream()
- *                              .map(b -> b.getWeight())
+ *                              .mapToInt(b -> b.getWeight())
  *                              .reduce(0, Integer::sum);
  * </pre>
  *
--- a/test-ng/boottests/java/util/stream/StreamReuseTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/boottests/java/util/stream/StreamReuseTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -176,15 +176,15 @@
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
     public void testTwoStreams(String name, IntStreamTestData data) {
         assertSecondFails(data,
-                          (IntStream s) -> s.map(i -> i), (IntStream s) -> s.map(i -> i),
+                          (IntStream s) -> s.mapToObj(i -> i), (IntStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "IntStream map / map succeeded erroneously");
         assertSecondFails(data,
-                          (IntStream s) -> s.distinct(), (IntStream s) -> s.map(i -> i),
+                          (IntStream s) -> s.distinct(), (IntStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "IntStream distinct / map succeeded erroneously");
         assertSecondFails(data,
-                          (IntStream s) -> s.map(i -> i), (IntStream s) -> s.distinct(),
+                          (IntStream s) -> s.mapToObj(i -> i), (IntStream s) -> s.distinct(),
                           IllegalStateException.class,
                           "IntStream map / distinct succeeded erroneously");
         assertSecondFails(data,
@@ -204,11 +204,11 @@
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
     public void testTerminalStream(String name, IntStreamTestData data) {
         assertSecondFails(data,
-                          (IntStream s) -> s.sum(), (IntStream s) -> s.map(i -> i),
+                          (IntStream s) -> s.sum(), (IntStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "IntStream sum / map succeeded erroneously");
         assertSecondFails(data,
-                          (IntStream s) -> s.map(i -> i), (IntStream s) -> s.sum(),
+                          (IntStream s) -> s.mapToObj(i -> i), (IntStream s) -> s.sum(),
                           IllegalStateException.class,
                           "IntStream map / sum succeeded erroneously");
         assertSecondFails(data,
@@ -244,11 +244,11 @@
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
     public void testStreamIterator(String name, IntStreamTestData data) {
         assertSecondFails(data,
-                          (IntStream s) -> s.iterator(), (IntStream s) -> s.map(i -> i),
+                          (IntStream s) -> s.iterator(), (IntStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "IntStream iterator / map succeeded erroneously");
         assertSecondFails(data,
-                          (IntStream s) -> s.map(i -> i), (IntStream s) -> s.iterator(),
+                          (IntStream s) -> s.mapToObj(i -> i), (IntStream s) -> s.iterator(),
                           IllegalStateException.class,
                           "IntStream map / iterator succeeded erroneously");
         assertSecondFails(data,
@@ -266,15 +266,15 @@
     @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class)
     public void testTwoStreams(String name, LongStreamTestData data) {
         assertSecondFails(data,
-                          (LongStream s) -> s.map(i -> i), (LongStream s) -> s.map(i -> i),
+                          (LongStream s) -> s.mapToObj(i -> i), (LongStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "LongStream map / map succeeded erroneously");
         assertSecondFails(data,
-                          (LongStream s) -> s.distinct(), (LongStream s) -> s.map(i -> i),
+                          (LongStream s) -> s.distinct(), (LongStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "LongStream distinct / map succeeded erroneously");
         assertSecondFails(data,
-                          (LongStream s) -> s.map(i -> i), (LongStream s) -> s.distinct(),
+                          (LongStream s) -> s.mapToObj(i -> i), (LongStream s) -> s.distinct(),
                           IllegalStateException.class,
                           "LongStream map / distinct succeeded erroneously");
         assertSecondFails(data,
@@ -294,11 +294,11 @@
     @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class)
     public void testTerminalStream(String name, LongStreamTestData data) {
         assertSecondFails(data,
-                          (LongStream s) -> s.sum(), (LongStream s) -> s.map(i -> i),
+                          (LongStream s) -> s.sum(), (LongStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "LongStream sum / map succeeded erroneously");
         assertSecondFails(data,
-                          (LongStream s) -> s.map(i -> i), (LongStream s) -> s.sum(),
+                          (LongStream s) -> s.mapToObj(i -> i), (LongStream s) -> s.sum(),
                           IllegalStateException.class,
                           "LongStream map / sum succeeded erroneously");
         assertSecondFails(data,
@@ -334,11 +334,11 @@
     @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class)
     public void testStreamIterator(String name, LongStreamTestData data) {
         assertSecondFails(data,
-                          (LongStream s) -> s.iterator(), (LongStream s) -> s.map(i -> i),
+                          (LongStream s) -> s.iterator(), (LongStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "LongStream iterator / map succeeded erroneously");
         assertSecondFails(data,
-                          (LongStream s) -> s.map(i -> i), (LongStream s) -> s.iterator(),
+                          (LongStream s) -> s.mapToObj(i -> i), (LongStream s) -> s.iterator(),
                           IllegalStateException.class,
                           "LongStream map / iterator succeeded erroneously");
         assertSecondFails(data,
@@ -356,15 +356,15 @@
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
     public void testTwoStreams(String name, DoubleStreamTestData data) {
         assertSecondFails(data,
-                          (DoubleStream s) -> s.map(i -> i), (DoubleStream s) -> s.map(i -> i),
+                          (DoubleStream s) -> s.mapToObj(i -> i), (DoubleStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "DoubleStream map / map succeeded erroneously");
         assertSecondFails(data,
-                          (DoubleStream s) -> s.distinct(), (DoubleStream s) -> s.map(i -> i),
+                          (DoubleStream s) -> s.distinct(), (DoubleStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "DoubleStream distinct / map succeeded erroneously");
         assertSecondFails(data,
-                          (DoubleStream s) -> s.map(i -> i), (DoubleStream s) -> s.distinct(),
+                          (DoubleStream s) -> s.mapToObj(i -> i), (DoubleStream s) -> s.distinct(),
                           IllegalStateException.class,
                           "DoubleStream map / distinct succeeded erroneously");
         assertSecondFails(data,
@@ -384,11 +384,11 @@
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
     public void testTerminalStream(String name, DoubleStreamTestData data) {
         assertSecondFails(data,
-                          (DoubleStream s) -> s.sum(), (DoubleStream s) -> s.map(i -> i),
+                          (DoubleStream s) -> s.sum(), (DoubleStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "DoubleStream sum / map succeeded erroneously");
         assertSecondFails(data,
-                          (DoubleStream s) -> s.map(i -> i), (DoubleStream s) -> s.sum(),
+                          (DoubleStream s) -> s.mapToObj(i -> i), (DoubleStream s) -> s.sum(),
                           IllegalStateException.class,
                           "DoubleStream map / sum succeeded erroneously");
         assertSecondFails(data,
@@ -424,11 +424,11 @@
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
     public void testStreamIterator(String name, DoubleStreamTestData data) {
         assertSecondFails(data,
-                          (DoubleStream s) -> s.iterator(), (DoubleStream s) -> s.map(i -> i),
+                          (DoubleStream s) -> s.iterator(), (DoubleStream s) -> s.mapToObj(i -> i),
                           IllegalStateException.class,
                           "DoubleStream iterator / map succeeded erroneously");
         assertSecondFails(data,
-                          (DoubleStream s) -> s.map(i -> i), (DoubleStream s) -> s.iterator(),
+                          (DoubleStream s) -> s.mapToObj(i -> i), (DoubleStream s) -> s.iterator(),
                           IllegalStateException.class,
                           "DoubleStream map / iterator succeeded erroneously");
         assertSecondFails(data,
--- a/test-ng/tests/org/openjdk/tests/java/util/BitsetStreamTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/BitsetStreamTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -24,9 +24,7 @@
  */
 package org.openjdk.tests.java.util;
 
-import java.util.Iterator;
 import java.util.PrimitiveIterator;
-import java.util.function.Consumer;
 import java.util.stream.StreamTestData;
 import java.util.stream.StreamTestDataProvider;
 import org.testng.annotations.Test;
@@ -55,7 +53,7 @@
     @Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
     public void testBitsetStream(String name, StreamTestData<Integer> data) {
         BitSet bs = new BitSet();
-        for (int i : data.stream().map(e -> (int) e).toArray())
+        for (int i : data.stream().mapToInt(e -> (int) e).toArray())
             bs.set(i);
 
         assertEquals(bs.cardinality(), data.stream().collect(Collectors.toSet()).size());
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java	Fri Mar 22 16:10:01 2013 -0400
@@ -39,7 +39,7 @@
     // @@@ tests for double are fragile if relying on equality when accumulating and multiplying values
 
     public void testUnBox() {
-        double sum = Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0).stream().map(i -> (double) i).reduce(0.0, Double::sum);
+        double sum = Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0).stream().mapToDouble(i -> (double) i).reduce(0.0, Double::sum);
         assertEquals(sum, 1.0 + 2.0 + 3.0 + 4.0 + 5.0);
     }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/GroupByOpTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/GroupByOpTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -65,7 +65,7 @@
                 = Collectors.groupingBy(Functions.forPredicate(pEven, true, false));
 
         Map<Boolean, List<Integer>> m = collector.resultSupplier().get();
-        int[] ints = countTo(10).stream().map(e -> (int) e).toArray();
+        int[] ints = countTo(10).stream().mapToInt(e -> (int) e).toArray();
         for (int i : ints)
             m = collector.accumulator().apply(m, i);
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -42,21 +42,16 @@
     private static final List<String> tenAs = Arrays.asList("A", "A", "A", "A", "A", "A", "A", "A", "A", "A");
 
     public void testRepeatLimit() {
-        assertContents(
-                Streams.generate(() -> "A").limit(10).iterator(),
-                tenAs.iterator());
+        assertContents(Streams.generate(() -> "A").limit(10).iterator(), tenAs.iterator());
     }
 
     public void testIterateLimit() {
-        assertContents(
-                Streams.iterate("A", s -> s).limit(10).iterator(),
-                tenAs.iterator());
+        assertContents(Streams.iterate("A", s -> s).limit(10).iterator(), tenAs.iterator());
     }
 
     public void testIterateFibLimit() {
-        Stream<Integer> fib = Streams.
-                iterate(new int[]{0, 1}, pair -> new int[]{pair[1], pair[0] + pair[1]}).
-                map(pair -> (Integer) pair[0]);
+        Stream<Integer> fib = Streams.iterate(new int[] {0, 1}, pair -> new int[] {pair[1], pair[0] + pair[1]})
+                                     .map(pair -> pair[0]);
 
         assertContents(
                 fib.limit(10).iterator(),
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/IntPrimitiveOpsTests.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/IntPrimitiveOpsTests.java	Fri Mar 22 16:10:01 2013 -0400
@@ -80,7 +80,7 @@
     }
 
     public void testUnBox() {
-        long sum = Arrays.asList(1, 2, 3, 4, 5).stream().map(i -> (int) i).sum();
+        long sum = Arrays.asList(1, 2, 3, 4, 5).stream().mapToInt(i -> (int) i).sum();
         assertEquals(sum, 15);
     }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/LongPrimitiveOpsTests.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/LongPrimitiveOpsTests.java	Fri Mar 22 16:10:01 2013 -0400
@@ -80,7 +80,7 @@
     }
 
     public void testUnBox() {
-        long sum = Arrays.asList(1L, 2L, 3L, 4L, 5L).stream().map(i -> (long) i).sum();
+        long sum = Arrays.asList(1L, 2L, 3L, 4L, 5L).stream().mapToLong(i -> (long) i).sum();
         assertEquals(sum, 15);
     }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/MapOpTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/MapOpTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -65,44 +65,44 @@
         exerciseOps(data, s -> s.map(mDoubler));
         exerciseOps(data, s -> s.map(mId.compose(mDoubler)));
         exerciseOps(data, s -> s.map(mDoubler.compose(mDoubler)));
-        exerciseOps(data, s -> s.map((ToIntFunction<Integer>) i -> (int) i));
-        exerciseOps(data, s -> s.map((ToLongFunction<Integer>) i -> (long) i));
-        exerciseOps(data, s -> s.map((ToDoubleFunction<Integer>) i -> (double) i));
+        exerciseOps(data, s -> s.mapToInt((ToIntFunction<Integer>) i -> (int) i));
+        exerciseOps(data, s -> s.mapToLong((ToLongFunction<Integer>) i -> (long) i));
+        exerciseOps(data, s -> s.mapToDouble((ToDoubleFunction<Integer>) i -> (double) i));
     }
 
     //
     
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
     public void testIntOps(String name, IntStreamTestData data) {
-        exerciseOps(data, s -> s.map(i -> i));
+        exerciseOps(data, s -> s.mapToObj(i -> i));
         exerciseOps(data, s -> s.map(i -> 0));
         exerciseOps(data, s -> s.map(i -> i * 2));
         exerciseOps(data, s -> s.longs());
         exerciseOps(data, s -> s.doubles());
         exerciseOps(data, s -> s.boxed());
-        exerciseOps(data, s -> s.map(e -> Integer.toString(e)));
+        exerciseOps(data, s -> s.mapToObj(e -> Integer.toString(e)));
     }
 
     //
 
     @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class)
     public void testLongOps(String name, LongStreamTestData data) {
-        exerciseOps(data, s -> s.map(i -> i));
+        exerciseOps(data, s -> s.mapToObj(i -> i));
         exerciseOps(data, s -> s.map(i -> 0L));
         exerciseOps(data, s -> s.map(i -> i * 2L));
         exerciseOps(data, s -> s.doubles());
         exerciseOps(data, s -> s.boxed());
-        exerciseOps(data, s -> s.map(e -> Long.toString(e)));
+        exerciseOps(data, s -> s.mapToObj(e -> Long.toString(e)));
     }
 
     //
 
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
     public void testDoubleOps(String name, DoubleStreamTestData data) {
-        exerciseOps(data, s -> s.map(i -> i));
+        exerciseOps(data, s -> s.mapToObj(i -> i));
         exerciseOps(data, s -> s.map(i -> 0.0));
         exerciseOps(data, s -> s.map(i -> i * 2.0));
         exerciseOps(data, s -> s.boxed());
-        exerciseOps(data, s -> s.map(e -> Double.toString(e)));
+        exerciseOps(data, s -> s.mapToObj(e -> Double.toString(e)));
     }
 }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/ToArrayOpTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/ToArrayOpTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -95,9 +95,9 @@
         exerciseTerminalOps(
                 new StreamTestData.CollectionData<>("", Arrays.asList(1.1, 2.2, 3.4, 4.4)),
                 s -> // First pipeline slice using Object[] with Double elements
-                    s.sorted().
+                    s.sorted()
                     // Second pipeline slice using Integer[] with Integer elements
-                    map((Double d) -> Integer.valueOf(d.intValue())).sorted(),
+                    .map((Double d) -> Integer.valueOf(d.intValue())).sorted(),
                 s -> s.toArray(Integer[]::new));
     }
 
--- a/test/java/io/BufferedReader/Lines.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test/java/io/BufferedReader/Lines.java	Fri Mar 22 16:10:01 2013 -0400
@@ -157,7 +157,7 @@
         try (BufferedReader br = new BufferedReader(
                                     new StringReader(data))) {
             assertEquals(br.lines()
-                           .map(l -> 1).reduce(0, (x, y) -> x + y),
+                           .mapToInt(l -> 1).reduce(0, (x, y) -> x + y),
                          total_lines,
                          data + " should produce " + total_lines + " lines.");
         } catch (IOException ioe) {
@@ -173,7 +173,7 @@
             try (BufferedReader br = new BufferedReader(new MockLineReader(i))) {
                 assertEquals(br.lines()
                                .peek(l -> assertTrue(l.matches("^Line \\d+$")))
-                               .map(l -> 1).reduce(0, (x, y) -> x + y),
+                               .mapToInt(l -> 1).reduce(0, (x, y) -> x + y),
                              i,
                              "MockLineReader(" + i + ") should produce " + i + " lines.");
             } catch (IOException ioe) {
--- a/test/java/nio/file/DirectoryStream/Entries.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test/java/nio/file/DirectoryStream/Entries.java	Fri Mar 22 16:10:01 2013 -0400
@@ -137,7 +137,7 @@
         }
 
         try (DirectoryStream<Path> ds = Files.newDirectoryStream(testFolder, "z*")) {
-            int count = ds.entries().map(p -> 1).reduce(0, Integer::sum);
+            int count = ds.entries().mapToInt(p -> 1).reduce(0, Integer::sum);
             assertEquals(count, 0, "Expect empty stream.");
         }
     }
@@ -162,7 +162,7 @@
 
     public void testEmptyFolder() throws IOException {
         try (DirectoryStream<Path> ds = Files.newDirectoryStream(testFolder.resolve("empty"))) {
-            int count = ds.entries().map(p -> 1).reduce(0, Integer::sum);
+            int count = ds.entries().mapToInt(p -> 1).reduce(0, Integer::sum);
             assertEquals(count, 0, "Expect empty stream.");
         }
     }
--- a/test/java/nio/file/Files/StreamTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test/java/nio/file/Files/StreamTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -146,7 +146,7 @@
         }
 
         try(CloseableStream<Path> s = Files.list(testFolder.resolve("empty"))) {
-            int count = s.map(p -> 1).reduce(0, Integer::sum);
+            int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
             assertEquals(count, 0, "Expect empty stream.");
         } catch (IOException ioe) {
             fail("Unexpected IOException");
@@ -187,7 +187,7 @@
     private void validateFileSystemLoopException(Path start, Path... causes) {
         try(CloseableStream<Path> s = Files.walk(start, FileVisitOption.FOLLOW_LINKS)) {
             try {
-                int count = s.map(p -> 1).reduce(0, Integer::sum);
+                int count = s.mapToInt(p -> 1).reduce(0, Integer::sum);
                 fail("Should got FileSystemLoopException, but got " + count + "elements.");
             } catch (UncheckedIOException uioe) {
                 IOException ioe = uioe.getCause();
@@ -318,7 +318,7 @@
             // zero lines
             assertTrue(Files.size(tmpfile) == 0, "File should be empty");
             try (CloseableStream<String> s = Files.lines(tmpfile, US_ASCII)) {
-                assertEquals(s.map(l -> 1).reduce(0, Integer::sum), 0, "No line expected");
+                assertEquals(s.mapToInt(l -> 1).reduce(0, Integer::sum), 0, "No line expected");
             }
 
             // one line
--- a/test/java/util/stream/Stream/IntStreamTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test/java/util/stream/Stream/IntStreamTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -394,7 +394,7 @@
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             Object[] objArray1 = stream2.map(LambdaUtilities.opIntUnaryOperator(op, randOps)).boxed().toArray();
-            Object[] objArray2 = stream3.map(LambdaUtilities.opIntFunction(op, randOps)).toArray();
+            Object[] objArray2 = stream3.mapToObj(LambdaUtilities.opIntFunction(op, randOps)).toArray();
             assertEquals(objArray1.length, objArray2.length);
             for(int index = 0; index < objArray1.length; index++) {
                 assertEquals(objArray1[index], objArray2[index]);
--- a/test/java/util/stream/Stream/IntegerStreamTest.java	Fri Mar 22 15:59:56 2013 -0400
+++ b/test/java/util/stream/Stream/IntegerStreamTest.java	Fri Mar 22 16:10:01 2013 -0400
@@ -517,7 +517,7 @@
             Stream<Integer> stream2 = (type == ParallelType.Parallel) ? c.parallelStream():
                     (type == ParallelType.Sequential) ? c.stream().sequential() :
                     c.stream();
-            PrimitiveIterator.OfInt pit = stream2.map(LambdaUtilities.opToIntFunction(op, randOps)).iterator();
+            PrimitiveIterator.OfInt pit = stream2.mapToInt(LambdaUtilities.opToIntFunction(op, randOps)).iterator();
             verifyAfterOps(c.iterator(), pit, op, randOps);
         }
     }