changeset 7570:f0063d6f7bfd

- Transform MatchOp into a factory class MatchOps. TODO: merge Supplier of Sink into MatchOp since the Sink captures variables, thus creating one thing instead of two. - Transform FindOp into a factory class FindOps. Note: the method expressions passed to the FindOp constructor are non-capturing so are constants.
author psandoz
date Thu, 07 Mar 2013 10:47:08 +0100
parents 1fc04d7d379f
children 93d85abe032b
files src/share/classes/java/util/stream/DoublePipeline.java src/share/classes/java/util/stream/FindOp.java src/share/classes/java/util/stream/FindOps.java src/share/classes/java/util/stream/ForEachOps.java src/share/classes/java/util/stream/IntPipeline.java src/share/classes/java/util/stream/LongPipeline.java src/share/classes/java/util/stream/MatchOp.java src/share/classes/java/util/stream/MatchOps.java src/share/classes/java/util/stream/ReduceOps.java src/share/classes/java/util/stream/ReferencePipeline.java
diffstat 10 files changed, 666 insertions(+), 616 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/DoublePipeline.java	Wed Mar 06 19:20:58 2013 -0800
+++ b/src/share/classes/java/util/stream/DoublePipeline.java	Thu Mar 07 10:47:08 2013 +0100
@@ -317,27 +317,27 @@
 
     @Override
     public boolean anyMatch(DoublePredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ANY));
+        return pipeline(MatchOps.makeDouble(predicate, MatchOps.MatchKind.ANY));
     }
 
     @Override
     public boolean allMatch(DoublePredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ALL));
+        return pipeline(MatchOps.makeDouble(predicate, MatchOps.MatchKind.ALL));
     }
 
     @Override
     public boolean noneMatch(DoublePredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.NONE));
+        return pipeline(MatchOps.makeDouble(predicate, MatchOps.MatchKind.NONE));
     }
 
     @Override
     public OptionalDouble findFirst() {
-        return pipeline(FindOp.makeDouble(true));
+        return pipeline(FindOps.makeDouble(true));
     }
 
     @Override
     public OptionalDouble findAny() {
-        return pipeline(FindOp.makeDouble(false));
+        return pipeline(FindOps.makeDouble(false));
     }
 
     @Override
--- a/src/share/classes/java/util/stream/FindOp.java	Wed Mar 06 19:20:58 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.*;
-import java.util.concurrent.CountedCompleter;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-/**
- * A short-circuiting {@code TerminalOp} that searches for an element in a
- * stream pipeline, and terminates when it finds one.  Implements both
- * find-first (find the first element in the encounter order) and find-any (find
- * any element, may not be the first in encounter order.)
- *
- * @param <T> The output type of the stream pipeline
- * @param <O> The result type of the find operation, typically an optional type
- * @since 1.8
- */
-final class FindOp<T, O> implements TerminalOp<T, O> {
-
-    /**
-     * Construct a {@code FindOp} for streams of objects
-     *
-     * @param mustFindFirst Whether the {@code FindOp} must produce the first
-     *        element in the encounter order
-     * @param <T> The type of elements of the stream
-     * @return A {@code FindOp} implementing the find operation
-     */
-    public static<T> FindOp<T, Optional<T>> makeRef(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.REFERENCE, Optional.empty(), Optional::isPresent, FindSink.OfRef::new);
-    }
-
-    /**
-     * Construct a {@code FindOp} for streams of ints
-     *
-     * @param mustFindFirst Whether the {@code FindOp} must produce the first
-     *        element in the encounter order
-     * @return A {@code FindOp} implementing the find operation
-     */
-    public static FindOp<Integer, OptionalInt> makeInt(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.INT_VALUE, OptionalInt.empty(), OptionalInt::isPresent, FindSink.OfInt::new);
-    }
-
-    /**
-     * Construct a {@code FindOp} for streams of longs
-     *
-     * @param mustFindFirst Whether the {@code FindOp} must produce the first
-     *        element in the encounter order
-     * @return A {@code FindOp} implementing the find operation
-     */
-    public static FindOp<Long, OptionalLong> makeLong(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.LONG_VALUE, OptionalLong.empty(), OptionalLong::isPresent, FindSink.OfLong::new);
-    }
-
-    /**
-     * Construct a {@code FindOp} for streams of doubles
-     *
-     * @param mustFindFirst Whether the {@code FindOp} must produce the first
-     *        element in the encounter order
-     * @return A {@code FindOp} implementing the find operation
-     */
-    public static FindOp<Double, OptionalDouble> makeDouble(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.DOUBLE_VALUE, OptionalDouble.empty(), OptionalDouble::isPresent, FindSink.OfDouble::new);
-    }
-
-    /**
-     * Implementation of @{code TerminalSink} that implements the find
-     * functionality, requesting cancellation when something has been found
-     *
-     * @param <T> The type of input element
-     * @param <O> The result type, typically an optional type
-     */
-    private static abstract class FindSink<T, O> implements TerminalSink<T, O> {
-        boolean hasValue;
-        T value;
-
-        FindSink() {} // Avoid creation of special accessor
-
-        @Override
-        public void accept(T value) {
-            if (!hasValue) {
-                hasValue = true;
-                this.value = value;
-            }
-        }
-
-        @Override
-        public boolean cancellationRequested() {
-            return hasValue;
-        }
-
-        /** Specialization of {@code FindSink} for reference streams */
-        static final class OfRef<T> extends FindSink<T, Optional<T>> {
-            @Override
-            public Optional<T> get() {
-                return hasValue ? Optional.of(value) : null;
-            }
-        }
-
-        /** Specialization of {@code FindSink} for int streams */
-        static final class OfInt extends FindSink<Integer, OptionalInt> implements Sink.OfInt {
-            @Override
-            public void accept(int value) {
-                // Boxing is OK here, since few values will actually flow into the sink
-                accept((Integer) value);
-            }
-
-            @Override
-            public OptionalInt get() {
-                return hasValue ? OptionalInt.of(value) : null;
-            }
-        }
-
-        /** Specialization of {@code FindSink} for long streams */
-        static final class OfLong extends FindSink<Long, OptionalLong> implements Sink.OfLong {
-            @Override
-            public void accept(long value) {
-                // Boxing is OK here, since few values will actually flow into the sink
-                accept((Long) value);
-            }
-
-            @Override
-            public OptionalLong get() {
-                return hasValue ? OptionalLong.of(value) : null;
-            }
-        }
-
-        /** Specialization of {@code FindSink} for double streams */
-        static final class OfDouble extends FindSink<Double, OptionalDouble> implements Sink.OfDouble {
-            @Override
-            public void accept(double value) {
-                // Boxing is OK here, since few values will actually flow into the sink
-                accept((Double) value);
-            }
-
-            @Override
-            public OptionalDouble get() {
-                return hasValue ? OptionalDouble.of(value) : null;
-            }
-        }
-    }
-
-    private final boolean mustFindFirst;
-    private final StreamShape shape;
-    private final O emptyValue;
-    private final Predicate<O> presentPredicate;
-    private final Supplier<TerminalSink<T, O>> sinkSupplier;
-
-    /**
-     * Construct a {@code FindOp}
-     *
-     * @param mustFindFirst If true, must find the first element in encounter
-     *        order, otherwise can find any element
-     * @param shape Stream shape of elements to search
-     * @param emptyValue Result value corresponding to "found nothing"
-     * @param presentPredicate {@code Predicate} on result value corresponding
-     *        to "found something"
-     * @param sinkSupplier Factory for a {@code TerminalSink} implementing the
-     *        matching functionality
-     */
-    private FindOp(boolean mustFindFirst,
-                   StreamShape shape,
-                   O emptyValue,
-                   Predicate<O> presentPredicate,
-                   Supplier<TerminalSink<T, O>> sinkSupplier) {
-        this.mustFindFirst = mustFindFirst;
-        this.shape = shape;
-        this.emptyValue = emptyValue;
-        this.presentPredicate = presentPredicate;
-        this.sinkSupplier = sinkSupplier;
-    }
-
-    @Override
-    public int getOpFlags() {
-        return StreamOpFlag.IS_SHORT_CIRCUIT | (mustFindFirst ? 0 : StreamOpFlag.NOT_ORDERED);
-    }
-
-    @Override
-    public StreamShape inputShape() {
-        return shape;
-    }
-
-    @Override
-    public <S> O evaluateSequential(PipelineHelper<S, T> helper) {
-        O result = helper.into(sinkSupplier.get(), helper.sourceSpliterator()).get();
-        return result != null ? result : emptyValue;
-    }
-
-    @Override
-    public <P_IN> O evaluateParallel(PipelineHelper<P_IN, T> helper) {
-        return new FindTask<>(helper, this).invoke();
-    }
-
-    /**
-     * {@code ForkJoinTask} implementing parallel short-circuiting search
-     * @param <S> Input element type to the stream pipeline
-     * @param <T> Output element type from the stream pipeline
-     * @param <O> Result type from the find operation
-     */
-    private static final class FindTask<S, T, O> extends AbstractShortCircuitTask<S, T, O, FindTask<S, T, O>> {
-        private final FindOp<T, O> op;
-
-        FindTask(PipelineHelper<S, T> helper, FindOp<T, O> op) {
-            super(helper);
-            this.op = op;
-        }
-
-        FindTask(FindTask<S, T, O> parent, Spliterator<S> spliterator) {
-            super(parent, spliterator);
-            this.op = parent.op;
-        }
-
-        @Override
-        protected FindTask<S, T, O> makeChild(Spliterator<S> spliterator) {
-            return new FindTask<>(this, spliterator);
-        }
-
-        @Override
-        protected O getEmptyResult() {
-            return op.emptyValue;
-        }
-
-        private void foundResult(O answer) {
-            if (isLeftmostNode())
-                shortCircuit(answer);
-            else
-                cancelLaterNodes();
-        }
-
-        @Override
-        protected O doLeaf() {
-            O result = helper.into(op.sinkSupplier.get(), spliterator).get();
-            if (!op.mustFindFirst) {
-                if (result != null)
-                    shortCircuit(result);
-                return null;
-            }
-            else {
-                if (result != null) {
-                    foundResult(result);
-                    return result;
-                }
-                else
-                    return null;
-            }
-        }
-
-        @Override
-        public void onCompletion(CountedCompleter<?> caller) {
-            if (op.mustFindFirst) {
-                for (FindTask<S, T, O> child = children; child != null; child = child.nextSibling) {
-                    O result = child.getLocalResult();
-                    if (result != null && op.presentPredicate.test(result)) {
-                        setLocalResult(result);
-                        foundResult(result);
-                        break;
-                    }
-                }
-            }
-            super.onCompletion(caller);
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/stream/FindOps.java	Thu Mar 07 10:47:08 2013 +0100
@@ -0,0 +1,304 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.*;
+import java.util.concurrent.CountedCompleter;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * A factory for creating instances of a short-circuiting {@code TerminalOp}
+ * that searches for an element in a stream pipeline, and terminates when it
+ * finds one.  The search supports find-first (find the first element in the
+ * encounter order) and find-any (find any element, may not be the first in
+ * encounter order.)
+ *
+ * @since 1.8
+ */
+final class FindOps {
+
+    private FindOps() { }
+
+    /**
+     * Construct a {@code TerminalOp} for streams of objects
+     *
+     * @param mustFindFirst Whether the {@code TerminalOp} must produce the
+     *        first element in the encounter order
+     * @param <T> The type of elements of the stream
+     * @return A {@code TerminalOp} implementing the find operation
+     */
+    public static<T> FindOp<T, Optional<T>> makeRef(boolean mustFindFirst) {
+        return new FindOp<>(mustFindFirst, StreamShape.REFERENCE, Optional.empty(),
+                            Optional::isPresent, FindSink.OfRef::new);
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for streams of ints
+     *
+     * @param mustFindFirst Whether the {@code TerminalOp} must produce the
+     *        first element in the encounter order
+     * @return A {@code TerminalOp} implementing the find operation
+     */
+    public static FindOp<Integer, OptionalInt> makeInt(boolean mustFindFirst) {
+        return new FindOp<>(mustFindFirst, StreamShape.INT_VALUE, OptionalInt.empty(),
+                            OptionalInt::isPresent, FindSink.OfInt::new);
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for streams of longs
+     *
+     * @param mustFindFirst Whether the {@code TerminalOp} must produce the
+     *        first element in the encounter order
+     * @return A {@code TerminalOp} implementing the find operation
+     */
+    public static FindOp<Long, OptionalLong> makeLong(boolean mustFindFirst) {
+        return new FindOp<>(mustFindFirst, StreamShape.LONG_VALUE, OptionalLong.empty(),
+                            OptionalLong::isPresent, FindSink.OfLong::new);
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for streams of doubles
+     *
+     * @param mustFindFirst Whether the {@code TerminalOp} must produce the
+     *        first element in the encounter order
+     * @return A {@code TerminalOp} implementing the find operation
+     */
+    public static FindOp<Double, OptionalDouble> makeDouble(boolean mustFindFirst) {
+        return new FindOp<>(mustFindFirst, StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
+                            OptionalDouble::isPresent, FindSink.OfDouble::new);
+    }
+
+    /**
+     * A short-circuiting {@code TerminalOp} that searches for an element in a
+     * stream pipeline, and terminates when it finds one.  Implements both
+     * find-first (find the first element in the encounter order) and find-any
+     * (find any element, may not be the first in encounter order.)
+     *
+     * @param <T> The output type of the stream pipeline
+     * @param <O> The result type of the find operation, typically an optional
+     *        type
+     */
+    private static final class FindOp<T, O> implements TerminalOp<T, O> {
+        private final StreamShape shape;
+        final boolean mustFindFirst;
+        final O emptyValue;
+        final Predicate<O> presentPredicate;
+        final Supplier<TerminalSink<T, O>> sinkSupplier;
+
+        /**
+         * Construct a {@code FindOp}
+         *
+         * @param mustFindFirst If true, must find the first element in
+         *        encounter order, otherwise can find any element
+         * @param shape Stream shape of elements to search
+         * @param emptyValue Result value corresponding to "found nothing"
+         * @param presentPredicate {@code Predicate} on result value
+         *        corresponding to "found something"
+         * @param sinkSupplier Factory for a {@code TerminalSink} implementing
+         *        the matching functionality
+         */
+        FindOp(boolean mustFindFirst,
+                       StreamShape shape,
+                       O emptyValue,
+                       Predicate<O> presentPredicate,
+                       Supplier<TerminalSink<T, O>> sinkSupplier) {
+            this.mustFindFirst = mustFindFirst;
+            this.shape = shape;
+            this.emptyValue = emptyValue;
+            this.presentPredicate = presentPredicate;
+            this.sinkSupplier = sinkSupplier;
+        }
+
+        @Override
+        public int getOpFlags() {
+            return StreamOpFlag.IS_SHORT_CIRCUIT | (mustFindFirst ? 0 : StreamOpFlag.NOT_ORDERED);
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return shape;
+        }
+
+        @Override
+        public <S> O evaluateSequential(PipelineHelper<S, T> helper) {
+            O result = helper.into(sinkSupplier.get(), helper.sourceSpliterator()).get();
+            return result != null ? result : emptyValue;
+        }
+
+        @Override
+        public <P_IN> O evaluateParallel(PipelineHelper<P_IN, T> helper) {
+            return new FindTask<>(helper, this).invoke();
+        }
+    }
+
+    /**
+     * Implementation of @{code TerminalSink} that implements the find
+     * functionality, requesting cancellation when something has been found
+     *
+     * @param <T> The type of input element
+     * @param <O> The result type, typically an optional type
+     */
+    private static abstract class FindSink<T, O> implements TerminalSink<T, O> {
+        boolean hasValue;
+        T value;
+
+        FindSink() {} // Avoid creation of special accessor
+
+        @Override
+        public void accept(T value) {
+            if (!hasValue) {
+                hasValue = true;
+                this.value = value;
+            }
+        }
+
+        @Override
+        public boolean cancellationRequested() {
+            return hasValue;
+        }
+
+        /** Specialization of {@code FindSink} for reference streams */
+        static final class OfRef<T> extends FindSink<T, Optional<T>> {
+            @Override
+            public Optional<T> get() {
+                return hasValue ? Optional.of(value) : null;
+            }
+        }
+
+        /** Specialization of {@code FindSink} for int streams */
+        static final class OfInt extends FindSink<Integer, OptionalInt> implements Sink.OfInt {
+            @Override
+            public void accept(int value) {
+                // Boxing is OK here, since few values will actually flow into the sink
+                accept((Integer) value);
+            }
+
+            @Override
+            public OptionalInt get() {
+                return hasValue ? OptionalInt.of(value) : null;
+            }
+        }
+
+        /** Specialization of {@code FindSink} for long streams */
+        static final class OfLong extends FindSink<Long, OptionalLong> implements Sink.OfLong {
+            @Override
+            public void accept(long value) {
+                // Boxing is OK here, since few values will actually flow into the sink
+                accept((Long) value);
+            }
+
+            @Override
+            public OptionalLong get() {
+                return hasValue ? OptionalLong.of(value) : null;
+            }
+        }
+
+        /** Specialization of {@code FindSink} for double streams */
+        static final class OfDouble extends FindSink<Double, OptionalDouble> implements Sink.OfDouble {
+            @Override
+            public void accept(double value) {
+                // Boxing is OK here, since few values will actually flow into the sink
+                accept((Double) value);
+            }
+
+            @Override
+            public OptionalDouble get() {
+                return hasValue ? OptionalDouble.of(value) : null;
+            }
+        }
+    }
+
+    /**
+     * {@code ForkJoinTask} implementing parallel short-circuiting search
+     * @param <S> Input element type to the stream pipeline
+     * @param <T> Output element type from the stream pipeline
+     * @param <O> Result type from the find operation
+     */
+    private static final class FindTask<S, T, O> extends AbstractShortCircuitTask<S, T, O, FindTask<S, T, O>> {
+        private final FindOp<T, O> op;
+
+        FindTask(PipelineHelper<S, T> helper, FindOp<T, O> op) {
+            super(helper);
+            this.op = op;
+        }
+
+        FindTask(FindTask<S, T, O> parent, Spliterator<S> spliterator) {
+            super(parent, spliterator);
+            this.op = parent.op;
+        }
+
+        @Override
+        protected FindTask<S, T, O> makeChild(Spliterator<S> spliterator) {
+            return new FindTask<>(this, spliterator);
+        }
+
+        @Override
+        protected O getEmptyResult() {
+            return op.emptyValue;
+        }
+
+        private void foundResult(O answer) {
+            if (isLeftmostNode())
+                shortCircuit(answer);
+            else
+                cancelLaterNodes();
+        }
+
+        @Override
+        protected O doLeaf() {
+            O result = helper.into(op.sinkSupplier.get(), spliterator).get();
+            if (!op.mustFindFirst) {
+                if (result != null)
+                    shortCircuit(result);
+                return null;
+            }
+            else {
+                if (result != null) {
+                    foundResult(result);
+                    return result;
+                }
+                else
+                    return null;
+            }
+        }
+
+        @Override
+        public void onCompletion(CountedCompleter<?> caller) {
+            if (op.mustFindFirst) {
+                for (FindTask<S, T, O> child = children; child != null; child = child.nextSibling) {
+                    O result = child.getLocalResult();
+                    if (result != null && op.presentPredicate.test(result)) {
+                        setLocalResult(result);
+                        foundResult(result);
+                        break;
+                    }
+                }
+            }
+            super.onCompletion(caller);
+        }
+    }
+}
+
--- a/src/share/classes/java/util/stream/ForEachOps.java	Wed Mar 06 19:20:58 2013 -0800
+++ b/src/share/classes/java/util/stream/ForEachOps.java	Thu Mar 07 10:47:08 2013 +0100
@@ -34,7 +34,7 @@
 import java.util.Objects;
 
 /**
- * A factory for the creating instances of {@code TerminalOp) that implement
+ * A factory for creating instances of {@code TerminalOp) that implement
  * {@code forEach} or {@code forEachUntil} traversal over elements of a stream.
  *
  * <p>{@code forEach} traverses all elements of a stream and sends those
--- a/src/share/classes/java/util/stream/IntPipeline.java	Wed Mar 06 19:20:58 2013 -0800
+++ b/src/share/classes/java/util/stream/IntPipeline.java	Thu Mar 07 10:47:08 2013 +0100
@@ -338,27 +338,27 @@
 
     @Override
     public boolean anyMatch(IntPredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ANY));
+        return pipeline(MatchOps.makeInt(predicate, MatchOps.MatchKind.ANY));
     }
 
     @Override
     public boolean allMatch(IntPredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ALL));
+        return pipeline(MatchOps.makeInt(predicate, MatchOps.MatchKind.ALL));
     }
 
     @Override
     public boolean noneMatch(IntPredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.NONE));
+        return pipeline(MatchOps.makeInt(predicate, MatchOps.MatchKind.NONE));
     }
 
     @Override
     public OptionalInt findFirst() {
-        return pipeline(FindOp.makeInt(true));
+        return pipeline(FindOps.makeInt(true));
     }
 
     @Override
     public OptionalInt findAny() {
-        return pipeline(FindOp.makeInt(false));
+        return pipeline(FindOps.makeInt(false));
     }
 
     @Override
--- a/src/share/classes/java/util/stream/LongPipeline.java	Wed Mar 06 19:20:58 2013 -0800
+++ b/src/share/classes/java/util/stream/LongPipeline.java	Thu Mar 07 10:47:08 2013 +0100
@@ -329,27 +329,27 @@
 
     @Override
     public boolean anyMatch(LongPredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ANY));
+        return pipeline(MatchOps.makeLong(predicate, MatchOps.MatchKind.ANY));
     }
 
     @Override
     public boolean allMatch(LongPredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ALL));
+        return pipeline(MatchOps.makeLong(predicate, MatchOps.MatchKind.ALL));
     }
 
     @Override
     public boolean noneMatch(LongPredicate predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.NONE));
+        return pipeline(MatchOps.makeLong(predicate, MatchOps.MatchKind.NONE));
     }
 
     @Override
     public OptionalLong findFirst() {
-        return pipeline(FindOp.makeLong(true));
+        return pipeline(FindOps.makeLong(true));
     }
 
     @Override
     public OptionalLong findAny() {
-        return pipeline(FindOp.makeLong(false));
+        return pipeline(FindOps.makeLong(false));
     }
 
     @Override
--- a/src/share/classes/java/util/stream/MatchOp.java	Wed Mar 06 19:20:58 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Spliterator;
-import java.util.function.DoublePredicate;
-import java.util.function.IntPredicate;
-import java.util.function.LongPredicate;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-/**
- * A short-circuiting {@code TerminalOp} that evaluates a predicate on the
- * elements of a stream pipeline and determines whether all, any, or none of the
- * elements match a given {@code Predicate}.
- *
- * @param <T> The output type of the stream pipeline
- * @since 1.8
- */
-final class MatchOp<T> implements TerminalOp<T, Boolean> {
-    private final StreamShape inputShape;
-    protected final MatchKind matchKind;
-    protected final Supplier<BooleanTerminalSink<T>> sinkSupplier;
-
-    /**
-     * Construct a {@code MatchOp}
-     *
-     * @param shape The output shape of the stream pipeline
-     * @param matchKind The kind of quantified match (all, any, none)
-     * @param sinkSupplier {@code Supplier} for a {@code Sink} of the
-     *        appropriate shape which implements the matching operation
-     */
-    private MatchOp(StreamShape shape, MatchKind matchKind, Supplier<BooleanTerminalSink<T>> sinkSupplier) {
-        this.inputShape = shape;
-        this.matchKind = matchKind;
-        this.sinkSupplier = sinkSupplier;
-    }
-
-    // Boolean specific terminal sink to avoid the boxing costs when returning results
-
-    /**
-     * Base class for match sink variants.  Subclasses implement the
-     * shape-specific functionality and implement {@code TerminalSink}.
-     *
-     * @param <T> The output type of the stream pipeline
-     */
-    private static abstract class BooleanTerminalSink<T> implements Sink<T> {
-        boolean stop;
-        boolean value;
-
-        BooleanTerminalSink(MatchKind matchKind) {
-            value = !matchKind.shortCircuitResult;
-        }
-
-        public boolean getAndClearState() {
-            return value;
-        }
-
-        @Override
-        public boolean cancellationRequested() {
-            return stop;
-        }
-    }
-
-    /**
-     * Construct a {@code MatchOp} for the given predicate and quantified match
-     * criteria
-     *
-     * @param predicate The {@code Predicate} to apply to stream elements
-     * @param matchKind The kind of quantified match (all, any, none)
-     * @param <T> The type of stream elements
-     * @return A {@code MatchOp} implementing the desired quantified match
-     *         criteria
-     */
-    public static <T> MatchOp<T> match(Predicate<? super T> predicate, MatchKind matchKind) {
-        class MatchSink extends BooleanTerminalSink<T> {
-            MatchSink() {
-                super(matchKind);
-            }
-
-            @Override
-            public void accept(T t) {
-                // @@@ assert !stop when SortedOp supports short-circuit on Sink.end
-                //     for sequential operations
-                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
-                    stop = true;
-                    value = matchKind.shortCircuitResult;
-                }
-            }
-        }
-
-        // @@@ Change to return MatchSink::new when compiler and runtime bugs are fixed
-        Supplier<BooleanTerminalSink<T>> s = new Supplier<BooleanTerminalSink<T>>() {
-            @Override
-            public BooleanTerminalSink<T> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.REFERENCE, matchKind, s);
-    }
-
-    /**
-     * Construct a {@code MatchOp} for the given predicate and quantified match
-     * criteria for an {@code IntStream}
-     *
-     * @param predicate The {@code Predicate} to apply to stream elements
-     * @param matchKind The kind of quantified match (all, any, none)
-     * @return A {@code MatchOp} implementing the desired quantified match
-     *         criteria
-     */
-    public static MatchOp<Integer> match(IntPredicate predicate, MatchKind matchKind) {
-        class MatchSink extends BooleanTerminalSink<Integer> implements Sink.OfInt {
-            MatchSink() {
-                super(matchKind);
-            }
-
-            @Override
-            public void accept(int t) {
-                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
-                    stop = true;
-                    value = matchKind.shortCircuitResult;
-                }
-            }
-        }
-
-        Supplier<BooleanTerminalSink<Integer>> s = new Supplier<BooleanTerminalSink<Integer>>() {
-            @Override
-            public BooleanTerminalSink<Integer> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.INT_VALUE, matchKind, s);
-    }
-
-    /**
-     * Construct a {@code MatchOp} for the given predicate and quantified match
-     * criteria for a {@code LongStream}
-     *
-     * @param predicate The {@code Predicate} to apply to stream elements
-     * @param matchKind The kind of quantified match (all, any, none)
-     * @return A {@code MatchOp} implementing the desired quantified match
-     *         criteria
-     */
-    public static MatchOp<Long> match(LongPredicate predicate, MatchKind matchKind) {
-        class MatchSink extends BooleanTerminalSink<Long> implements Sink.OfLong {
-
-            MatchSink() {
-                super(matchKind);
-            }
-
-            @Override
-            public void accept(long t) {
-                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
-                    stop = true;
-                    value = matchKind.shortCircuitResult;
-                }
-            }
-        }
-
-        Supplier<BooleanTerminalSink<Long>> s = new Supplier<BooleanTerminalSink<Long>>() {
-            @Override
-            public BooleanTerminalSink<Long> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, s);
-    }
-
-    /**
-     * Construct a {@code MatchOp} for the given predicate and quantified match
-     * criteria for a {@code DoubleStream}
-     *
-     * @param predicate The {@code Predicate} to apply to stream elements
-     * @param matchKind The kind of quantified match (all, any, none)
-     * @return A {@code MatchOp} implementing the desired quantified match
-     *         criteria
-     */
-    public static MatchOp<Double> match(DoublePredicate predicate, MatchKind matchKind) {
-        class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble {
-
-            MatchSink() {
-                super(matchKind);
-            }
-
-            @Override
-            public void accept(double t) {
-                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
-                    stop = true;
-                    value = matchKind.shortCircuitResult;
-                }
-            }
-        }
-
-        Supplier<BooleanTerminalSink<Double>> s = new Supplier<BooleanTerminalSink<Double>>() {
-            @Override
-            public BooleanTerminalSink<Double> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, s);
-    }
-
-    @Override
-    public int getOpFlags() {
-        return StreamOpFlag.IS_SHORT_CIRCUIT | StreamOpFlag.NOT_ORDERED;
-    }
-
-    @Override
-    public StreamShape inputShape() {
-        return inputShape;
-    }
-
-    @Override
-    public <S> Boolean evaluateSequential(PipelineHelper<S, T> helper) {
-        return helper.into(sinkSupplier.get(), helper.sourceSpliterator()).getAndClearState();
-    }
-
-    @Override
-    public <S> Boolean evaluateParallel(PipelineHelper<S, T> helper) {
-        // Approach for parallel implementation:
-        // - Decompose as per usual
-        // - run match on leaf chunks, call result "b"
-        // - if b == matchKind.shortCircuitOn, complete early and return b
-        // - else if we complete normally, return !shortCircuitOn
-
-        return new MatchTask<>(this, helper).invoke();
-    }
-
-    /**
-     * ForkJoinTask implementation to implement a parallel short-circuiting
-     * quantified match
-     *
-     * @param <S> The type of source elements for the pipeline
-     * @param <T> The type of output elements for the pipeline
-     */
-    private static class MatchTask<S, T> extends AbstractShortCircuitTask<S, T, Boolean, MatchTask<S, T>> {
-        private final MatchOp<T> op;
-
-        MatchTask(MatchOp<T> op, PipelineHelper<S, T> helper) {
-            super(helper);
-            this.op = op;
-        }
-
-        MatchTask(MatchTask<S, T> parent, Spliterator<S> spliterator) {
-            super(parent, spliterator);
-            this.op = parent.op;
-        }
-
-        @Override
-        protected MatchTask<S, T> makeChild(Spliterator<S> spliterator) {
-            return new MatchTask<>(this, spliterator);
-        }
-
-        @Override
-        protected Boolean doLeaf() {
-            boolean b = helper.into(op.sinkSupplier.get(), spliterator).getAndClearState();
-            if (b == op.matchKind.shortCircuitResult)
-                shortCircuit(b);
-            return null;
-        }
-
-        @Override
-        protected Boolean getEmptyResult() {
-            return !op.matchKind.shortCircuitResult;
-        }
-    }
-
-    /**
-     * Enum describing quantified match options -- all match, any match, none
-     * match
-     */
-    enum MatchKind {
-        /** Do all elements match the predicate? */
-        ANY(true, true),
-
-        /** Do any elements match the predicate? */
-        ALL(false, false),
-
-        /** Do no elements match the predicate? */
-        NONE(true, false);
-
-        private final boolean stopOnPredicateMatches;
-        private final boolean shortCircuitResult;
-
-        private MatchKind(boolean stopOnPredicateMatches, boolean shortCircuitResult) {
-            this.stopOnPredicateMatches = stopOnPredicateMatches;
-            this.shortCircuitResult = shortCircuitResult;
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/stream/MatchOps.java	Thu Mar 07 10:47:08 2013 +0100
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Objects;
+import java.util.Spliterator;
+import java.util.function.DoublePredicate;
+import java.util.function.IntPredicate;
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * A factory for creating instances of a short-circuiting {@code TerminalOp}
+ * that evaluates a predicate on the elements of a stream and determines whether
+ * all, any or none of those elements match the predicate.
+ *
+ * @since 1.8
+ */
+final class MatchOps {
+
+    private MatchOps() { }
+
+    /**
+     * Enum describing quantified match options -- all match, any match, none
+     * match
+     */
+    enum MatchKind {
+        /** Do all elements match the predicate? */
+        ANY(true, true),
+
+        /** Do any elements match the predicate? */
+        ALL(false, false),
+
+        /** Do no elements match the predicate? */
+        NONE(true, false);
+
+        private final boolean stopOnPredicateMatches;
+        private final boolean shortCircuitResult;
+
+        private MatchKind(boolean stopOnPredicateMatches, boolean shortCircuitResult) {
+            this.stopOnPredicateMatches = stopOnPredicateMatches;
+            this.shortCircuitResult = shortCircuitResult;
+        }
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for the given predicate and quantified
+     * match criteria
+     *
+     * @param predicate The {@code Predicate} to apply to stream elements
+     * @param matchKind The kind of quantified match (all, any, none)
+     * @param <T> The type of stream elements
+     * @return A {@code TerminalOp} implementing the desired quantified match
+     *         criteria
+     */
+    public static <T> TerminalOp<T, Boolean> makeRef(Predicate<? super T> predicate, MatchKind matchKind) {
+        Objects.requireNonNull(predicate);
+        Objects.requireNonNull(matchKind);
+        class MatchSink extends BooleanTerminalSink<T> {
+            MatchSink() {
+                super(matchKind);
+            }
+
+            @Override
+            public void accept(T t) {
+                // @@@ assert !stop when SortedOp supports short-circuit on Sink.end
+                //     for sequential operations
+                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
+                    stop = true;
+                    value = matchKind.shortCircuitResult;
+                }
+            }
+        }
+
+        // @@@ Change to return MatchSink::new when compiler and runtime bugs are fixed
+        Supplier<BooleanTerminalSink<T>> s = new Supplier<BooleanTerminalSink<T>>() {
+            @Override
+            public BooleanTerminalSink<T> get() {return new MatchSink();}
+        };
+        return new MatchOp<>(StreamShape.REFERENCE, matchKind, s);
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for the given predicate and quantified
+     * match criteria for an {@code IntStream}
+     *
+     * @param predicate The {@code Predicate} to apply to stream elements
+     * @param matchKind The kind of quantified match (all, any, none)
+     * @return A {@code TerminalOp} implementing the desired quantified match
+     *         criteria
+     */
+    public static TerminalOp<Integer, Boolean> makeInt(IntPredicate predicate, MatchKind matchKind) {
+        Objects.requireNonNull(predicate);
+        Objects.requireNonNull(matchKind);
+        class MatchSink extends BooleanTerminalSink<Integer> implements Sink.OfInt {
+            MatchSink() {
+                super(matchKind);
+            }
+
+            @Override
+            public void accept(int t) {
+                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
+                    stop = true;
+                    value = matchKind.shortCircuitResult;
+                }
+            }
+        }
+
+        Supplier<BooleanTerminalSink<Integer>> s = new Supplier<BooleanTerminalSink<Integer>>() {
+            @Override
+            public BooleanTerminalSink<Integer> get() {return new MatchSink();}
+        };
+        return new MatchOp<>(StreamShape.INT_VALUE, matchKind, s);
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for the given predicate and quantified
+     * match criteria for a {@code LongStream}
+     *
+     * @param predicate The {@code Predicate} to apply to stream elements
+     * @param matchKind The kind of quantified match (all, any, none)
+     * @return A {@code TerminalOp} implementing the desired quantified match
+     *         criteria
+     */
+    public static TerminalOp<Long, Boolean> makeLong(LongPredicate predicate, MatchKind matchKind) {
+        Objects.requireNonNull(predicate);
+        Objects.requireNonNull(matchKind);
+        class MatchSink extends BooleanTerminalSink<Long> implements Sink.OfLong {
+
+            MatchSink() {
+                super(matchKind);
+            }
+
+            @Override
+            public void accept(long t) {
+                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
+                    stop = true;
+                    value = matchKind.shortCircuitResult;
+                }
+            }
+        }
+
+        Supplier<BooleanTerminalSink<Long>> s = new Supplier<BooleanTerminalSink<Long>>() {
+            @Override
+            public BooleanTerminalSink<Long> get() {return new MatchSink();}
+        };
+        return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, s);
+    }
+
+    /**
+     * Construct a {@code TerminalOp} for the given predicate and quantified
+     * match criteria for a {@code DoubleStream}
+     *
+     * @param predicate The {@code Predicate} to apply to stream elements
+     * @param matchKind The kind of quantified match (all, any, none)
+     * @return A {@code TerminalOp} implementing the desired quantified match
+     *         criteria
+     */
+    public static TerminalOp<Double, Boolean> makeDouble(DoublePredicate predicate, MatchKind matchKind) {
+        Objects.requireNonNull(predicate);
+        Objects.requireNonNull(matchKind);
+        class MatchSink extends BooleanTerminalSink<Double> implements Sink.OfDouble {
+
+            MatchSink() {
+                super(matchKind);
+            }
+
+            @Override
+            public void accept(double t) {
+                if (!stop && predicate.test(t) == matchKind.stopOnPredicateMatches) {
+                    stop = true;
+                    value = matchKind.shortCircuitResult;
+                }
+            }
+        }
+
+        Supplier<BooleanTerminalSink<Double>> s = new Supplier<BooleanTerminalSink<Double>>() {
+            @Override
+            public BooleanTerminalSink<Double> get() {return new MatchSink();}
+        };
+        return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, s);
+    }
+
+    /**
+     * A short-circuiting {@code TerminalOp} that evaluates a predicate on the
+     * elements of a stream and determines whether all, any or none of those
+     * elements match the predicate.
+     *
+     * @param <T> The output type of the stream pipeline
+     */
+    private static final class MatchOp<T> implements TerminalOp<T, Boolean> {
+        private final StreamShape inputShape;
+        final MatchKind matchKind;
+        final Supplier<BooleanTerminalSink<T>> sinkSupplier;
+
+        /**
+         * Construct a {@code MatchOp}
+         *
+         * @param shape The output shape of the stream pipeline
+         * @param matchKind The kind of quantified match (all, any, none)
+         * @param sinkSupplier {@code Supplier} for a {@code Sink} of the
+         *        appropriate shape which implements the matching operation
+         */
+        MatchOp(StreamShape shape, MatchKind matchKind, Supplier<BooleanTerminalSink<T>> sinkSupplier) {
+            this.inputShape = shape;
+            this.matchKind = matchKind;
+            this.sinkSupplier = sinkSupplier;
+        }
+
+        @Override
+        public int getOpFlags() {
+            return StreamOpFlag.IS_SHORT_CIRCUIT | StreamOpFlag.NOT_ORDERED;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public <S> Boolean evaluateSequential(PipelineHelper<S, T> helper) {
+            return helper.into(sinkSupplier.get(), helper.sourceSpliterator()).getAndClearState();
+        }
+
+        @Override
+        public <S> Boolean evaluateParallel(PipelineHelper<S, T> helper) {
+            // Approach for parallel implementation:
+            // - Decompose as per usual
+            // - run match on leaf chunks, call result "b"
+            // - if b == matchKind.shortCircuitOn, complete early and return b
+            // - else if we complete normally, return !shortCircuitOn
+
+            return new MatchTask<>(this, helper).invoke();
+        }
+    }
+
+    /**
+     * Boolean specific terminal sink to avoid the boxing costs when returning
+     * results.  Subclasses implement the shape-specific functionality.
+     *
+     * @param <T> The output type of the stream pipeline
+     */
+    private static abstract class BooleanTerminalSink<T> implements Sink<T> {
+        boolean stop;
+        boolean value;
+
+        BooleanTerminalSink(MatchKind matchKind) {
+            value = !matchKind.shortCircuitResult;
+        }
+
+        public boolean getAndClearState() {
+            return value;
+        }
+
+        @Override
+        public boolean cancellationRequested() {
+            return stop;
+        }
+    }
+
+    /**
+     * ForkJoinTask implementation to implement a parallel short-circuiting
+     * quantified match
+     *
+     * @param <S> The type of source elements for the pipeline
+     * @param <T> The type of output elements for the pipeline
+     */
+    private static final class MatchTask<S, T> extends AbstractShortCircuitTask<S, T, Boolean, MatchTask<S, T>> {
+        private final MatchOp<T> op;
+
+        MatchTask(MatchOp<T> op, PipelineHelper<S, T> helper) {
+            super(helper);
+            this.op = op;
+        }
+
+        MatchTask(MatchTask<S, T> parent, Spliterator<S> spliterator) {
+            super(parent, spliterator);
+            this.op = parent.op;
+        }
+
+        @Override
+        protected MatchTask<S, T> makeChild(Spliterator<S> spliterator) {
+            return new MatchTask<>(this, spliterator);
+        }
+
+        @Override
+        protected Boolean doLeaf() {
+            boolean b = helper.into(op.sinkSupplier.get(), spliterator).getAndClearState();
+            if (b == op.matchKind.shortCircuitResult)
+                shortCircuit(b);
+            return null;
+        }
+
+        @Override
+        protected Boolean getEmptyResult() {
+            return !op.matchKind.shortCircuitResult;
+        }
+    }
+}
+
--- a/src/share/classes/java/util/stream/ReduceOps.java	Wed Mar 06 19:20:58 2013 -0800
+++ b/src/share/classes/java/util/stream/ReduceOps.java	Thu Mar 07 10:47:08 2013 +0100
@@ -24,6 +24,7 @@
  */
 package java.util.stream;
 
+import java.util.Objects;
 import java.util.Optional;
 import java.util.OptionalDouble;
 import java.util.OptionalInt;
@@ -66,6 +67,8 @@
      */
     public static<T, U> TerminalOp<T, U>
     makeRef(U seed, BiFunction<U, ? super T, U> reducer, BinaryOperator<U> combiner) {
+        Objects.requireNonNull(reducer);
+        Objects.requireNonNull(combiner);
         class ReducingSink extends Box<U> implements AccumulatingSink<T, U, ReducingSink> {
             @Override
             public void begin(long size) {
@@ -100,6 +103,7 @@
      */
     public static<T> TerminalOp<T, Optional<T>>
     makeRef(BinaryOperator<T> operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<T, Optional<T>, ReducingSink> {
             private boolean empty;
             private T state;
@@ -149,7 +153,7 @@
      */
     public static<T,R> TerminalOp<T, R>
     makeRef(Collector<? super T,R> collector) {
-        Supplier<R> supplier = collector.resultSupplier();
+        Supplier<R> supplier = Objects.requireNonNull(collector).resultSupplier();
         BiConsumer<R, ? super T> accumulator = collector.accumulator();
         BinaryOperator<R> combiner = collector.combiner();
         class ReducingSink extends Box<R> implements AccumulatingSink<T, R, ReducingSink> {
@@ -190,6 +194,9 @@
      */
     public static<T, R> TerminalOp<T, R>
     makeRef(Supplier<R> seedFactory, BiConsumer<R, ? super T> accumulator, BiConsumer<R,R> reducer) {
+        Objects.requireNonNull(seedFactory);
+        Objects.requireNonNull(accumulator);
+        Objects.requireNonNull(reducer);
         class ReducingSink extends Box<R> implements AccumulatingSink<T, R, ReducingSink> {
             @Override
             public void begin(long size) {
@@ -224,6 +231,7 @@
      */
     public static TerminalOp<Integer, Integer>
     makeInt(int identity, IntBinaryOperator operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<Integer, Integer, ReducingSink>, Sink.OfInt {
             private int state;
 
@@ -264,6 +272,7 @@
      */
     public static TerminalOp<Integer, OptionalInt>
     makeInt(IntBinaryOperator operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<Integer, OptionalInt, ReducingSink>, Sink.OfInt {
             private boolean empty;
             private int state;
@@ -313,7 +322,7 @@
      */
     public static <R> TerminalOp<Integer, R>
     makeInt(Collector.OfInt<R> collector) {
-        Supplier<R> supplier = collector.resultSupplier();
+        Supplier<R> supplier = Objects.requireNonNull(collector).resultSupplier();
         ObjIntConsumer<R> accumulator = collector.intAccumulator();
         BinaryOperator<R> combiner = collector.combiner();
         class ReducingSink extends Box<R> implements AccumulatingSink<Integer, R, ReducingSink>, Sink.OfInt {
@@ -350,6 +359,7 @@
      */
     public static TerminalOp<Long, Long>
     makeLong(long identity, LongBinaryOperator operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<Long, Long, ReducingSink>, Sink.OfLong {
             private long state;
 
@@ -390,6 +400,7 @@
      */
     public static TerminalOp<Long, OptionalLong>
     makeLong(LongBinaryOperator operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<Long, OptionalLong, ReducingSink>, Sink.OfLong {
             private boolean empty;
             private long state;
@@ -439,7 +450,7 @@
      */
     public static <R> TerminalOp<Long, R>
     makeLong(Collector.OfLong<R> collector) {
-        Supplier<R> supplier = collector.resultSupplier();
+        Supplier<R> supplier = Objects.requireNonNull(collector).resultSupplier();
         ObjLongConsumer<R> accumulator = collector.longAccumulator();
         BinaryOperator<R> combiner = collector.combiner();
         class ReducingSink extends Box<R> implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
@@ -476,6 +487,7 @@
      */
     public static TerminalOp<Double, Double>
     makeDouble(double identity, DoubleBinaryOperator operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<Double, Double, ReducingSink>, Sink.OfDouble {
             private double state;
 
@@ -516,6 +528,7 @@
      */
     public static TerminalOp<Double, OptionalDouble>
     makeDouble(DoubleBinaryOperator operator) {
+        Objects.requireNonNull(operator);
         class ReducingSink implements AccumulatingSink<Double, OptionalDouble, ReducingSink>, Sink.OfDouble {
             private boolean empty;
             private double state;
@@ -564,7 +577,7 @@
      * @return A {@code TerminalOp} implementing the reduction
      */
     public static <R> TerminalOp<Double, R> makeDouble(Collector.OfDouble<R> collector) {
-        Supplier<R> supplier = collector.resultSupplier();
+        Supplier<R> supplier = Objects.requireNonNull(collector).resultSupplier();
         ObjDoubleConsumer<R> accumulator = collector.doubleAccumulator();
         BinaryOperator<R> combiner = collector.combiner();
         class ReducingSink extends Box<R> implements AccumulatingSink<Double, R, ReducingSink>, Sink.OfDouble {
@@ -600,7 +613,7 @@
      * @param <R> The result type
      * @param <K> The type of the {@code AccumulatingSink}.
      */
-    private static interface AccumulatingSink<T, R, K extends AccumulatingSink<T, R, K>> extends TerminalSink<T, R> {
+    private interface AccumulatingSink<T, R, K extends AccumulatingSink<T, R, K>> extends TerminalSink<T, R> {
         public void combine(K other);
     }
 
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Wed Mar 06 19:20:58 2013 -0800
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Thu Mar 07 10:47:08 2013 +0100
@@ -334,27 +334,27 @@
 
     @Override
     public boolean anyMatch(Predicate<? super U> predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ANY));
+        return pipeline(MatchOps.makeRef(predicate, MatchOps.MatchKind.ANY));
     }
 
     @Override
     public boolean allMatch(Predicate<? super U> predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.ALL));
+        return pipeline(MatchOps.makeRef(predicate, MatchOps.MatchKind.ALL));
     }
 
     @Override
     public boolean noneMatch(Predicate<? super U> predicate) {
-        return pipeline(MatchOp.match(predicate, MatchOp.MatchKind.NONE));
+        return pipeline(MatchOps.makeRef(predicate, MatchOps.MatchKind.NONE));
     }
 
     @Override
     public Optional<U> findFirst() {
-        return pipeline(FindOp.makeRef(true));
+        return pipeline(FindOps.makeRef(true));
     }
 
     @Override
     public Optional<U> findAny() {
-        return pipeline(FindOp.makeRef(false));
+        return pipeline(FindOps.makeRef(false));
     }
 
     @Override