changeset 7047:52fcc7897ce1

Move Spliterator to java.util
author briangoetz
date Thu, 10 Jan 2013 18:40:41 -0500
parents eeba6d5aeaf8
children 46fff268b702
files src/share/classes/java/lang/CharSequence.java src/share/classes/java/util/Arrays.java src/share/classes/java/util/BitSet.java src/share/classes/java/util/Iterators.java src/share/classes/java/util/PrimitiveIterator.java src/share/classes/java/util/Spliterator.java src/share/classes/java/util/stream/AbstractPipeline.java src/share/classes/java/util/stream/AbstractSpliterator.java src/share/classes/java/util/stream/BaseStream.java src/share/classes/java/util/stream/IntPipeline.java src/share/classes/java/util/stream/IntStream.java src/share/classes/java/util/stream/NodeFactory.java src/share/classes/java/util/stream/PipelineHelper.java src/share/classes/java/util/stream/ReferencePipeline.java src/share/classes/java/util/stream/Spliterator.java src/share/classes/java/util/stream/StreamShape.java src/share/classes/java/util/stream/StreamShapeImpls.java src/share/classes/java/util/stream/Streams.java src/share/classes/java/util/stream/op/AbstractShortCircuitTask.java src/share/classes/java/util/stream/op/AbstractTask.java src/share/classes/java/util/stream/op/FindOp.java src/share/classes/java/util/stream/op/MatchOp.java src/share/classes/java/util/stream/op/Node.java src/share/classes/java/util/stream/op/NodeUtils.java src/share/classes/java/util/stream/op/Nodes.java src/share/classes/java/util/stream/op/OpUtils.java src/share/classes/java/util/stream/op/SpinedBuffer.java src/share/classes/java/util/stream/primitive/PrimitiveIterator.java src/share/classes/java/util/stream/primitive/PrimitiveNode.java src/share/classes/java/util/stream/primitive/PrimitiveSpliterator.java test-ng/tests/org/openjdk/tests/java/lang/CharSequenceStreamTest.java test-ng/tests/org/openjdk/tests/java/util/BitsetStreamTest.java test-ng/tests/org/openjdk/tests/java/util/stream/SpliteratorTest.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestData.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestDataProvider.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestScenario.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FindAnyOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FindFirstOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/SequentialOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/SortedOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/SpinedBufferTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ToArrayOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntSpliteratorTest.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamSpliteratorTest.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestData.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestDataProvider.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestScenario.java
diffstat 50 files changed, 555 insertions(+), 570 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/CharSequence.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/lang/CharSequence.java	Thu Jan 10 18:40:41 2013 -0500
@@ -28,7 +28,7 @@
 import java.util.NoSuchElementException;
 import java.util.function.IntBlock;
 import java.util.stream.*;
-import java.util.stream.primitive.PrimitiveIterator;
+import java.util.PrimitiveIterator;
 
 /**
  * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This
--- a/src/share/classes/java/util/Arrays.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/Arrays.java	Thu Jan 10 18:40:41 2013 -0500
@@ -29,7 +29,6 @@
 import java.util.concurrent.ForkJoinPool;
 import java.util.function.*;
 import java.util.stream.*;
-import java.util.stream.primitive.*;
 
 /**
  * This class contains various methods for manipulating arrays (such as
@@ -4570,7 +4569,7 @@
 
     private static class IntArraySpliterator
             extends AbstractArraySpliterator<Integer>
-            implements PrimitiveSpliterator.OfInt {
+            implements Spliterator.OfInt {
         private final int[] elements;
 
         private IntArraySpliterator(int[] elements, int offset, int length) {
@@ -4597,14 +4596,14 @@
         }
 
         @Override
-        public PrimitiveSpliterator.OfInt trySplit() {
+        public Spliterator.OfInt trySplit() {
             if (state != State.SPLITTING)
                 throw illegalState();
             int t = (endOffset - curOffset) / 2;
             if (t == 0)
                 return null;
             else {
-                PrimitiveSpliterator.OfInt ret = new IntArraySpliterator(elements, curOffset, t);
+                Spliterator.OfInt ret = new IntArraySpliterator(elements, curOffset, t);
                 curOffset += t;
                 return ret;
             }
@@ -4743,11 +4742,11 @@
         return new ArraySpliterator<>(array, offset, length);
     }
 
-    public static PrimitiveSpliterator<Integer> spliterator(int[] array) {
+    public static Spliterator.OfInt spliterator(int[] array) {
         return spliterator(array, 0, array.length);
     }
 
-    public static PrimitiveSpliterator<Integer> spliterator(int[] array, int offset, int length) {
+    public static Spliterator.OfInt spliterator(int[] array, int offset, int length) {
         return new IntArraySpliterator(array, offset, length);
     }
 
--- a/src/share/classes/java/util/BitSet.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/BitSet.java	Thu Jan 10 18:40:41 2013 -0500
@@ -32,7 +32,6 @@
 import java.util.stream.IntStream;
 import java.util.stream.StreamOpFlag;
 import java.util.stream.Streams;
-import java.util.stream.primitive.PrimitiveIterator;
 
 /**
  * This class implements a vector of bits that grows as needed. Each
--- a/src/share/classes/java/util/Iterators.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/Iterators.java	Thu Jan 10 18:40:41 2013 -0500
@@ -28,7 +28,6 @@
 import java.util.function.Predicate;
 import java.util.function.Function;
 import java.util.stream.AbstractSpliterator;
-import java.util.stream.Spliterator;
 
 /**
  * Utilities for Iterators.  All of these methods consume elements from the iterators passed to them!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/PrimitiveIterator.java	Thu Jan 10 18:40:41 2013 -0500
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+import java.util.function.Block;
+import java.util.function.IntBlock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An iterator over a source of primitive values.  This is the base type for
+ * primitive specializations of {@link Iterator}.
+ */
+public interface PrimitiveIterator<E> extends Iterator<E> {
+
+    default int nextInt() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    void forEach(Block<? super E> block);
+
+    default void forEach(IntBlock block) {
+        throw new UnsupportedOperationException();
+    }
+
+    interface OfInt extends PrimitiveIterator<Integer> {
+
+        @Override
+        default Integer next() {
+            Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in next()", getClass().getName());
+            return nextInt();
+        }
+
+        @Override
+        int nextInt();
+
+        @Override
+        default void forEach(Block<? super Integer> sink) {
+            if (sink instanceof IntBlock) {
+                forEach((IntBlock) sink);
+            }
+            else {
+                Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in forEach()", getClass().getName());
+                while (hasNext()) {
+                    sink.accept(nextInt());
+                }
+            }
+        }
+
+        @Override
+        default void forEach(IntBlock block) {
+            while (hasNext())
+                block.accept(nextInt());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/Spliterator.java	Thu Jan 10 18:40:41 2013 -0500
@@ -0,0 +1,270 @@
+/*
+ * 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;
+
+import java.util.function.Block;
+import java.util.function.IntBlock;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Provides the ability to decompose an aggregate data structure and to iterate
+ * over the elements the elements of the aggregate.
+ * <p/>
+ * Use of a Spliterator has two phases; splitting and traversal. The splitting
+ * phase divides the elements of the data structures so that they may be
+ * processed concurrently. The split phase is intended to be repeated
+ * recursively until the number of elements per split reaches a threshold where
+ * further splitting would only generate additional cost.  Most methods of
+ * {@code Spliterator} are applicable primarily to one phase or the other.
+ * <p/>
+ * The traversal phase allows you to obtain access to the elements of the current
+ * split, and begins on first call to the {@link #tryAdvance(java.util.function.Block)}
+ * or {@link #forEach(java.util.function.Block)} methods.
+ * <p/>
+ * @author Brian Goetz
+ * @author Doug Lea
+ */
+public interface Spliterator<T> {
+    /**
+     * If the source can be split further, return a new {@code Spliterator}
+     * covering some portion of the elements, guaranteed
+     * not to overlap with those retained by this {@code Spliterator}. After invoking
+     * this method, the current {@code Spliterator} will <em>not</em> cover the elements
+     * of the returned {@code Spliterator}.  If the element source cannot be split further,
+     * return null.  Repeated calls to {@code #trySplit} on finite streams must
+     * eventually return null.
+     *
+     * <p>This method may throw an {@link IllegalStateException} if
+     * traversal has already commenced. <p/>
+     *
+     * @return a {@code Spliterator} covering some portion of the
+     * elements, or null if the source cannot be split further.
+     * <p/>
+     * @throws IllegalStateException if traversal has already commenced.
+     */
+    Spliterator<T> trySplit();
+
+    /**
+     * Create an {@link Iterator} view of this {@code Spliterator}, backed by calling the
+     * {@link #tryAdvance(java.util.function.Block)} method on the {@code Spliterator}.
+     * Calling methods on this {@code Iterator} may cause the traversal phase of the {@code Spliterator}
+     * to commence.
+     *
+     * @return an  {@code Iterator} view of this {@code Spliterator}
+     */
+    default Iterator<T> iterator() {
+        class Adapter implements Iterator<T>, Block<T> {
+            boolean valueReady = false;
+            T nextElement;
+
+            @Override
+            public void accept(T t) {
+                valueReady = true;
+                nextElement = t;
+            }
+
+            @Override
+            public boolean hasNext() {
+                if (!valueReady)
+                    tryAdvance(this);
+                return valueReady;
+            }
+
+            @Override
+            public T next() {
+                if (!valueReady && !hasNext())
+                    throw new NoSuchElementException();
+                else {
+                    valueReady = false;
+                    return nextElement;
+                }
+            }
+        }
+
+        return new Adapter();
+    }
+
+    /**
+     *
+     * @param block
+     * @return
+     */
+    boolean tryAdvance(Block<? super T> block);
+
+    /**
+     * Perform the given action for all remaining elements.  This method initiates
+     * the traversal phase.
+     *
+     * @param block The action which will be performed for each element
+     */
+    void forEach(Block<? super T> block);
+
+    /**
+     * Returns the number of elements that would be encountered by
+     * traversal, or returns -1 if unknown or if computing this value may
+     * itself require traversal or significant computation.
+     *
+     * The default implementation behaves as if:
+     *
+     *     return hasExactSize() ? estimateSize() : -1;
+     *
+     * Implementations generally need not override this method.
+     *
+     * @return The number of remaining elements or {@code -1} if the remaining
+     * element count is unavailable.
+     */
+    default long exactSizeIfKnown() {
+        return hasExactSize() ? estimateSize() : -1;
+    }
+
+    /**
+     * Returns an estimate of the number of elements that would be
+     * encountered by traversal, or returns -1 if unknown, or if
+     * computing this value may itself require traversal or
+     * significant computation.  The result of calling
+     * this method during the traversal phase is unspecified.  If the method
+     * {@link #hasExactSize()} returns true, then this method must return
+     * the exact size or -1.
+     *
+     * <p>For example, a sub-spliterator of an approximately balanced
+     * tree may return a value that estimates the number of elements
+     * to be half of that of its parent.
+     *
+     * @return An estimate of the number of remaining elements, or
+     * {@code -1} if an estimate is unavailable.
+     */
+    default long estimateSize() {
+        return exactSizeIfKnown();
+    }
+
+    /**
+     * Return {@code true} if the {@link #estimateSize} method of this
+     * {@code Spliterator} and all of its descendent {@code Spliterator}s
+     * return exact non-negative results.  The result of calling this method
+     * during the traversal phase is unspecified.
+     *
+     * @return {@code true} if exact size information is available for this
+     * {@code Spliterator} and all its descendents.
+     */
+    boolean hasExactSplits();
+
+    /**
+     * Returns {@code true} if the {@link #estimateSize()} method always returns
+     * an exact value.  The result of calling this method during the traversal phase
+     * is unspecified.
+     */
+    default boolean hasExactSize() {
+        return hasExactSplits();
+    }
+
+    /**
+     * Specialization for primitive types.
+     */
+    interface OfPrimitive<E> extends Spliterator<E> {
+        @Override
+        OfPrimitive<E> trySplit();
+
+        @Override
+        PrimitiveIterator<E> iterator();
+
+        default boolean tryAdvance(IntBlock block) {
+            throw new UnsupportedOperationException(getClass().toString());
+        }
+
+        void forEach(IntBlock block);
+    }
+
+    /**
+     * Specialization for int.
+     */
+    public interface OfInt extends OfPrimitive<Integer> {
+        /**
+         * Create a {@link PrimitiveIterator} view of this spliterator
+         * @return
+         */
+        @Override
+        default PrimitiveIterator<Integer> iterator() {
+            class Adapter implements PrimitiveIterator.OfInt, IntBlock {
+                boolean valueReady = false;
+                int nextValue;
+
+                @Override
+                public void accept(int value) {
+                    valueReady = true;
+                    nextValue = value;
+                }
+
+                @Override
+                public boolean hasNext() {
+                    if (!valueReady)
+                        tryAdvance(this);
+                    return valueReady;
+                }
+
+                @Override
+                public int nextInt() {
+                    if (!valueReady && !hasNext())
+                        throw new NoSuchElementException();
+                    else {
+                        valueReady = false;
+                        return nextValue;
+                    }
+                }
+            }
+
+            return new Adapter();
+        }
+
+        boolean tryAdvance(IntBlock block);
+
+        @Override
+        default void forEach(IntBlock block) {
+            while (tryAdvance(block)) { }
+        }
+
+        @Override
+        default boolean tryAdvance(Block<? super Integer> block) {
+            if (block instanceof IntBlock) {
+                return tryAdvance((IntBlock) block);
+            }
+            else {
+                Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in forEach", getClass().getName());
+                return tryAdvance((IntBlock) block::accept);
+            }
+        }
+
+        @Override
+        default void forEach(Block<? super Integer> sink) {
+            if (sink instanceof IntBlock) {
+                forEach((IntBlock) sink);
+            }
+            else {
+                Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in forEach", getClass().getName());
+                forEach((IntBlock) sink::accept);
+            }
+        }
+    }
+}
--- a/src/share/classes/java/util/stream/AbstractPipeline.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/AbstractPipeline.java	Thu Jan 10 18:40:41 2013 -0500
@@ -30,7 +30,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.stream.op.*;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 /**
  * The abstract pipeline implementation from which concrete implementations extend from.
@@ -501,7 +500,7 @@
 
     @Override
     public Iterator<E_OUT> iterator() {
-        return spliterator().asIterator();
+        return spliterator().iterator();
     }
 
     @Override
@@ -523,9 +522,9 @@
     }
 
     @SuppressWarnings("unchecked")
-    public static <E> PrimitiveSpliterator<E> adapt(final Spliterator<E> i) {
-        if (i instanceof PrimitiveSpliterator) {
-            return (PrimitiveSpliterator<E>) i;
+    public static <E> Spliterator.OfPrimitive<E> adapt(final Spliterator<E> i) {
+        if (i instanceof Spliterator.OfPrimitive) {
+            return (Spliterator.OfPrimitive<E>) i;
         }
         else {
             Logger.getLogger(StreamShapeImpls.class.getName()).log(Level.WARNING, "Using Primitives.adapt(Splterator)");
--- a/src/share/classes/java/util/stream/AbstractSpliterator.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/AbstractSpliterator.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,6 +24,8 @@
  */
 package java.util.stream;
 
+import java.util.Spliterator;
+
 /**
  * AbstractSpliterator
  *
--- a/src/share/classes/java/util/stream/BaseStream.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/BaseStream.java	Thu Jan 10 18:40:41 2013 -0500
@@ -25,6 +25,7 @@
 package java.util.stream;
 
 import java.util.Iterator;
+import java.util.Spliterator;
 
 /**
  * BaseStream
--- a/src/share/classes/java/util/stream/IntPipeline.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/IntPipeline.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,8 +24,7 @@
  */
 package java.util.stream;
 
-import java.util.Objects;
-import java.util.OptionalInt;
+import java.util.*;
 import java.util.function.*;
 import java.util.stream.op.*;
 import java.util.stream.primitive.*;
@@ -53,7 +52,7 @@
     }
 
     @Override
-    public PrimitiveSpliterator<Integer> spliterator() {
+    public Spliterator.OfPrimitive<Integer> spliterator() {
         return adapt(super.spliterator());
     }
 
--- a/src/share/classes/java/util/stream/IntStream.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/IntStream.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,11 +24,8 @@
  */
 package java.util.stream;
 
+import java.util.*;
 import java.util.function.*;
-import java.util.OptionalDouble;
-import java.util.OptionalInt;
-import java.util.stream.primitive.PrimitiveIterator;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 public interface IntStream extends BaseStream<Integer> {
 
@@ -38,7 +35,7 @@
     PrimitiveIterator<Integer> iterator();
 
     @Override
-    PrimitiveSpliterator<Integer> spliterator();
+    Spliterator.OfPrimitive<Integer> spliterator();
 
     // @@@ Do the following make sense?
     // map to long or double stream?
--- a/src/share/classes/java/util/stream/NodeFactory.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/NodeFactory.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,8 +24,8 @@
  */
 package java.util.stream;
 
-import java.util.Iterator;
 import java.util.List;
+import java.util.Spliterator;
 import java.util.function.ObjIntFunction;
 import java.util.stream.op.Node;
 
--- a/src/share/classes/java/util/stream/PipelineHelper.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/PipelineHelper.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,6 +24,7 @@
  */
 package java.util.stream;
 
+import java.util.Spliterator;
 import java.util.function.ObjIntFunction;
 import java.util.stream.op.Node;
 
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Thu Jan 10 18:40:41 2013 -0500
@@ -25,6 +25,7 @@
 package java.util.stream;
 
 import java.util.Objects;
+import java.util.Spliterator;
 import java.util.function.*;
 import java.util.Comparator;
 import java.util.Optional;
--- a/src/share/classes/java/util/stream/Spliterator.java	Thu Jan 10 15:39:08 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +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.Iterator;
-import java.util.NoSuchElementException;
-import java.util.function.Block;
-import java.util.function.Supplier;
-
-/**
- * Provides the ability to decompose an aggregate data structure and to iterate
- * over the elements the elements of the aggregate.
- * <p/>
- * Use of a Spliterator has two phases; splitting and traversal. The splitting
- * phase divides the elements of the data structures so that they may be
- * processed concurrently. The split phase is intended to be repeated
- * recursively until the number of elements per split reaches a threshold where
- * further splitting would only generate additional cost.  Most methods of
- * {@code Spliterator} are applicable primarily to one phase or the other.
- * <p/>
- * The traversal phase allows you to obtain access to the elements of the current
- * split, and begins on first call to the {@code iterator()} or {@code forEach()}
- * methods.
- * <p/>
- * @author Brian Goetz
- * @author Doug Lea
- */
-public interface Spliterator<T> {
-    /**
-     * If the element source can be split further, return a
-     * spliterator covering some portion of the elements, guaranteed
-     * not to overlap with those retained by this Spliterator. After invoking
-     * this method, the current Spliterator will <em>not</em> cover the elements
-     * of the returned Spliterator.  If the element source cannot be split further,
-     * return null.  Repeated calls to {@code #trySplit} on finite streams must
-     * eventually return null.
-     *
-     * <p>This method may throw an {@link IllegalStateException} if a
-     * traversal has already commenced. <p/>
-     *
-     * @return a Spliterator covering some portion of the
-     * elements, or null if the source cannot be split further.
-     * <p/>
-     * @throws IllegalStateException if traversal has already commenced.
-     */
-    Spliterator<T> trySplit();
-
-    /**
-     * Create an {@link Iterator} view of this spliterator
-     * @return
-     */
-    default Iterator<T> asIterator() {
-        class Adapter implements Iterator<T>, Block<T> {
-            boolean valueReady = false;
-            T nextElement;
-
-            @Override
-            public void accept(T t) {
-                valueReady = true;
-                nextElement = t;
-            }
-
-            @Override
-            public boolean hasNext() {
-                if (!valueReady)
-                    tryAdvance(this);
-                return valueReady;
-            }
-
-            @Override
-            public T next() {
-                if (!valueReady && !hasNext())
-                    throw new NoSuchElementException();
-                else {
-                    valueReady = false;
-                    return nextElement;
-                }
-            }
-        }
-
-        return new Adapter();
-    }
-
-    boolean tryAdvance(Block<? super T> block);
-
-    /**
-     * Perform the given action for all remaining elements.  This method initiates
-     * the traversal phase.
-     *
-     * @param block The action which will be performed for each element
-     */
-    void forEach(Block<? super T> block);
-
-    /**
-     * Returns the number of elements that would be encountered by
-     * traversal, or returns a
-     * negative value if unknown, or if computing this value may
-     * itself require traversal or significant computation.  The result of
-     * calling this method during the traversal phase is unspecified.
-     *
-     * @return The number of remaining elements or {@code -1} if the remaining
-     * element count is unavailable.
-     */
-    default long exactSizeIfKnown() {
-        return hasExactSize() ? estimateSize() : -1;
-    }
-
-    /**
-     * Returns an estimate of the number of elements that would be
-     * encountered by traversal, or returns a negative value if unknown, or if
-     * computing this value may itself require traversal or
-     * significant computation.  The result of calling
-     * this method during the traversal phase is unspecified.
-     *
-     * <p>For example, a sub-spliterator of an approximately balanced
-     * tree may return a value that estimates the number of elements
-     * to be half of that of its parent.
-     *
-     * @return An estimate of the number of remaining elements, or
-     * {@code -1} if an estimate is unavailable.
-     */
-    default long estimateSize() {
-        return exactSizeIfKnown();
-    }
-
-    /**
-     * Return {@code true} if the {@link #exactSizeIfKnown} method of this
-     * {@code Spliterator} and all of its descendent {@code Spliterator}s
-     * return non-negative results.  The result of calling this method during the
-     * traversal phase is unspecified.
-     *
-     * @return {@code true} if size information is available for this
-     * {@code Spliterator} and all its descendents.
-     */
-    boolean hasExactSplits();
-
-    default boolean hasExactSize() {
-        return hasExactSplits();
-    }
-
-    class ValueHolder<T> implements Block<T>, Supplier<T> {
-        private T value;
-
-        @Override
-        public void accept(T t) {
-            this.value = t;
-        }
-
-        @Override
-        public T get() {
-            return value;
-        }
-    }
-}
--- a/src/share/classes/java/util/stream/StreamShape.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/StreamShape.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,6 +24,7 @@
  */
 package java.util.stream;
 
+import java.util.Spliterator;
 import java.util.function.Supplier;
 import java.util.stream.op.IntermediateOp;
 import java.util.stream.op.Node;
--- a/src/share/classes/java/util/stream/StreamShapeImpls.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/StreamShapeImpls.java	Thu Jan 10 18:40:41 2013 -0500
@@ -143,14 +143,14 @@
 
         @Override
         public void forEachWithCancel(Spliterator spliterator, Sink sink) {
-            PrimitiveSpliterator<Integer> spl = AbstractPipeline.adapt(spliterator);
+            Spliterator.OfPrimitive<Integer> spl = AbstractPipeline.adapt(spliterator);
             while (!sink.cancellationRequested() && spl.tryAdvance(sink)) { }
         }
 
         @Override
-        public<P_IN,P_OUT> PrimitiveSpliterator<P_OUT> wrap(PipelineHelper<P_IN, P_OUT> ph,
+        public<P_IN,P_OUT> Spliterator.OfPrimitive<P_OUT> wrap(PipelineHelper<P_IN, P_OUT> ph,
                                                             Spliterator<P_IN> spliterator) {
-            return (PrimitiveSpliterator<P_OUT>) new IntWrappingSpliterator<>((PipelineHelper<P_IN,Integer>) ph,
+            return (Spliterator.OfPrimitive<P_OUT>) new IntWrappingSpliterator<>((PipelineHelper<P_IN,Integer>) ph,
                                                                               spliterator, ph.isParallel());
         }
 
@@ -170,7 +170,7 @@
         public Node<Integer> truncateToNode(long size, Spliterator<Integer> spliterator, long skip, long targetSize, ObjIntFunction<Integer[]> generator) {
             PrimitiveNode.Builder<Integer> nodeBuilder = Nodes.makeIntBuilder(size);
             nodeBuilder.begin(size);
-            PrimitiveSpliterator<Integer> adapted = AbstractPipeline.adapt(spliterator);
+            Spliterator.OfPrimitive<Integer> adapted = AbstractPipeline.adapt(spliterator);
             for (int i = 0; i < skip && adapted.tryAdvance((IntBlock) e -> { }); i++) { }
             for (int i = 0; ((targetSize == -1) || (i < targetSize)) && adapted.tryAdvance(nodeBuilder); i++)  { }
             nodeBuilder.end();
@@ -313,7 +313,7 @@
 
     private static class IntWrappingSpliterator<P_IN>
             extends AbstractWrappingSpliterator<P_IN, Integer, SpinedBuffer.OfInt>
-            implements PrimitiveSpliterator.OfInt {
+            implements Spliterator.OfInt {
 
         IntWrappingSpliterator(PipelineHelper<P_IN, Integer> ph, Spliterator<P_IN> spliterator, boolean parallel) {
             super(ph, spliterator, parallel);
@@ -333,8 +333,8 @@
         }
 
         @Override
-        public PrimitiveSpliterator<Integer> trySplit() {
-            return (PrimitiveSpliterator<Integer>) super.trySplit();
+        public OfPrimitive<Integer> trySplit() {
+            return (OfPrimitive<Integer>) super.trySplit();
         }
 
         @Override
--- a/src/share/classes/java/util/stream/Streams.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/Streams.java	Thu Jan 10 18:40:41 2013 -0500
@@ -26,8 +26,7 @@
 
 import java.util.*;
 import java.util.function.*;
-import java.util.stream.primitive.PrimitiveIterator;
-import java.util.stream.primitive.PrimitiveSpliterator;
+import java.util.PrimitiveIterator;
 
 /**
  * Streams
@@ -72,19 +71,19 @@
         return intStream(Streams.<Integer>emptyPrimitiveSpliterator(), 0);
     }
 
-    public static<T> IntStream intStream(Supplier<? extends PrimitiveSpliterator<Integer>> source, int flags) {
+    public static<T> IntStream intStream(Supplier<? extends Spliterator.OfPrimitive<Integer>> source, int flags) {
         return new IntPipeline<>(source, flags & ~StreamOpFlag.IS_PARALLEL);
     }
 
-    public static<T> IntStream intParallelStream(Supplier<? extends PrimitiveSpliterator<Integer>> source, int flags) {
+    public static<T> IntStream intParallelStream(Supplier<? extends Spliterator.OfPrimitive<Integer>> source, int flags) {
         return new IntPipeline<>(source, flags | StreamOpFlag.IS_PARALLEL);
     }
 
-    public static<T> IntStream intStream(PrimitiveSpliterator<Integer> source, int flags) {
+    public static<T> IntStream intStream(Spliterator.OfPrimitive<Integer> source, int flags) {
         return new IntPipeline<>(() -> source, flags & ~StreamOpFlag.IS_PARALLEL);
     }
 
-    public static<T> IntStream intParallelStream(PrimitiveSpliterator<Integer> source, int flags) {
+    public static<T> IntStream intParallelStream(Spliterator.OfPrimitive<Integer> source, int flags) {
         return new IntPipeline<>(() -> source, flags | StreamOpFlag.IS_PARALLEL);
     }
 
@@ -94,8 +93,8 @@
         return new EmptySpliterator<>();
     }
 
-    public static <E> PrimitiveSpliterator<E> emptyPrimitiveSpliterator() {
-        return new EmptySpliterator.OfPrimitive<>();
+    public static <E> Spliterator.OfPrimitive<E> emptyPrimitiveSpliterator() {
+        return new EmptySpliterator.OfPrimitive();
     }
 
     @SuppressWarnings("unchecked")
@@ -113,18 +112,18 @@
         return Iterators.spliterator(iterator, -1);
     }
 
-    public static PrimitiveSpliterator<Integer> intSpliteratorUnknownSize(PrimitiveIterator<Integer> iterator) {
+    public static Spliterator.OfInt intSpliteratorUnknownSize(PrimitiveIterator<Integer> iterator) {
         return intSpliterator(iterator, -1);
     }
 
-    public static PrimitiveSpliterator.OfInt intSpliterator(PrimitiveIterator<Integer> iterator, final long sizeIfKnown) {
-        class Splitr extends AbstractSpliterator<Integer> implements PrimitiveSpliterator.OfInt {
+    public static Spliterator.OfInt intSpliterator(PrimitiveIterator<Integer> iterator, final long sizeIfKnown) {
+        class Splitr extends AbstractSpliterator<Integer> implements Spliterator.OfInt {
             private static final int MAX_ITERATOR_CHUNK_SIZE = 1024;
             int nextSize = 1;
             long sizeLeft = sizeIfKnown;
 
             @Override
-            public PrimitiveSpliterator<Integer> trySplit() {
+            public Spliterator.OfInt trySplit() {
                 if (state != State.SPLITTING)
                     throw illegalState();
                 else if (!iterator.hasNext())
@@ -222,7 +221,7 @@
     }
 
     public static IntStream intRange(final int from, final int upTo, final int step) {
-        PrimitiveSpliterator.OfInt s = new RangeIntSpliterator(from, upTo, step);
+        Spliterator.OfInt s = new RangeIntSpliterator(from, upTo, step);
         return intStream(s, StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED);
     }
 
@@ -333,8 +332,8 @@
             cSize = Math.min(aSpliterator.exactSizeIfKnown(), bSpliterator.exactSizeIfKnown());
         }
 
-        Iterator<A> aIterator = aSpliterator.asIterator();
-        Iterator<B> bIterator = bSpliterator.asIterator();
+        Iterator<A> aIterator = aSpliterator.iterator();
+        Iterator<B> bIterator = bSpliterator.iterator();
         Iterator<C> cIterator = new Iterator<C>() {
             @Override
             public boolean hasNext() {
@@ -366,7 +365,7 @@
     }
 
     private static class RangeIntSpliterator extends AbstractSpliterator<Integer>
-            implements PrimitiveSpliterator.OfInt {
+            implements Spliterator.OfInt {
         private int from;
         private final int upTo;
         private final int step;
@@ -408,7 +407,7 @@
         }
 
         @Override
-        public PrimitiveSpliterator<Integer> trySplit() {
+        public Spliterator.OfInt trySplit() {
             if (state != State.SPLITTING)
                 throw illegalState();
 
@@ -497,15 +496,15 @@
             return true;
         }
 
-        private static class OfPrimitive<T> extends EmptySpliterator<T> implements PrimitiveSpliterator<T> {
+        private static class OfPrimitive<T> extends EmptySpliterator<T> implements Spliterator.OfPrimitive<T> {
             @Override
             @SuppressWarnings("unchecked")
-            public PrimitiveSpliterator<T> trySplit() {
+            public Spliterator.OfPrimitive<T> trySplit() {
                 return null;
             }
 
             @Override
-            public PrimitiveIterator<T> asIterator() {
+            public PrimitiveIterator<T> iterator() {
                 return emptyPrimitiveIterator();
             }
 
--- a/src/share/classes/java/util/stream/op/AbstractShortCircuitTask.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/AbstractShortCircuitTask.java	Thu Jan 10 18:40:41 2013 -0500
@@ -26,7 +26,7 @@
 
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.PipelineHelper;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 
 /**
  * Abstract class for fork-join tasks used to implement short-circuiting
--- a/src/share/classes/java/util/stream/op/AbstractTask.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/AbstractTask.java	Thu Jan 10 18:40:41 2013 -0500
@@ -27,7 +27,7 @@
 import java.util.concurrent.CountedCompleter;
 import java.util.concurrent.ForkJoinPool;
 import java.util.stream.PipelineHelper;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 
 /**
  * Abstract base class for most fork-join tasks used to implement stream ops.
--- a/src/share/classes/java/util/stream/op/FindOp.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/FindOp.java	Thu Jan 10 18:40:41 2013 -0500
@@ -25,10 +25,12 @@
 package java.util.stream.op;
 
 import java.util.Optional;
+import java.util.OptionalInt;
 import java.util.concurrent.CountedCompleter;
-import java.util.stream.*;
-import java.util.OptionalInt;
-import java.util.stream.primitive.PrimitiveSpliterator;
+import java.util.stream.AbstractPipeline;
+import java.util.stream.PipelineHelper;
+import java.util.Spliterator;
+import java.util.stream.StreamShape;
 
 public abstract class FindOp<T, O> implements TerminalOp<T, O> {
     public static final class OfReference<T> extends FindOp<T, Optional<T>> {
@@ -52,7 +54,7 @@
 
         @Override
         protected Optional<T> find(Spliterator<T> spliterator) {
-            Spliterator.ValueHolder<T> vh = new Spliterator.ValueHolder<>();
+            OpUtils.ValueHolder<T> vh = new OpUtils.ValueHolder<>();
             if (spliterator.tryAdvance(vh))
                 return Optional.of(vh.get());
             return null;
@@ -85,7 +87,7 @@
 
         @Override
         protected OptionalInt find(Spliterator<Integer> spliterator) {
-            PrimitiveSpliterator.ValueHolder.OfInt vh = new PrimitiveSpliterator.ValueHolder.OfInt();
+            OpUtils.PrimitiveValueHolder.OfInt vh = new OpUtils.PrimitiveValueHolder.OfInt();
             if (AbstractPipeline.adapt(spliterator).tryAdvance(vh))
                 return OptionalInt.of(vh.getAsInt());
             return null;
--- a/src/share/classes/java/util/stream/op/MatchOp.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/MatchOp.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,12 +24,12 @@
  */
 package java.util.stream.op;
 
+import java.util.Spliterator;
 import java.util.function.Block;
 import java.util.function.IntBlock;
 import java.util.function.IntPredicate;
 import java.util.function.Predicate;
 import java.util.stream.*;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 /**
  * MatchOp
@@ -99,7 +99,7 @@
                         stop = true;
                 }
             }
-            PrimitiveSpliterator<Integer> intIterator = AbstractPipeline.adapt(spliterator);
+            Spliterator.OfPrimitive<Integer> intIterator = AbstractPipeline.adapt(spliterator);
             Matcher m = new Matcher();
             while (intIterator.tryAdvance(m)) {
                 if (m.stop)
--- a/src/share/classes/java/util/stream/op/Node.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/Node.java	Thu Jan 10 18:40:41 2013 -0500
@@ -27,7 +27,7 @@
 import java.util.Iterator;
 import java.util.function.ObjIntFunction;
 import java.util.stream.Sink;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 
 /**
  * An immutable container of elements.
@@ -45,7 +45,7 @@
 
     @Override
     default Iterator<T> iterator() {
-        return spliterator().asIterator();
+        return spliterator().iterator();
     }
 
     /**
--- a/src/share/classes/java/util/stream/op/NodeUtils.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/NodeUtils.java	Thu Jan 10 18:40:41 2013 -0500
@@ -28,7 +28,7 @@
 import java.util.concurrent.CountedCompleter;
 import java.util.function.ObjIntFunction;
 import java.util.stream.PipelineHelper;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.Streams;
 import java.util.stream.primitive.PrimitiveNode;
 
--- a/src/share/classes/java/util/stream/op/Nodes.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/Nodes.java	Thu Jan 10 18:40:41 2013 -0500
@@ -30,7 +30,6 @@
 import java.util.function.ObjIntFunction;
 import java.util.stream.*;
 import java.util.stream.primitive.PrimitiveNode;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 import static java.util.stream.Collectors.toStringJoiner;
 
@@ -494,15 +493,15 @@
             // @@@ Push down forEach(Block)
         }
 
-        private static class OfInt extends InternalNodeSpliterator<Integer, PrimitiveSpliterator<Integer>>
-                implements PrimitiveSpliterator.OfInt {
+        private static class OfInt extends InternalNodeSpliterator<Integer, OfPrimitive<Integer>>
+                implements Spliterator.OfInt {
 
             public OfInt(PrimitiveNode<Integer> cur) {
                 super(cur);
             }
 
             @Override
-            protected PrimitiveSpliterator<Integer> spliterator(Node<Integer> node) {
+            protected Spliterator.OfPrimitive<Integer> spliterator(Node<Integer> node) {
                 return ((PrimitiveNode<Integer>) node).spliterator();
             }
 
@@ -643,7 +642,7 @@
     private static final PrimitiveNode<?> EMPTY_PRIMITIVE_NODE = new PrimitiveNode<Object>() {
 
         @Override
-        public PrimitiveSpliterator<Object> spliterator() {
+        public Spliterator.OfPrimitive<Object> spliterator() {
             return Streams.emptyPrimitiveSpliterator();
         }
 
@@ -711,7 +710,7 @@
         //
 
         @Override
-        public abstract PrimitiveSpliterator<E> spliterator();
+        public abstract Spliterator.OfPrimitive<E> spliterator();
 
         @Override
         public abstract int[] asIntArray();
@@ -740,7 +739,7 @@
         // Node
 
         @Override
-        public PrimitiveSpliterator<Integer> spliterator() {
+        public Spliterator.OfPrimitive<Integer> spliterator() {
             return Arrays.spliterator(array, 0, curSize);
         }
 
@@ -795,7 +794,7 @@
         }
 
         @Override
-        public PrimitiveSpliterator<Integer> spliterator() {
+        public Spliterator.OfPrimitive<Integer> spliterator() {
             return new InternalNodeSpliterator.OfInt(this);
         }
 
@@ -882,7 +881,7 @@
         }
 
         @Override
-        public PrimitiveSpliterator.OfInt spliterator() {
+        public Spliterator.OfInt spliterator() {
             assert !building : "during building";
             return super.spliterator();
         }
--- a/src/share/classes/java/util/stream/op/OpUtils.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/OpUtils.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,7 +24,11 @@
  */
 package java.util.stream.op;
 
+import java.util.Spliterator;
 import java.util.concurrent.CountedCompleter;
+import java.util.function.Block;
+import java.util.function.IntBlock;
+import java.util.function.IntSupplier;
 import java.util.function.Supplier;
 import java.util.stream.*;
 
@@ -164,4 +168,32 @@
             }
         }
     }
+
+    public static class ValueHolder<T> implements Block<T>, Supplier<T> {
+        private T value;
+
+        @Override
+        public void accept(T t) {
+            this.value = t;
+        }
+
+        @Override
+        public T get() {
+            return value;
+        }
+    }
+
+    public static class PrimitiveValueHolder {
+        public static class OfInt implements IntBlock, IntSupplier {
+            private int value;
+
+            public int getAsInt() {
+                return value;
+            }
+
+            public void accept(int value) {
+                this.value = value;
+            }
+        }
+    }
 }
--- a/src/share/classes/java/util/stream/op/SpinedBuffer.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/op/SpinedBuffer.java	Thu Jan 10 18:40:41 2013 -0500
@@ -31,8 +31,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.stream.*;
-import java.util.stream.primitive.PrimitiveIterator;
-import java.util.stream.primitive.PrimitiveSpliterator;
+import java.util.PrimitiveIterator;
 
 /**
  * An ordered collection of elements.
@@ -212,7 +211,7 @@
     // Iterable
 
     public Iterator<E> iterator() {
-        return spliterator().asIterator();
+        return spliterator().iterator();
     }
 
     public void forEach(Block<? super E> block) {
@@ -690,14 +689,14 @@
 
         @Override
         public PrimitiveIterator<Integer> iterator() {
-            return spliterator().asIterator();
+            return spliterator().iterator();
         }
 
         private class Splitr
-                extends BaseSpliterator<PrimitiveSpliterator<Integer>>
-                implements PrimitiveSpliterator.OfInt {
+                extends BaseSpliterator<Spliterator.OfPrimitive<Integer>>
+                implements Spliterator.OfInt {
             @Override
-            PrimitiveSpliterator<Integer> arraySpliterator(int[] array, int offset, int len) {
+            Spliterator.OfPrimitive<Integer> arraySpliterator(int[] array, int offset, int len) {
                 return Arrays.spliterator(array, offset, len);
             }
 
@@ -711,7 +710,7 @@
 
         }
 
-        public PrimitiveSpliterator.OfInt spliterator() {
+        public Spliterator.OfInt spliterator() {
             return new Splitr();
         }
 
--- a/src/share/classes/java/util/stream/primitive/PrimitiveIterator.java	Thu Jan 10 15:39:08 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +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.primitive;
-
-import java.util.Iterator;
-import java.util.function.Block;
-import java.util.function.IntBlock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public interface PrimitiveIterator<E> extends Iterator<E> {
-
-    default int nextInt() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    void forEach(Block<? super E> block);
-
-    default void forEach(IntBlock block) {
-        throw new UnsupportedOperationException();
-    }
-
-    //
-
-    interface OfInt extends PrimitiveIterator<Integer> {
-
-        @Override
-        default Integer next() {
-            Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in next()", getClass().getName());
-            return nextInt();
-        }
-
-        @Override
-        int nextInt();
-
-        @Override
-        default void forEach(Block<? super Integer> sink) {
-            if (sink instanceof IntBlock) {
-                forEach((IntBlock) sink);
-            }
-            else {
-                Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in forEach()", getClass().getName());
-                while (hasNext()) {
-                    sink.accept(nextInt());
-                }
-            }
-        }
-
-        @Override
-        default void forEach(IntBlock block) {
-            while (hasNext())
-                block.accept(nextInt());
-        }
-    }
-}
--- a/src/share/classes/java/util/stream/primitive/PrimitiveNode.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/src/share/classes/java/util/stream/primitive/PrimitiveNode.java	Thu Jan 10 18:40:41 2013 -0500
@@ -24,6 +24,8 @@
  */
 package java.util.stream.primitive;
 
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
 import java.util.function.Block;
 import java.util.function.IntBlock;
 import java.util.function.ObjIntFunction;
@@ -43,7 +45,7 @@
 
     @Override
     default PrimitiveIterator<E> iterator() {
-        return spliterator().asIterator();
+        return spliterator().iterator();
     }
 
     @Override
@@ -61,7 +63,7 @@
     }
 
     @Override
-    PrimitiveSpliterator<E> spliterator();
+    Spliterator.OfPrimitive<E> spliterator();
 
     @Override
     default E[] asArray(ObjIntFunction<E[]> generator) {
--- a/src/share/classes/java/util/stream/primitive/PrimitiveSpliterator.java	Thu Jan 10 15:39:08 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +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.primitive;
-
-import java.util.NoSuchElementException;
-import java.util.function.Block;
-import java.util.function.IntBlock;
-import java.util.function.IntSupplier;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Spliterator;
-
-public interface PrimitiveSpliterator<E> extends Spliterator<E> {
-
-    @Override
-    PrimitiveSpliterator<E> trySplit();
-
-    @Override
-    PrimitiveIterator<E> asIterator();
-
-    default boolean tryAdvance(IntBlock block) {
-        throw new UnsupportedOperationException(getClass().toString());
-    }
-
-    void forEach(IntBlock block);
-
-    //
-
-    interface OfInt extends PrimitiveSpliterator<Integer> {
-
-        /**
-         * Create a {@link PrimitiveIterator} view of this spliterator
-         * @return
-         */
-        @Override
-        default PrimitiveIterator<Integer> asIterator() {
-            class Adapter implements PrimitiveIterator.OfInt, IntBlock {
-                boolean valueReady = false;
-                int nextValue;
-
-                @Override
-                public void accept(int value) {
-                    valueReady = true;
-                    nextValue = value;
-                }
-
-                @Override
-                public boolean hasNext() {
-                    if (!valueReady)
-                        tryAdvance(this);
-                    return valueReady;
-                }
-
-                @Override
-                public int nextInt() {
-                    if (!valueReady && !hasNext())
-                        throw new NoSuchElementException();
-                    else {
-                        valueReady = false;
-                        return nextValue;
-                    }
-                }
-            }
-
-            return new Adapter();
-        }
-
-        boolean tryAdvance(IntBlock block);
-
-        @Override
-        default void forEach(IntBlock block) {
-            while (tryAdvance(block)) { }
-        }
-
-        @Override
-        default boolean tryAdvance(Block<? super Integer> block) {
-            if (block instanceof IntBlock) {
-                return tryAdvance((IntBlock) block);
-            }
-            else {
-                Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in forEach", getClass().getName());
-                return tryAdvance((IntBlock) block::accept);
-            }
-        }
-
-        @Override
-        default void forEach(Block<? super Integer> sink) {
-            if (sink instanceof IntBlock) {
-                forEach((IntBlock) sink);
-            }
-            else {
-                Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} using boxed int in forEach", getClass().getName());
-                forEach((IntBlock) sink::accept);
-            }
-        }
-    }
-
-    public static class ValueHolder {
-        public static class OfInt implements IntBlock, IntSupplier {
-            private int value;
-
-            public int getAsInt() {
-                return value;
-            }
-
-            public void accept(int value) {
-                this.value = value;
-            }
-        }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/lang/CharSequenceStreamTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/lang/CharSequenceStreamTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -29,7 +29,7 @@
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.stream.Collectors;
-import java.util.stream.primitive.PrimitiveIterator;
+import java.util.PrimitiveIterator;
 
 import org.testng.annotations.Test;
 
--- a/test-ng/tests/org/openjdk/tests/java/util/BitsetStreamTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/BitsetStreamTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -30,7 +30,7 @@
 
 import java.util.BitSet;
 import java.util.stream.Collectors;
-import java.util.stream.primitive.PrimitiveIterator;
+import java.util.PrimitiveIterator;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/SpliteratorTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/SpliteratorTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -30,7 +30,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.function.Supplier;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.Streams;
 
 import static org.testng.Assert.*;
@@ -57,7 +57,7 @@
     public void testIteratorAgainstForEach(String name, Supplier<Spliterator<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        Iterator<Integer> iterator = supplier.get().asIterator();
+        Iterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.next());
 
@@ -76,7 +76,7 @@
     public void testSplitOnce(String name, Supplier<Spliterator<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        Iterator<Integer> iterator = supplier.get().asIterator();
+        Iterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.next());
 
@@ -103,7 +103,7 @@
 
         // Reference copy from iterator
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        Iterator<Integer> iterator = supplier.get().asIterator();
+        Iterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.next());
 
@@ -112,7 +112,7 @@
 
         // Iterate first few elements, then forEach rest
         ArrayList<Integer> dest = new ArrayList<>();
-        iterator = supplier.get().asIterator();
+        iterator = supplier.get().iterator();
         for (int i=0; i<10 && iterator.hasNext(); i++)
             dest.add(iterator.next());
         iterator.forEach(e -> dest.add(e));
@@ -126,7 +126,7 @@
     public void testSplitSixDeep(String name, Supplier<Spliterator<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        Iterator<Integer> iterator = supplier.get().asIterator();
+        Iterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.next());
         if (sizeIfKnown != -1)
@@ -167,7 +167,7 @@
         else {
             long sizeIfKnown = spliterator.exactSizeIfKnown();
             if (useIterator) {
-                Iterator<Integer> iterator = spliterator.asIterator();
+                Iterator<Integer> iterator = spliterator.iterator();
                 int count = 0;
                 while (iterator.hasNext()) {
                     ++count;
@@ -189,7 +189,7 @@
                     assertEquals(sizeIfKnown, boxedCount[0]);
 
                 // assert splterator.iterator() is empty
-                Iterator<Integer> iterator = spliterator.asIterator();
+                Iterator<Integer> iterator = spliterator.iterator();
                 assertFalse(iterator.hasNext());
             }
         }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -31,7 +31,7 @@
 import java.util.List;
 import java.util.function.Block;
 import java.util.function.Function;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.Stream;
 import java.util.stream.StreamOpFlag;
 import java.util.stream.Streams;
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestData.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestData.java	Thu Jan 10 18:40:41 2013 -0500
@@ -26,6 +26,7 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Spliterator;
 import java.util.stream.*;
 import java.util.stream.op.SpinedBuffer;
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestDataProvider.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestDataProvider.java	Thu Jan 10 18:40:41 2013 -0500
@@ -30,7 +30,7 @@
 import java.util.*;
 import java.util.function.BiFunction;
 import java.util.function.Supplier;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.op.SpinedBuffer;
 
 /**
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestScenario.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestScenario.java	Thu Jan 10 18:40:41 2013 -0500
@@ -25,6 +25,7 @@
 package org.openjdk.tests.java.util.stream;
 
 import java.util.Iterator;
+import java.util.Spliterator;
 import java.util.function.Block;
 import java.util.function.Function;
 import java.util.stream.*;
@@ -87,7 +88,7 @@
     // Wrap as stream, and spliterate then iterate in pull mode
     STREAM_SPLITERATOR_ITERATOR(false) {
         <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<S_IN, Stream<U>> m) {
-            for (Iterator<U> seqIter = m.apply(data.stream()).spliterator().asIterator(); seqIter.hasNext(); )
+            for (Iterator<U> seqIter = m.apply(data.stream()).spliterator().iterator(); seqIter.hasNext(); )
                 b.accept(seqIter.next());
         }
     },
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/FindAnyOpTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FindAnyOpTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -36,12 +36,11 @@
 import java.util.Objects;
 import java.util.Optional;
 import java.util.function.BiBlock;
-import java.util.function.BiPredicate;
 import java.util.function.Function;
 import java.util.stream.Stream;
 import java.util.OptionalInt;
 import java.util.stream.IntStream;
-import java.util.stream.primitive.PrimitiveIterator;
+import java.util.PrimitiveIterator;
 
 import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/FindFirstOpTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FindFirstOpTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -39,7 +39,7 @@
 import java.util.stream.Stream;
 import java.util.OptionalInt;
 import java.util.stream.IntStream;
-import java.util.stream.primitive.PrimitiveIterator;
+import java.util.PrimitiveIterator;
 
 import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -27,9 +27,7 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 import java.util.function.Function;
 import java.util.function.IntBlock;
 import java.util.stream.op.Node;
@@ -154,7 +152,7 @@
     @Test(dataProvider = "nodes")
     public void testIterator(int[] array, PrimitiveNode<Integer> n) {
         List<Integer> l = new ArrayList<>((int) n.count());
-        PrimitiveIterator<Integer> it = n.spliterator().asIterator();
+        PrimitiveIterator<Integer> it = n.spliterator().iterator();
         while (it.hasNext()) {
             l.add(it.nextInt());
         }
@@ -165,7 +163,7 @@
     @Test(dataProvider = "nodes")
     public void testRootSpliterator(int[] array, PrimitiveNode<Integer> n) {
         List<Integer> l = new ArrayList<>((int) n.count());
-        PrimitiveIterator<Integer> it = n.spliterator().asIterator();
+        PrimitiveIterator<Integer> it = n.spliterator().iterator();
         while (it.hasNext()) {
             l.add(it.nextInt());
         }
@@ -177,16 +175,16 @@
     public void testDepthOneSpliterator(int[] array, PrimitiveNode<Integer> n) {
         List<Integer> l = new ArrayList<>((int) n.count());
 
-        PrimitiveSpliterator<Integer> s = n.spliterator();
-        PrimitiveSpliterator<Integer> split = s.trySplit();
+        Spliterator.OfPrimitive<Integer> s = n.spliterator();
+        Spliterator.OfPrimitive<Integer> split = s.trySplit();
         if (split != null) {
-            PrimitiveIterator<Integer> it = split.asIterator();
+            PrimitiveIterator<Integer> it = split.iterator();
             while (it.hasNext()) {
                 l.add(it.nextInt());
             }
         }
 
-        PrimitiveIterator<Integer> it = s.asIterator();
+        PrimitiveIterator<Integer> it = s.iterator();
         while (it.hasNext()) {
             l.add(it.nextInt());
         }
@@ -198,17 +196,17 @@
     public void testTwoSpliterator(int[] array, PrimitiveNode<Integer> n) {
         List<Integer> l = new ArrayList<>((int) n.count());
 
-        PrimitiveSpliterator<Integer> s2 = n.spliterator();
-        PrimitiveSpliterator<Integer> s1 = s2.trySplit();
+        Spliterator.OfPrimitive<Integer> s2 = n.spliterator();
+        Spliterator.OfPrimitive<Integer> s1 = s2.trySplit();
 
         if (s1 != null) {
-            PrimitiveIterator<Integer> it = s1.asIterator();
+            PrimitiveIterator<Integer> it = s1.iterator();
             while (it.hasNext()) {
                 l.add(it.nextInt());
             }
         }
 
-        PrimitiveIterator<Integer> it = s2.asIterator();
+        PrimitiveIterator<Integer> it = s2.iterator();
         while (it.hasNext()) {
             l.add(it.nextInt());
         }
@@ -224,9 +222,9 @@
         assertEqualsListIntArray(l, array);
     }
 
-    void split(List<Integer> target, PrimitiveSpliterator<Integer> spliterator) {
+    void split(List<Integer> target, Spliterator.OfPrimitive<Integer> spliterator) {
         long totalSize = spliterator.exactSizeIfKnown();
-        PrimitiveSpliterator<Integer> split = spliterator.trySplit();
+        Spliterator.OfPrimitive<Integer> split = spliterator.trySplit();
         if (split == null) {
             spliterator.forEach((IntBlock) target::add);
         }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -31,7 +31,7 @@
 
 import java.util.*;
 import java.util.function.Function;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.op.Node;
 import java.util.stream.op.NodeUtils;
 import java.util.stream.op.Nodes;
@@ -132,7 +132,7 @@
     @Test(dataProvider = "nodes")
     public void testIterator(Integer[] array, Node<Integer> n) {
         List<Integer> l = new ArrayList<>((int) n.count());
-        Iterator<Integer> it = n.spliterator().asIterator();
+        Iterator<Integer> it = n.spliterator().iterator();
         while (it.hasNext()) {
             l.add(it.next());
         }
@@ -143,7 +143,7 @@
     @Test(dataProvider = "nodes")
     public void testRootSpliterator(Integer[] array, Node<Integer> n) {
         List<Integer> l = new ArrayList<>((int) n.count());
-        Iterator<Integer> it = n.spliterator().asIterator();
+        Iterator<Integer> it = n.spliterator().iterator();
         while (it.hasNext()) {
             l.add(it.next());
         }
@@ -158,13 +158,13 @@
         Spliterator<Integer> s = n.spliterator();
         Spliterator<Integer> split = s.trySplit();
         if (split != null) {
-            Iterator<Integer> it = split.asIterator();
+            Iterator<Integer> it = split.iterator();
             while (it.hasNext()) {
                 l.add(it.next());
             }
         }
 
-        Iterator<Integer> it = s.asIterator();
+        Iterator<Integer> it = s.iterator();
         while (it.hasNext()) {
             l.add(it.next());
         }
@@ -180,13 +180,13 @@
         Spliterator<Integer> s1 = s2.trySplit();
 
         if (s1 != null) {
-            Iterator<Integer> it = s1.asIterator();
+            Iterator<Integer> it = s1.iterator();
             while (it.hasNext()) {
                 l.add(it.next());
             }
         }
 
-        Iterator<Integer> it = s2.asIterator();
+        Iterator<Integer> it = s2.iterator();
         while (it.hasNext()) {
             l.add(it.next());
         }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/SequentialOpTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/SequentialOpTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -36,7 +36,7 @@
 import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.function.UnaryOperator;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.Stream;
 
 import static org.testng.Assert.assertEquals;
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/SortedOpTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/SortedOpTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -59,7 +59,7 @@
         SortedOp<Integer> op = new SortedOp.OfRef<>(cInteger);
 
         Node<Integer> result = exerciseOps(data, s -> s.sorted(cInteger));
-        assertSorted(result.spliterator().asIterator());
+        assertSorted(result.spliterator().iterator());
         // @@@ Can make stronger assertions about content equality
         Assert.assertEquals(result.count(), data.size());
 
@@ -76,7 +76,7 @@
                 <Integer, Stream<Integer>>using(op, op, new TestParallelSizedOp<>()).
                 exercise();
 
-        assertSorted(result.spliterator().asIterator());
+        assertSorted(result.spliterator().iterator());
         Assert.assertEquals(result.count(), data.size());
     }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/SpinedBufferTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/SpinedBufferTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -35,11 +35,10 @@
 import java.util.List;
 import java.util.function.IntBlock;
 import java.util.stream.Collectors;
-import java.util.stream.Spliterator;
+import java.util.Spliterator;
 import java.util.stream.Streams;
 import java.util.stream.op.SpinedBuffer;
-import java.util.stream.primitive.PrimitiveIterator;
-import java.util.stream.primitive.PrimitiveSpliterator;
+import java.util.PrimitiveIterator;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
@@ -139,8 +138,8 @@
 
     @Test(dataProvider = "IntSpinedBuffer")
     public void testIntLastSplit(int[] array, SpinedBuffer.OfInt sb) {
-        PrimitiveSpliterator.OfInt spliterator = sb.spliterator();
-        PrimitiveSpliterator<Integer> split = spliterator.trySplit();
+        Spliterator.OfInt spliterator = sb.spliterator();
+        Spliterator.OfPrimitive<Integer> split = spliterator.trySplit();
         long splitSizes = (split == null) ? 0 : split.exactSizeIfKnown();
         long lastSplitSize = spliterator.exactSizeIfKnown();
         splitSizes += lastSplitSize;
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/ToArrayOpTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ToArrayOpTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -143,7 +143,7 @@
 
         {
             Node<Integer> node = Nodes.node(l);
-            Object[] output = Streams.stream(Iterators.spliterator(node.spliterator().asIterator(), node.count()), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED).sequential().toArray();
+            Object[] output = Streams.stream(Iterators.spliterator(node.spliterator().iterator(), node.count()), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED).sequential().toArray();
             assertEquals(Arrays.asList(output), l);
 
             output = Streams.stream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED).sequential().toArray();
@@ -153,7 +153,7 @@
     }
 
     private void testNode(List<Integer> l, Node<Integer> node) {
-        Object[] output = Streams.stream(Iterators.spliterator(node.spliterator().asIterator(), node.count()), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED).toArray();
+        Object[] output = Streams.stream(Iterators.spliterator(node.spliterator().iterator(), node.count()), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED).toArray();
         assertEquals(Arrays.asList(output), l);
 
         output = Streams.stream(() -> node.spliterator(), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED).toArray();
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntSpliteratorTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntSpliteratorTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -26,13 +26,10 @@
 
 import org.testng.annotations.Test;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 import java.util.function.IntBlock;
 import java.util.function.Supplier;
 import java.util.stream.Streams;
-import java.util.stream.primitive.PrimitiveIterator;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 import static org.testng.Assert.*;
 
@@ -44,10 +41,10 @@
 @Test
 public class IntSpliteratorTest {
     @Test(dataProvider = "IntSpliterator", dataProviderClass = IntStreamTestDataProvider.class )
-    public void testIteratorAgainstForEach(String name, Supplier<PrimitiveSpliterator<Integer>> supplier) {
+    public void testIteratorAgainstForEach(String name, Supplier<Spliterator.OfPrimitive<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        PrimitiveIterator<Integer> iterator = supplier.get().asIterator();
+        PrimitiveIterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.nextInt());
 
@@ -63,16 +60,16 @@
     }
 
     @Test(dataProvider = "IntSpliterator", dataProviderClass = IntStreamTestDataProvider.class )
-    public void testSplitOnce(String name, Supplier<PrimitiveSpliterator<Integer>> supplier) {
+    public void testSplitOnce(String name, Supplier<Spliterator.OfPrimitive<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        PrimitiveIterator<Integer> iterator = supplier.get().asIterator();
+        PrimitiveIterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.nextInt());
 
         ArrayList<Integer> fromSplit = new ArrayList<>();
-        PrimitiveSpliterator<Integer> s1 = supplier.get();
-        PrimitiveSpliterator<Integer> s2 = s1.trySplit();
+        Spliterator.OfPrimitive<Integer> s1 = supplier.get();
+        Spliterator.OfPrimitive<Integer> s2 = s1.trySplit();
         long s1Size = s1.exactSizeIfKnown();
         long s2Size = (s2 != null) ? s2.exactSizeIfKnown() : 0;
         if (s2 != null)
@@ -88,12 +85,12 @@
     }
 
     @Test(dataProvider = "IntSpliterator", dataProviderClass = IntStreamTestDataProvider.class )
-    public void testMixedIteratorForeach(String name, Supplier<PrimitiveSpliterator<Integer>> supplier) {
+    public void testMixedIteratorForeach(String name, Supplier<Spliterator.OfPrimitive<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
 
         // Reference copy from iterator
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        PrimitiveIterator<Integer> iterator = supplier.get().asIterator();
+        PrimitiveIterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.nextInt());
 
@@ -102,7 +99,7 @@
 
         // Iterate first few elements, then forEach rest
         ArrayList<Integer> dest = new ArrayList<>();
-        iterator = supplier.get().asIterator();
+        iterator = supplier.get().iterator();
         for (int i=0; i<10 && iterator.hasNext(); i++)
             dest.add(iterator.nextInt());
         iterator.forEach((int e) -> dest.add(e));
@@ -113,16 +110,16 @@
     }
 
     @Test(dataProvider = "IntSpliterator", dataProviderClass = IntStreamTestDataProvider.class )
-    public void testSplitSixDeep(String name, Supplier<PrimitiveSpliterator<Integer>> supplier) {
+    public void testSplitSixDeep(String name, Supplier<Spliterator.OfPrimitive<Integer>> supplier) {
         long sizeIfKnown = supplier.get().exactSizeIfKnown();
         ArrayList<Integer> fromIterator = new ArrayList<>();
-        PrimitiveIterator<Integer> iterator = supplier.get().asIterator();
+        PrimitiveIterator<Integer> iterator = supplier.get().iterator();
         while (iterator.hasNext())
             fromIterator.add(iterator.nextInt());
 
         for (int depth=0; depth < 6; depth++) {
             ArrayList<Integer> dest = new ArrayList<>();
-            PrimitiveSpliterator<Integer> spliterator = supplier.get();
+            Spliterator.OfPrimitive<Integer> spliterator = supplier.get();
             // verify splitting with forEach
             visit(depth, 0, dest, spliterator, spliterator.hasExactSplits(), false);
             assertEquals(fromIterator, dest);
@@ -135,10 +132,10 @@
         }
     }
 
-    private void visit(int depth, int curLevel, List<Integer> dest, PrimitiveSpliterator<Integer> spliterator, boolean isPredictable, boolean useIterator) {
+    private void visit(int depth, int curLevel, List<Integer> dest, Spliterator.OfPrimitive<Integer> spliterator, boolean isPredictable, boolean useIterator) {
         if (curLevel < depth) {
             long beforeSize = spliterator.exactSizeIfKnown();
-            PrimitiveSpliterator<Integer> split = spliterator.trySplit();
+            Spliterator.OfPrimitive<Integer> split = spliterator.trySplit();
             if (split != null) {
                 if (isPredictable) {
                     long leftSize = split.exactSizeIfKnown();
@@ -155,7 +152,7 @@
         else {
             long sizeIfKnown = spliterator.exactSizeIfKnown();
             if (useIterator) {
-                PrimitiveIterator<Integer> iterator = spliterator.asIterator();
+                PrimitiveIterator<Integer> iterator = spliterator.iterator();
                 int count = 0;
                 while (iterator.hasNext()) {
                     ++count;
@@ -177,7 +174,7 @@
                     assertEquals(sizeIfKnown, boxedCount[0]);
 
                 // assert splterator.iterator() is empty
-                PrimitiveIterator<Integer> iterator = spliterator.asIterator();
+                PrimitiveIterator<Integer> iterator = spliterator.iterator();
                 if (iterator.hasNext()) {
                     System.out.println(iterator);
                     System.out.println(spliterator);
@@ -189,17 +186,17 @@
     }
 
     @Test(dataProvider = "IntSpliterator", dataProviderClass = IntStreamTestDataProvider.class )
-    public void testSplitAfterIterate(String name, Supplier<PrimitiveSpliterator<Integer>> supplier) {
+    public void testSplitAfterIterate(String name, Supplier<Spliterator.OfPrimitive<Integer>> supplier) {
 
         // advance, split
-        PrimitiveSpliterator<Integer> s = supplier.get();
+        Spliterator.OfPrimitive<Integer> s = supplier.get();
         s.tryAdvance((IntBlock) e -> {
         });
         assertSplitThrowsISE(s);
 
         // split, advance, split
         s = supplier.get();
-        PrimitiveSpliterator<Integer> s1 = s.trySplit();
+        Spliterator.OfPrimitive<Integer> s1 = s.trySplit();
         s.tryAdvance((IntBlock) e -> {
         });
         if (s1 != null)
@@ -228,14 +225,14 @@
             assertSplitThrowsISE(s1);
     }
 
-    private void assertSplitThrowsISE(PrimitiveSpliterator<Integer> s) {
+    private void assertSplitThrowsISE(Spliterator.OfPrimitive<Integer> s) {
         // Special dispensation for the singleton empty spliterator
-        PrimitiveSpliterator<Integer> empty = Streams.emptyPrimitiveSpliterator();
+        Spliterator.OfPrimitive<Integer> empty = Streams.emptyPrimitiveSpliterator();
         if (s == empty)
             return;
 
         try {
-            PrimitiveSpliterator<Integer> s1 = s.trySplit();
+            Spliterator.OfPrimitive<Integer> s1 = s.trySplit();
             // fall through
         }
         catch (IllegalStateException e) {
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamSpliteratorTest.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamSpliteratorTest.java	Thu Jan 10 18:40:41 2013 -0500
@@ -27,15 +27,12 @@
 import org.openjdk.tests.java.util.stream.OpTestCase;
 import org.testng.annotations.Test;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 import java.util.function.Block;
 import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.IntStream;
 import java.util.stream.Streams;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
 
@@ -77,7 +74,7 @@
 
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
     public void testSpliterators(String name, IntStreamTestData data) {
-        for (Block<Supplier<PrimitiveSpliterator<Integer>>> b : spliteratorBlocks()) {
+        for (Block<Supplier<Spliterator.OfPrimitive<Integer>>> b : spliteratorBlocks()) {
             for (Function<IntStream, IntStream> f : streamFunctions()) {
                 b.accept(() -> f.apply(data.stream()).spliterator());
             }
@@ -86,7 +83,7 @@
 
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
     public void testParSpliterators(String name, IntStreamTestData data) {
-        for (Block<Supplier<PrimitiveSpliterator<Integer>>> b : spliteratorBlocks()) {
+        for (Block<Supplier<Spliterator.OfPrimitive<Integer>>> b : spliteratorBlocks()) {
             for (Function<IntStream, IntStream> f : streamFunctions()) {
                 b.accept(() -> f.apply(data.parallelStream()).spliterator());
             }
@@ -121,11 +118,11 @@
         return streamFunctions;
     }
 
-    private List<Block<Supplier<PrimitiveSpliterator<Integer>>>> spliteratorBlocks;
+    private List<Block<Supplier<Spliterator.OfPrimitive<Integer>>>> spliteratorBlocks;
 
-    List<Block<Supplier<PrimitiveSpliterator<Integer>>>> spliteratorBlocks() {
+    List<Block<Supplier<Spliterator.OfPrimitive<Integer>>>> spliteratorBlocks() {
         if (spliteratorBlocks == null) {
-            spliteratorBlocks = Arrays.<Block<Supplier<PrimitiveSpliterator<Integer>>>>asList(
+            spliteratorBlocks = Arrays.<Block<Supplier<Spliterator.OfPrimitive<Integer>>>>asList(
                     s -> proxy.testIteratorAgainstForEach("testIteratorAgainstForEach", s),
                     s -> proxy.testMixedIteratorForeach("testMixedIteratorForeach", s),
                     s -> proxy.testSplitOnce("testSplitOnce", s),
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestData.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestData.java	Thu Jan 10 18:40:41 2013 -0500
@@ -27,11 +27,12 @@
 import org.openjdk.tests.java.util.stream.OpTestCase;
 
 import java.util.Arrays;
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
 import java.util.function.IntSupplier;
 import java.util.function.Supplier;
 import java.util.stream.*;
 import java.util.stream.op.SpinedBuffer;
-import java.util.stream.primitive.*;
 
 public abstract class IntStreamTestData implements OpTestCase.TestData<Integer, IntStream> {
 
@@ -68,7 +69,7 @@
         }
 
         @Override
-        public PrimitiveSpliterator<Integer> spliterator() {
+        public Spliterator.OfPrimitive<Integer> spliterator() {
             return Arrays.spliterator(array);
         }
 
@@ -110,7 +111,7 @@
         }
 
         @Override
-        public PrimitiveSpliterator<Integer> spliterator() {
+        public Spliterator.OfPrimitive<Integer> spliterator() {
             throw new UnsupportedOperationException();
         }
 
@@ -150,7 +151,7 @@
         }
 
         @Override
-        public PrimitiveSpliterator<Integer> spliterator() {
+        public Spliterator.OfPrimitive<Integer> spliterator() {
             return s.get().spliterator();
         }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestDataProvider.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestDataProvider.java	Thu Jan 10 18:40:41 2013 -0500
@@ -31,7 +31,6 @@
 import java.util.function.Supplier;
 import java.util.stream.Streams;
 import java.util.stream.op.SpinedBuffer;
-import java.util.stream.primitive.PrimitiveSpliterator;
 
 public class IntStreamTestDataProvider {
     private static final int[] to0 = new int[0];
@@ -114,15 +113,15 @@
                     isl.accept(i);
                 }
 
-                spliterators.add(new Object[] { "Arrays.s(array):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Arrays.spliterator(ints) });
-                spliterators.add(new Object[] { "Arrays.s(array,o,l):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Arrays.spliterator(ints, 0, ints.length / 2) });
-                spliterators.add(new Object[] { "SpinedBuffer.s():" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> isl.spliterator() });
-                spliterators.add(new Object[] { "Primitives.s(SpinedBuffer.iterator(), size):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Streams.intSpliterator(isl.iterator(), ints.length) });
-                spliterators.add(new Object[] { "Primitives.s(SpinedBuffer.iterator()):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Streams.intSpliteratorUnknownSize(isl.iterator()) });
-                spliterators.add(new Object[] { "Primitives.range(0,l):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Streams.intRange(0, ints.length).spliterator() });
-                spliterators.add(new Object[] { "Primitives.range(0,l,2):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Streams.intRange(0, ints.length, 2).spliterator() });
-                spliterators.add(new Object[] { "Primitives.range(0,l,3):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Streams.intRange(0, ints.length, 3).spliterator() });
-                spliterators.add(new Object[] { "Primitives.range(0,l,7):" + name, (Supplier<PrimitiveSpliterator<Integer>>) () -> Streams.intRange(0, ints.length, 7).spliterator() });
+                spliterators.add(new Object[] { "Arrays.s(array):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Arrays.spliterator(ints) });
+                spliterators.add(new Object[] { "Arrays.s(array,o,l):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Arrays.spliterator(ints, 0, ints.length / 2) });
+                spliterators.add(new Object[] { "SpinedBuffer.s():" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> isl.spliterator() });
+                spliterators.add(new Object[] { "Primitives.s(SpinedBuffer.iterator(), size):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Streams.intSpliterator(isl.iterator(), ints.length) });
+                spliterators.add(new Object[] { "Primitives.s(SpinedBuffer.iterator()):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Streams.intSpliteratorUnknownSize(isl.iterator()) });
+                spliterators.add(new Object[] { "Primitives.range(0,l):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Streams.intRange(0, ints.length).spliterator() });
+                spliterators.add(new Object[] { "Primitives.range(0,l,2):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Streams.intRange(0, ints.length, 2).spliterator() });
+                spliterators.add(new Object[] { "Primitives.range(0,l,3):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Streams.intRange(0, ints.length, 3).spliterator() });
+                spliterators.add(new Object[] { "Primitives.range(0,l,7):" + name, (Supplier<Spliterator.OfPrimitive<Integer>>) () -> Streams.intRange(0, ints.length, 7).spliterator() });
                 // Need more!
             }
             spliteratorTestData = spliterators.toArray(new Object[0][]);
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestScenario.java	Thu Jan 10 15:39:08 2013 -0800
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestScenario.java	Thu Jan 10 18:40:41 2013 -0500
@@ -26,14 +26,14 @@
 
 import org.openjdk.tests.java.util.stream.OpTestCase;
 
+import java.util.Spliterator;
 import java.util.function.Block;
 import java.util.function.IntBlock;
 import java.util.function.Function;
 import java.util.stream.*;
 import org.openjdk.tests.java.util.stream.op.FlagDeclaringOp;
 import java.util.stream.IntStream;
-import java.util.stream.primitive.PrimitiveIterator;
-import java.util.stream.primitive.PrimitiveSpliterator;
+import java.util.PrimitiveIterator;
 
 @SuppressWarnings({"rawtypes", "unchecked"})
 public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
@@ -66,7 +66,7 @@
     // Wrap as stream, and spliterate then iterate in pull mode
     STREAM_SPLITERATOR(false) {
         <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<S_IN, IntStream> m) {
-            for (PrimitiveSpliterator<Integer> spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) { }
+            for (Spliterator.OfPrimitive<Integer> spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) { }
         }
     },
 
@@ -80,7 +80,7 @@
     // Wrap as stream, and spliterate then iterate in pull mode
     STREAM_SPLITERATOR_ITERATOR(false) {
         <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<S_IN, IntStream> m) {
-            for (PrimitiveIterator<Integer> seqIter = m.apply(data.stream()).spliterator().asIterator(); seqIter.hasNext(); )
+            for (PrimitiveIterator<Integer> seqIter = m.apply(data.stream()).spliterator().iterator(); seqIter.hasNext(); )
                 b.accept(seqIter.nextInt());
         }
     },
@@ -94,7 +94,7 @@
     // Wrap as stream, and spliterate then iterate sequentially
     PAR_STREAM_SPLITERATOR(true) {
         <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<S_IN, IntStream> m) {
-            for (PrimitiveSpliterator<Integer> spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) { }
+            for (Spliterator.OfPrimitive<Integer> spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) { }
         }
     },