changeset 6370:e60b1819b652

The type parameter declarations of nominal function types (SAMs in j.u.functions) that return a value are re-ordered so that the return type parameter is declared first (e.g. Mapper and FlatMapper).
author psandoz
date Mon, 05 Nov 2012 15:21:49 +0100
parents 33e0259f7495
children 685d2eb9aa05
files src/share/classes/java/util/Comparators.java src/share/classes/java/util/Iterators.java src/share/classes/java/util/functions/BiMapper.java src/share/classes/java/util/functions/BinaryOperator.java src/share/classes/java/util/functions/Combiner.java src/share/classes/java/util/functions/FlatMapper.java src/share/classes/java/util/functions/Mapper.java src/share/classes/java/util/functions/Mappers.java src/share/classes/java/util/functions/Predicates.java src/share/classes/java/util/streams/Stream.java src/share/classes/java/util/streams/ValuePipeline.java src/share/classes/java/util/streams/ops/FlatMapOp.java src/share/classes/java/util/streams/ops/FoldOp.java src/share/classes/java/util/streams/ops/GroupByOp.java src/share/classes/java/util/streams/ops/MapOp.java src/share/classes/java/util/streams/ops/MatchOp.java src/share/classes/java/util/streams/ops/ReduceByOp.java test-ng/tests/org/openjdk/tests/java/util/ComparatorsTest.java test-ng/tests/org/openjdk/tests/java/util/LambdaTestHelpers.java test-ng/tests/org/openjdk/tests/java/util/functions/MappersTest.java test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestDataProvider.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/GroupByOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeBuilderTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeTest.java test-ng/tests/org/openjdk/tests/javac/MethodReferenceTestInstanceMethod.java
diffstat 25 files changed, 88 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Comparators.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/Comparators.java	Mon Nov 05 15:21:49 2012 +0100
@@ -141,9 +141,9 @@
 
         private static final long serialVersionUID = 8900536460967781434L;
 
-        private final Mapper<? super T, ? extends U> mapper;
+        private final Mapper<? extends U, ? super T> mapper;
 
-        private MapperComparator(Mapper<? super T, ? extends U> mapper) {
+        private MapperComparator(Mapper<? extends U, ? super T> mapper) {
             Objects.requireNonNull(mapper);
             this.mapper = mapper;
         }
@@ -196,7 +196,7 @@
         return (Comparator<Mapping<K,V>>) MappingValueComparator.INSTANCE;
     }
 
-    public static <T, U extends Comparable<? super U>> Comparator<T> comparing(Mapper<? super T, ? extends U> mapper) {
+    public static <T, U extends Comparable<? super U>> Comparator<T> comparing(Mapper<? extends U, ? super T> mapper) {
         return new MapperComparator<>(mapper);
     }
 
--- a/src/share/classes/java/util/Iterators.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/Iterators.java	Mon Nov 05 15:21:49 2012 +0100
@@ -25,7 +25,6 @@
 package java.util;
 
 import java.util.functions.*;
-import java.util.streams.Stream;
 
 /**
  * Utilities for Iterators.  All of these methods consume elements from the iterators passed to them!
@@ -73,7 +72,7 @@
         return base;
     }
 
-    public static <T, U> U mapReduce(Iterator<? extends T> iterator, Mapper<? super T, ? extends U> mapper, U base, BinaryOperator<U> operator) {
+    public static <U, T> U mapReduce(Iterator<? extends T> iterator, Mapper<? extends U, ? super T> mapper, U base, BinaryOperator<U> operator) {
         Objects.requireNonNull(iterator);
         Objects.requireNonNull(mapper);
         Objects.requireNonNull(operator);
--- a/src/share/classes/java/util/functions/BiMapper.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/BiMapper.java	Mon Nov 05 15:21:49 2012 +0100
@@ -53,12 +53,12 @@
  * in any specific order.</li>
  * </ul>
  *
+ * @param <R> the type of output objects from {@code map} operation. May be the
  * @param <T> the type of input objects provided to the {@code map} operation.
  * @param <U> the type of input objects provided to the {@code map} operation.
- * @param <R> the type of output objects from {@code map} operation. May be the
  * same type as either {@code <T>} or {@code <U>}.
  */
-public interface BiMapper<T, U, R> {
+public interface BiMapper<R, T, U> {
 
     /**
      * Map the provided input objects to an appropriate output object.
@@ -80,7 +80,7 @@
      * @return A mapper which performs both the original mapping followed by
      * a second mapping.
      */
-    public <W> BiMapper<T, U, W> compose(Mapper<? super R, ? extends W> after) default {
+    public <W> BiMapper<W, T, U> compose(Mapper<? extends W, ? super R> after) default {
         throw new UnsupportedOperationException("Not yet implemented.");
     }
 }
--- a/src/share/classes/java/util/functions/BinaryOperator.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/BinaryOperator.java	Mon Nov 05 15:21:49 2012 +0100
@@ -53,7 +53,7 @@
  *
  * @param <T> the type of input objects provided to {@code eval} and the result.
  */
-public interface BinaryOperator<T> extends Combiner<T,T,T> {
+public interface BinaryOperator<T> extends Combiner<T, T, T> {
 
     public T operate(T left, T right);
 
--- a/src/share/classes/java/util/functions/Combiner.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/Combiner.java	Mon Nov 05 15:21:49 2012 +0100
@@ -29,6 +29,6 @@
  *
  * @author Brian Goetz
  */
-public interface Combiner<T, U, V> {
-    V combine(T t, U u);
+public interface Combiner<R, T, U> {
+    R combine(T t, U u);
 }
--- a/src/share/classes/java/util/functions/FlatMapper.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/FlatMapper.java	Mon Nov 05 15:21:49 2012 +0100
@@ -29,7 +29,7 @@
  *
  * @author Brian Goetz
  */
-public interface FlatMapper<T, R> {
+public interface FlatMapper<R, T> {
     /**
      * Map {@code element} and add all of the results to {@code sink}.
      *
--- a/src/share/classes/java/util/functions/Mapper.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/Mapper.java	Mon Nov 05 15:21:49 2012 +0100
@@ -53,11 +53,11 @@
  * in any specific order.</li>
  * </ul>
  *
+ * @param <R> the type of output objects from {@code map} operation. May be the
  * @param <T> the type of input objects provided to the {@code map} operation.
- * @param <R> the type of output objects from {@code map} operation. May be the
  * same type as {@code <T>}.
  */
-public interface Mapper<T, R> {
+public interface Mapper<R, T> {
 
     /**
      * Map the provided input object to an appropriate output object.
@@ -78,7 +78,7 @@
      * @return A mapper which performs both the original mapping followed by
      * a second mapping.
      */
-    public <V> Mapper<T, V> compose(Mapper<? super R, ? extends V> after) default {
+    public <V> Mapper<V, T> compose(Mapper<? extends V, ? super R> after) default {
         return Mappers.chain(this, after);
     }
 }
--- a/src/share/classes/java/util/functions/Mappers.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/Mappers.java	Mon Nov 05 15:21:49 2012 +0100
@@ -47,7 +47,7 @@
      * A mapper which performs a mapping from an object to it's
      * string representation.
      */
-    private static final Mapper<Object, String> STRING = String::valueOf;
+    private static final Mapper<String, Object> STRING = String::valueOf;
 
     /**
      * singleton utils
@@ -62,7 +62,7 @@
      * are the same type.
      */
     public static <T> Mapper<T, T> identity() {
-        return (Mapper<T,T>) IDENTITY;
+        return (Mapper<T, T>) IDENTITY;
     }
 
 //    /**
@@ -87,25 +87,25 @@
      * @return a mapper which performs a mapping from {@code <T>} to it's
      * string representation
      */
-    public static <T> Mapper<T,String> string() {
-        return (Mapper<T,String>) STRING;
+    public static <T> Mapper<String, T> string() {
+        return (Mapper<String, T>) STRING;
     }
 
     /**
      * Returns a mapper which performs a mapping from {@code <T>} to {@code <U>}
      * followed by a mapping from {@code <U>} to {@code <V>}.
      *
+     * @param <R> Type for final mapped values. May be the same type as
+     * {@code <U>}.
      * @param <T> Type for input values
      * @param <U> Type for intermediate mapped values. May be the same type as
      * {@code <T>}.
-     * @param <V> Type for final mapped values. May be the same type as
-     * {@code <U>}.
      * @param first Initial mapping from {@code <T>} to {@code <U>}.
      * @param second additional mapping from {@code <U>} to {@code <V>}.
      */
-    public static <T, U, V> Mapper<T, V> chain(
-            Mapper<? super T, ? extends U> first,
-            Mapper<? super U, ? extends V> second) {
+    public static <R, T, U> Mapper<R, T> chain(
+            Mapper<? extends U, ? super T> first,
+            Mapper<? extends R, ? super U> second) {
         Objects.requireNonNull(first);
         Objects.requireNonNull(second);
 
@@ -118,7 +118,7 @@
      * @param constant The value to be returned by the {@code map} method.
      * @return a mapper who's {@code map} method provides a constant result.
      */
-    public static <T, U> Mapper<T, U> constant(U constant) {
+    public static <R, T> Mapper<R, T> constant(R constant) {
         return t -> constant;
     }
 
@@ -140,24 +140,24 @@
      * Returns a new instance of {@code <U>} constructed with provided
      * {@code <T>}.
      *
+     * @param <R> Type of output values from mapping
      * @param <T> Type of input values to mapping
-     * @param <U> Type of output values from mapping
      * @param clazzT The {@code Class} which defines objects of type {@code <T>}
-     * @param clazzU The {@code Class} which defines objects of type {@code <U>}
-     * @return a mapper which creates instances of {@code <U>} using {@code <T>}
+     * @param clazzR The {@code Class} which defines objects of type {@code <U>}
+     * @return a mapper which creates instances of {@code <R>} using {@code <T>}
      * as the constructor parameter.
-     * @throws NoSuchMethodException when {@code <U>} has no constructor which
+     * @throws NoSuchMethodException when {@code <R>} has no constructor which
      * takes a {@code <T>} as a parameter.
      */
-    public static <T, U> Mapper<T, U> instantiate(Class<? extends T> clazzT, Class<? extends U> clazzU) {
+    public static <R, T> Mapper<R, T> instantiate(Class<? extends T> clazzT, Class<? extends R> clazzR) {
         Objects.requireNonNull(clazzT);
-        Objects.requireNonNull(clazzU);
+        Objects.requireNonNull(clazzR);
 
-        final Constructor<? extends U> constructor;
+        final Constructor<? extends R> constructor;
         try {
-            constructor = clazzU.getConstructor(clazzT);
+            constructor = clazzR.getConstructor(clazzT);
         } catch(NoSuchMethodException noConstructor) {
-            throw new IllegalArgumentException("no constructor for "+ clazzU.getSimpleName() + "(" + clazzT.getSimpleName() + ")", noConstructor);
+            throw new IllegalArgumentException("no constructor for "+ clazzR.getSimpleName() + "(" + clazzT.getSimpleName() + ")", noConstructor);
         }
 
         return t -> {
@@ -177,13 +177,13 @@
      * avoid changes to the map during operation may produce results which
      * violate the {@code map} method contract.
      *
+     * @param <R> output type from mapping operation
      * @param <T> input type to mapping operation
-     * @param <U> output type from mapping operation
      * @param map provides the mappings from {@code <T>} to {@code <U>}
      * @throws IllegalArgumentException for all values of {@code <T>} not
      * present in the map
      */
-    public static <T, U> Mapper<T, U> forMap(Map<? super T, ? extends U> map) {
+    public static <R, T> Mapper<R, T> forMap(Map<? super T, ? extends R> map) {
         Objects.requireNonNull(map);
 
         return t -> {
@@ -202,13 +202,13 @@
      * changes to the map during operation may produce results which violate the
      * {@code map} method contract.
      *
+     * @param <R> output type from mapping
      * @param <T> input type to map
-     * @param <U> output type from mapping
      * @param map provides the mappings from {@code <T>} to {@code <U>}
      * @param defaultValue the value returned by {@code map} method for
      * {@code <T>} values not contained in the provided map
      */
-    public static <T, U> Mapper<T, U> forMap(Map<? super T, ? extends U> map, U defaultValue) {
+    public static <R, T> Mapper<R, T> forMap(Map<? super T, ? extends R> map, R defaultValue) {
         Objects.requireNonNull(map);
 
         return t -> map.containsKey(t) ? map.get(t) : defaultValue;
@@ -219,15 +219,15 @@
      * {@code forTrue} is returned if the predicate returns {@code true}
      * otherwise the {@code forFalse} value is returned.
      *
+     * @param <R> output type from mapping
      * @param <T> input type to map
-     * @param <U> output type from mapping
      * @param predicate decides which value {@code map} method should return
      * @param forTrue value to be returned for {@code true} predicate results
      * @param forFalse value to be returned for {@code false} predicate results
      * @return a Mapper who's {@code map} method provides results according to
      * the provided predicate.
      */
-    public static <T, U> Mapper<T, U> forPredicate(Predicate<? super T> predicate, U forTrue, U forFalse) {
+    public static <R, T> Mapper<R, T> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
         Objects.requireNonNull(predicate);
 
         return t -> predicate.test(t) ? forTrue : forFalse;
--- a/src/share/classes/java/util/functions/Predicates.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/functions/Predicates.java	Mon Nov 05 15:21:49 2012 +0100
@@ -174,7 +174,7 @@
      * @return the composition of the provided mapper and predicate
      */
     public static <T, V> Predicate<T> compose(
-            Predicate<? super V> predicate, Mapper<? super T, ? extends V> mapper) {
+            Predicate<? super V> predicate, Mapper<? extends V, ? super T> mapper) {
         return t -> predicate.test(mapper.map(t));
     }
 
--- a/src/share/classes/java/util/streams/Stream.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/Stream.java	Mon Nov 05 15:21:49 2012 +0100
@@ -41,9 +41,9 @@
 
     Stream<T> filter(Predicate<? super T> predicate);
 
-    <R> Stream<R> map(Mapper<? super T, ? extends R> mapper);
+    <R> Stream<R> map(Mapper<? extends R, ? super T> mapper);
 
-    <R> Stream<R> flatMap(FlatMapper<? super T, R> mapper);
+    <R> Stream<R> flatMap(FlatMapper<? extends R, ? super T> mapper);
 
     Stream<T> uniqueElements();
 
@@ -89,18 +89,18 @@
 
     Object[] toArray();
 
-    <U> Map<U, Collection<T>> groupBy(Mapper<? super T, ? extends U> classifier);
+    <U> Map<U, Collection<T>> groupBy(Mapper<? extends U, ? super T> classifier);
 
-    <U, W> Map<U, W> reduceBy(Mapper<? super T, ? extends U> classifier,
+    <U, W> Map<U, W> reduceBy(Mapper<? extends U, ? super T> classifier,
                               Factory<W> baseFactory,
-                              Combiner<W, T, W> reducer);
+                              Combiner<W, W, T> reducer);
 
     T reduce(T base, BinaryOperator<T> op);
 
     Optional<T> reduce(BinaryOperator<T> op);
 
     <U> U fold(Factory<U> baseFactory,
-               Combiner<U, T, U> reducer,
+               Combiner<U, U, T> reducer,
                BinaryOperator<U> combiner);
 
     boolean anyMatch(Predicate<? super T> predicate);
--- a/src/share/classes/java/util/streams/ValuePipeline.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ValuePipeline.java	Mon Nov 05 15:21:49 2012 +0100
@@ -60,12 +60,12 @@
     }
 
     @Override
-    public <R> Stream<R> map(Mapper<? super U, ? extends R> mapper) {
+    public <R> Stream<R> map(Mapper<? extends R, ? super U> mapper) {
         return chainValue(new MapOp<>(mapper));
     }
 
     @Override
-    public <R> Stream<R> flatMap(FlatMapper<? super U, R> mapper) {
+    public <R> Stream<R> flatMap(FlatMapper<? extends R, ? super U> mapper) {
         return chainValue(new FlatMapOp<>(mapper));
     }
 
@@ -116,14 +116,14 @@
     }
 
     @Override
-    public <K> Map<K,Collection<U>> groupBy(Mapper<? super U, ? extends K> classifier) {
+    public <K> Map<K,Collection<U>> groupBy(Mapper<? extends K, ? super U> classifier) {
         return pipeline(new GroupByOp<>(classifier));
     }
 
     @Override
-    public <K, W> Map<K, W> reduceBy(Mapper<? super U, ? extends K> classifier,
+    public <K, W> Map<K, W> reduceBy(Mapper<? extends K, ? super U> classifier,
                                      Factory<W> baseFactory,
-                                     Combiner<W, U, W> reducer) {
+                                     Combiner<W, W, U> reducer) {
         return pipeline(new ReduceByOp<>(classifier, baseFactory, reducer));
     }
 
@@ -173,7 +173,7 @@
     }
 
     @Override
-    public <V> V fold(Factory<V> baseFactory, Combiner<V, U, V> reducer, BinaryOperator<V> combiner) {
+    public <V> V fold(Factory<V> baseFactory, Combiner<V, V, U> reducer, BinaryOperator<V> combiner) {
         return pipeline(new FoldOp<>(baseFactory, reducer, combiner));
     }
 }
--- a/src/share/classes/java/util/streams/ops/FlatMapOp.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ops/FlatMapOp.java	Mon Nov 05 15:21:49 2012 +0100
@@ -39,9 +39,9 @@
  * @author Brian Goetz
  */
 public class FlatMapOp<T,R> implements IntermediateOp<T, R> {
-    public final FlatMapper<? super T, R> mapper;
+    public final FlatMapper<? extends R, ? super T> mapper;
 
-    public FlatMapOp(FlatMapper<? super T, R> mapper) {
+    public FlatMapOp(FlatMapper<? extends R, ? super T> mapper) {
         Objects.requireNonNull(mapper);
         this.mapper = mapper;
     }
@@ -67,7 +67,7 @@
         };
     }
 
-    public static<T, R> Iterator<R> iterator(final Iterator<T> iterator, final FlatMapper<? super T, R> mapper) {
+    public static<T, R> Iterator<R> iterator(final Iterator<T> iterator, final FlatMapper<? extends R, ? super T> mapper) {
         return new Iterator<R>() {
             final Iterator<? extends T> source = iterator;
             // @@@ Replace with spined list implementation
--- a/src/share/classes/java/util/streams/ops/FoldOp.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ops/FoldOp.java	Mon Nov 05 15:21:49 2012 +0100
@@ -37,16 +37,16 @@
  */
 public class FoldOp<T, U> implements TerminalOp<T, U> {
     private final Factory<U> seedFactory;
-    private final Combiner<U, T, U> reducer;
+    private final Combiner<U, U, T> reducer;
     private final BinaryOperator<U> combiner;
 
-    public FoldOp(Factory<U> factory, Combiner<U, T, U> reducer, BinaryOperator<U> combiner) {
+    public FoldOp(Factory<U> factory, Combiner<U, U, T> reducer, BinaryOperator<U> combiner) {
         this.seedFactory = factory;
         this.reducer = reducer;
         this.combiner = combiner;
     }
 
-    public FoldOp(U seed, Combiner<U, T, U> reducer, BinaryOperator<U> combiner) {
+    public FoldOp(U seed, Combiner<U, U, T> reducer, BinaryOperator<U> combiner) {
         this(()->seed, reducer, combiner);
     }
 
--- a/src/share/classes/java/util/streams/ops/GroupByOp.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ops/GroupByOp.java	Mon Nov 05 15:21:49 2012 +0100
@@ -42,15 +42,15 @@
 //     of data when list needs to be re-sized
 public class GroupByOp<T, K> implements TerminalOp<T, Map<K, Collection<T>>> {
 
-    private final Mapper<? super T, ? extends K> mapper;
+    private final Mapper<? extends K, ? super T> mapper;
 
     private final Factory<Collection<T>> valueFactory;
 
-    public GroupByOp(Mapper<? super T, ? extends K> mapper) {
+    public GroupByOp(Mapper<? extends K, ? super T> mapper) {
         this(mapper, ArrayList::new);
     }
 
-    public GroupByOp(Mapper<? super T, ? extends K> mapper, Factory<Collection<T>> valueFactory) {
+    public GroupByOp(Mapper<? extends K, ? super T> mapper, Factory<Collection<T>> valueFactory) {
         this.mapper = mapper;
         this.valueFactory = valueFactory;
     }
--- a/src/share/classes/java/util/streams/ops/MapOp.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ops/MapOp.java	Mon Nov 05 15:21:49 2012 +0100
@@ -36,9 +36,9 @@
  * @author Brian Goetz
  */
 public class MapOp<T, R> implements IntermediateOp<T, R> {
-    public final Mapper<? super T, ? extends R> mapper;
+    public final Mapper<? extends R, ? super T> mapper;
 
-    public MapOp(Mapper<? super T, ? extends R> mapper) {
+    public MapOp(Mapper<? extends R, ? super T> mapper) {
         this.mapper = Objects.requireNonNull(mapper);
     }
 
@@ -62,7 +62,7 @@
         };
     }
 
-    public static<T, R> Iterator<R> iterator(final Iterator<T> source, final Mapper<? super T, ? extends R> mapper) {
+    public static<T, R> Iterator<R> iterator(final Iterator<T> source, final Mapper<? extends R, ? super T> mapper) {
         Objects.requireNonNull(source);
         Objects.requireNonNull(mapper);
         return new Iterator<R>() {
--- a/src/share/classes/java/util/streams/ops/MatchOp.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ops/MatchOp.java	Mon Nov 05 15:21:49 2012 +0100
@@ -41,10 +41,10 @@
  */
 public class MatchOp<T> implements TerminalOp<T, Boolean> {
     private final MatchKind matchKind;
-    private final Mapper<Iterator<? extends T>, Boolean> impl;
+    private final Mapper<Boolean, Iterator<? extends T>> impl;
     private final StreamShape inputShape;
 
-    private MatchOp(MatchKind matchKind, Mapper<Iterator<? extends T>, Boolean> impl, StreamShape shape) {
+    private MatchOp(MatchKind matchKind, Mapper<Boolean, Iterator<? extends T>> impl, StreamShape shape) {
         this.matchKind = matchKind;
         this.impl = impl;
         inputShape = shape;
--- a/src/share/classes/java/util/streams/ops/ReduceByOp.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/src/share/classes/java/util/streams/ops/ReduceByOp.java	Mon Nov 05 15:21:49 2012 +0100
@@ -38,13 +38,13 @@
  * @author Brian Goetz
  */
 public class ReduceByOp<T, U, W> implements TerminalOp<T,Map<U,W>> {
-    private final Mapper<? super T, ? extends U> classifier;
+    private final Mapper<? extends U, ? super T> classifier;
     private Factory<W> seedFactory;
-    private Combiner<W, T, W> reducer;
+    private Combiner<W, W, T> reducer;
 
-    public ReduceByOp(Mapper<? super T, ? extends U> classifier,
+    public ReduceByOp(Mapper<? extends U, ? super T> classifier,
                       Factory<W> seedFactory,
-                      Combiner<W, T, W> reducer) {
+                      Combiner<W, W, T> reducer) {
         this.classifier = classifier;
         this.seedFactory = seedFactory;
         this.reducer = reducer;
--- a/test-ng/tests/org/openjdk/tests/java/util/ComparatorsTest.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/ComparatorsTest.java	Mon Nov 05 15:21:49 2012 +0100
@@ -130,7 +130,7 @@
         Thing[] things = new Thing[doubleValues.length];
         for (int i=0; i<doubleValues.length; i++)
             things[i] = new Thing(0, 0L, 0.0, stringValues[i]);
-        Comparator<Thing> comp = Comparators.comparing(new Mapper<Thing, String>() {
+        Comparator<Thing> comp = Comparators.comparing(new Mapper<String, Thing>() {
             @Override
             public String map(Thing thing) {
                 return thing.getStringField();
--- a/test-ng/tests/org/openjdk/tests/java/util/LambdaTestHelpers.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/LambdaTestHelpers.java	Mon Nov 05 15:21:49 2012 +0100
@@ -72,7 +72,7 @@
     public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
     public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
 
-    public static final FlatMapper<String, Character> flattenChars = new FlatMapper<String, Character>() {
+    public static final FlatMapper<Character, String> flattenChars = new FlatMapper<Character, String>() {
         @Override
         public void flatMapInto(Block<? super Character> sink, String element) {
             for (int i=0; i<element.length(); i++) {
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/MappersTest.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/functions/MappersTest.java	Mon Nov 05 15:21:49 2012 +0100
@@ -77,7 +77,7 @@
 
     @Test
     public void testForPredicate() {
-        Mapper<Integer, String> mapper = Mappers.<Integer, String>forPredicate(x -> x != 0, "true", "false");
+        Mapper<String, Integer> mapper = Mappers.<String, Integer>forPredicate(x -> x != 0, "true", "false");
 
         assertEquals("false", mapper.map(0));
         assertEquals("true", mapper.map(1));
@@ -89,7 +89,7 @@
         truths.put(0, "sky");
         truths.put(1, "ice");
 
-        Mapper<Integer, String> mapper = Mappers.<Integer, String>forMap(truths);
+        Mapper<String, Integer> mapper = Mappers.<String, Integer>forMap(truths);
 
         assertEquals("sky", mapper.map(0));
         assertEquals("ice", mapper.map(1));
@@ -102,7 +102,7 @@
         truths.put(0, "sky");
         truths.put(1, "ice");
 
-        Mapper<Integer, String> mapper = Mappers.<Integer, String>forMap(truths, "fire");
+        Mapper<String, Integer> mapper = Mappers.<String, Integer>forMap(truths, "fire");
 
         assertEquals("sky", mapper.map(0));
         assertEquals("ice", mapper.map(1));
@@ -112,9 +112,9 @@
 
     @Test
     public void testChain() {
-        Mapper<Integer, Boolean> first = Mappers.<Integer, Boolean>forPredicate(x -> x != 0, true, false);
-        Mapper<Boolean, String> second = Mappers.<Boolean, String>forPredicate(x -> !x, "false", "true");
-        Mapper<Integer, String> mapper = Mappers.chain(first, second);
+        Mapper<Boolean, Integer> first = Mappers.<Boolean, Integer>forPredicate(x -> x != 0, true, false);
+        Mapper<String, Boolean> second = Mappers.<String, Boolean>forPredicate(x -> !x, "false", "true");
+        Mapper<String, Integer> mapper = Mappers.chain(first, second);
 
         assertEquals("false", mapper.map(0));
         assertEquals("true", mapper.map(1));
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestDataProvider.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestDataProvider.java	Mon Nov 05 15:21:49 2012 +0100
@@ -30,7 +30,6 @@
 
 import java.util.*;
 import java.util.functions.Combiner;
-import java.util.functions.Mapper;
 
 /**
  * StreamTestDataProvider
@@ -99,11 +98,11 @@
         testData = list.toArray(new Object[0][]);
     }
 
-    static <T> Object[] e(String description, T[] data, Combiner<String, T[], StreamOpTestCase.TestData<T>> m) {
+    static <T> Object[] e(String description, T[] data, Combiner<StreamOpTestCase.TestData<T>, String, T[]> m) {
         return new Object[] { description, m.combine(description, data) };
     }
 
-    static <T> Object[] e(String description, Collection<T> data, Combiner<String, Collection<T>, StreamOpTestCase.TestData<T>> m) {
+    static <T> Object[] e(String description, Collection<T> data, Combiner<StreamOpTestCase.TestData<T>, String, Collection<T>> m) {
         return new Object[] { description, m.combine(description, data) };
     }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/GroupByOpTest.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/GroupByOpTest.java	Mon Nov 05 15:21:49 2012 +0100
@@ -78,10 +78,10 @@
     }
 
     static class MapperData<T, K> {
-        Mapper<T, K> m;
+        Mapper<K, T> m;
         int expectedSize;
 
-        MapperData(Mapper<T, K> m, int expectedSize) {
+        MapperData(Mapper<K, T> m, int expectedSize) {
             this.m = m;
             this.expectedSize = expectedSize;
         }
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeBuilderTest.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeBuilderTest.java	Mon Nov 05 15:21:49 2012 +0100
@@ -54,7 +54,7 @@
             ls.add(countTo(size));
         }
 
-        List<Mapper<Integer, NodeBuilder<Integer>>> ms = Arrays.<Mapper<Integer, NodeBuilder<Integer>>>asList(
+        List<Mapper<NodeBuilder<Integer>, Integer>> ms = Arrays.<Mapper<NodeBuilder<Integer>, Integer>>asList(
                 s -> Nodes.makeVariableSizeBuilder(),
                 s -> Nodes.makeBuilder(s)
         );
@@ -62,7 +62,7 @@
         Object[][] params = new Object[ls.size() * ms.size()][];
         int i = 0;
         for (List<Integer> l : ls) {
-            for (Mapper<Integer, NodeBuilder<Integer>> m : ms) {
+            for (Mapper<NodeBuilder<Integer>, Integer> m : ms) {
                 params[i++] = new Object[]{l, m};
             }
         }
@@ -71,7 +71,7 @@
     }
 
     @Test(dataProvider = "sizes")
-    public void testIteration(List<Integer> l, Mapper<Integer, NodeBuilder<Integer>> m) {
+    public void testIteration(List<Integer> l, Mapper<NodeBuilder<Integer>, Integer> m) {
         NodeBuilder<Integer> nb = m.map(l.size());
         nb.begin(l.size());
         for (int i : l) {
@@ -101,7 +101,7 @@
     }
 
     @Test(dataProvider = "sizes")
-    public void testUpdate(List<Integer> l, Mapper<Integer, NodeBuilder<Integer>> m) {
+    public void testUpdate(List<Integer> l, Mapper<NodeBuilder<Integer>, Integer> m) {
         NodeBuilder<Integer> nb = m.map(l.size());
         nb.begin(l.size());
         for (int i : l) {
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeTest.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeTest.java	Mon Nov 05 15:21:49 2012 +0100
@@ -97,7 +97,7 @@
         }
     }
 
-    Node<Integer> tree(List<Integer> l, Mapper<List<Integer>, Node<Integer>> m) {
+    Node<Integer> tree(List<Integer> l, Mapper<Node<Integer>, List<Integer>> m) {
         if (l.size() < 3) {
             return m.map(l);
         }
--- a/test-ng/tests/org/openjdk/tests/javac/MethodReferenceTestInstanceMethod.java	Mon Nov 05 15:05:16 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/javac/MethodReferenceTestInstanceMethod.java	Mon Nov 05 15:21:49 2012 +0100
@@ -43,7 +43,7 @@
     }
 
     class Thingy<T,U> {
-        U blah(Mapper<T,U> m, T val) {
+        U blah(Mapper<U, T> m, T val) {
 	    return m.map(val);
         }
     }