ojtests: Split out public/boot tests and add device targets
* Enable tests to be run from CTS (without changing bootclasspath)
* Fix host test script to pass higher heap maximum
* Include test source code as part of the core-ojtests-public.jar
Bug: 27521545
Bug: 27797922
Change-Id: Ibd5ac74c939d1252e17dab2dc22d2a00de837bfd
(cherry picked from commit ce0115e08189fcb96f990f0b93a6c2aeae59250e)
diff --git a/JavaLibrary.mk b/JavaLibrary.mk
index 18ca800..6114ad2 100644
--- a/JavaLibrary.mk
+++ b/JavaLibrary.mk
@@ -325,7 +325,7 @@
include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
endif
-# Make the core-ojtests library.
+# Make the core-ojtests-hostdex library.
ifeq ($(LIBCORE_SKIP_TESTS),)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(ojtest_src_files)
@@ -340,6 +340,43 @@
include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
endif
+# Make the core-ojtests library.
+ifeq ($(LIBCORE_SKIP_TESTS),)
+ include $(CLEAR_VARS)
+ LOCAL_NO_STANDARD_LIBRARIES := true
+ LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp bouncycastle
+ LOCAL_STATIC_JAVA_LIBRARIES := testng
+ LOCAL_JAVACFLAGS := $(local_javac_flags)
+ LOCAL_MODULE_TAGS := optional
+ LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+ LOCAL_MODULE := core-ojtests
+ LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
+ # jack bug workaround: int[] java.util.stream.StatefulTestOp.-getjava-util-stream-StreamShapeSwitchesValues() is a private synthetic method in an interface which causes a hard verifier error
+ LOCAL_DEX_PREOPT := false # disable AOT preverification which breaks the build. it will still throw VerifyError at runtime.
+ include $(BUILD_JAVA_LIBRARY)
+endif
+
+
+# Make the core-ojtests-public library. Excludes any private API tests.
+ifeq ($(LIBCORE_SKIP_TESTS),)
+ include $(CLEAR_VARS)
+ # Filter out SerializedLambdaTest because it depends on stub classes and won't actually run.
+ LOCAL_SRC_FILES := $(filter-out %/DeserializeMethodTest.java %/SerializedLambdaTest.java ojluni/src/test/java/util/stream/boot%,$(ojtest_src_files)) # Do not include anything from the boot* directories. Those directories need a custom bootclasspath to run.
+ # Include source code as part of JAR
+ LOCAL_JAVA_RESOURCE_DIRS := ojluni/src/test/dist
+ LOCAL_NO_STANDARD_LIBRARIES := true
+ LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp bouncycastle testng
+ LOCAL_JAVACFLAGS := $(local_javac_flags)
+ LOCAL_MODULE_TAGS := optional
+ LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+ LOCAL_MODULE := core-ojtests-public
+ LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
+ # jack bug workaround: int[] java.util.stream.StatefulTestOp.-getjava-util-stream-StreamShapeSwitchesValues() is a private synthetic method in an interface which causes a hard verifier error
+ LOCAL_DEX_PREOPT := false # disable AOT preverification which breaks the build. it will still throw VerifyError at runtime.
+ include $(BUILD_JAVA_LIBRARY)
+endif
+
+
endif # HOST_OS == linux
#
diff --git a/ojluni/src/main/java/java/util/stream/AbstractPipeline.java b/ojluni/src/main/java/java/util/stream/AbstractPipeline.java
index d3ccdac..9bdea9c 100644
--- a/ojluni/src/main/java/java/util/stream/AbstractPipeline.java
+++ b/ojluni/src/main/java/java/util/stream/AbstractPipeline.java
@@ -68,8 +68,9 @@
* @param <E_OUT> type of output elements
* @param <S> type of the subclass implementing {@code BaseStream}
* @since 1.8
+ * @hide Visibility for CTS only (OpenJDK 8 streams tests).
*/
-abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
+public abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
extends PipelineHelper<E_OUT> implements BaseStream<E_OUT, S> {
private static final String MSG_STREAM_LINKED = "stream has already been operated upon or closed";
private static final String MSG_CONSUMED = "source already consumed or closed";
@@ -241,7 +242,7 @@
* @return a flat array-backed Node that holds the collected output elements
*/
@SuppressWarnings("unchecked")
- final Node<E_OUT> evaluateToArrayNode(IntFunction<E_OUT[]> generator) {
+ public final Node<E_OUT> evaluateToArrayNode(IntFunction<E_OUT[]> generator) {
if (linkedOrConsumed)
throw new IllegalStateException(MSG_STREAM_LINKED);
linkedOrConsumed = true;
@@ -379,7 +380,7 @@
* intermediate operations
* @see StreamOpFlag
*/
- final int getStreamFlags() {
+ public final int getStreamFlags() {
return StreamOpFlag.toStreamFlags(combinedFlags);
}
@@ -500,7 +501,7 @@
}
@Override
- final int getStreamAndOpFlags() {
+ public final int getStreamAndOpFlags() {
return combinedFlags;
}
@@ -510,7 +511,7 @@
@Override
@SuppressWarnings("unchecked")
- final <P_IN> Sink<P_IN> wrapSink(Sink<E_OUT> sink) {
+ public final <P_IN> Sink<P_IN> wrapSink(Sink<E_OUT> sink) {
Objects.requireNonNull(sink);
for ( @SuppressWarnings("rawtypes") AbstractPipeline p=AbstractPipeline.this; p.depth > 0; p=p.previousStage) {
@@ -532,7 +533,7 @@
@Override
@SuppressWarnings("unchecked")
- final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator,
+ public final <P_IN> Node<E_OUT> evaluate(Spliterator<P_IN> spliterator,
boolean flatten,
IntFunction<E_OUT[]> generator) {
if (isParallel()) {
@@ -557,7 +558,7 @@
*
* @return the output shape
*/
- abstract StreamShape getOutputShape();
+ public abstract StreamShape getOutputShape();
/**
* Collect elements output from a pipeline into a Node that holds elements
@@ -569,10 +570,10 @@
* @param generator the array generator
* @return a Node holding the output of the pipeline
*/
- abstract <P_IN> Node<E_OUT> evaluateToNode(PipelineHelper<E_OUT> helper,
- Spliterator<P_IN> spliterator,
- boolean flattenTree,
- IntFunction<E_OUT[]> generator);
+ public abstract <P_IN> Node<E_OUT> evaluateToNode(PipelineHelper<E_OUT> helper,
+ Spliterator<P_IN> spliterator,
+ boolean flattenTree,
+ IntFunction<E_OUT[]> generator);
/**
* Create a spliterator that wraps a source spliterator, compatible with
@@ -583,16 +584,16 @@
* @param supplier the supplier of a spliterator
* @return a wrapping spliterator compatible with this shape
*/
- abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph,
- Supplier<Spliterator<P_IN>> supplier,
- boolean isParallel);
+ public abstract <P_IN> Spliterator<E_OUT> wrap(PipelineHelper<E_OUT> ph,
+ Supplier<Spliterator<P_IN>> supplier,
+ boolean isParallel);
/**
* Create a lazy spliterator that wraps and obtains the supplied the
* spliterator when a method is invoked on the lazy spliterator.
* @param supplier the supplier of a spliterator
*/
- abstract Spliterator<E_OUT> lazySpliterator(Supplier<? extends Spliterator<E_OUT>> supplier);
+ public abstract Spliterator<E_OUT> lazySpliterator(Supplier<? extends Spliterator<E_OUT>> supplier);
/**
* Traverse the elements of a spliterator compatible with this stream shape,
@@ -602,7 +603,7 @@
* @param spliterator the spliterator to pull elements from
* @param sink the sink to push elements to
*/
- abstract void forEachWithCancel(Spliterator<E_OUT> spliterator, Sink<E_OUT> sink);
+ public abstract void forEachWithCancel(Spliterator<E_OUT> spliterator, Sink<E_OUT> sink);
/**
* Make a node builder compatible with this stream shape.
@@ -620,8 +621,8 @@
* @return a node builder
*/
@Override
- abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
- IntFunction<E_OUT[]> generator);
+ public abstract Node.Builder<E_OUT> makeNodeBuilder(long exactSizeIfKnown,
+ IntFunction<E_OUT[]> generator);
// Op-specific abstract methods, implemented by the operation class
@@ -634,7 +635,7 @@
*
* @return {@code true} if this operation is stateful
*/
- abstract boolean opIsStateful();
+ public abstract boolean opIsStateful();
/**
* Accepts a {@code Sink} which will receive the results of this operation,
@@ -655,7 +656,7 @@
* each element, and passes the results (if any) to the provided
* {@code Sink}.
*/
- abstract Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink);
+ public abstract Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink);
/**
* Performs a parallel evaluation of the operation using the specified
@@ -672,7 +673,7 @@
* @param generator the array generator
* @return a {@code Node} describing the result of the evaluation
*/
- <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
+ public <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator,
IntFunction<E_OUT[]> generator) {
throw new UnsupportedOperationException("Parallel evaluation is not supported");
@@ -699,7 +700,7 @@
* @return a {@code Spliterator} describing the result of the evaluation
*/
@SuppressWarnings("unchecked")
- <P_IN> Spliterator<E_OUT> opEvaluateParallelLazy(PipelineHelper<E_OUT> helper,
+ public <P_IN> Spliterator<E_OUT> opEvaluateParallelLazy(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator) {
return opEvaluateParallel(helper, spliterator, i -> (E_OUT[]) new Object[i]).spliterator();
}
diff --git a/ojluni/src/main/java/java/util/stream/DistinctOps.java b/ojluni/src/main/java/java/util/stream/DistinctOps.java
index 66d7cb7..0b7713e 100644
--- a/ojluni/src/main/java/java/util/stream/DistinctOps.java
+++ b/ojluni/src/main/java/java/util/stream/DistinctOps.java
@@ -65,7 +65,7 @@
}
@Override
- <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+ public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
Spliterator<P_IN> spliterator,
IntFunction<T[]> generator) {
if (StreamOpFlag.DISTINCT.isKnown(helper.getStreamAndOpFlags())) {
@@ -100,7 +100,7 @@
}
@Override
- <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
+ public <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
if (StreamOpFlag.DISTINCT.isKnown(helper.getStreamAndOpFlags())) {
// No-op
return helper.wrapSpliterator(spliterator);
@@ -116,7 +116,7 @@
}
@Override
- Sink<T> opWrapSink(int flags, Sink<T> sink) {
+ public Sink<T> opWrapSink(int flags, Sink<T> sink) {
Objects.requireNonNull(sink);
if (StreamOpFlag.DISTINCT.isKnown(flags)) {
diff --git a/ojluni/src/main/java/java/util/stream/DoublePipeline.java b/ojluni/src/main/java/java/util/stream/DoublePipeline.java
index 3b6335b..25c19c6 100644
--- a/ojluni/src/main/java/java/util/stream/DoublePipeline.java
+++ b/ojluni/src/main/java/java/util/stream/DoublePipeline.java
@@ -50,8 +50,9 @@
* @param <E_IN> type of elements in the upstream source
*
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-abstract class DoublePipeline<E_IN>
+public abstract class DoublePipeline<E_IN>
extends AbstractPipeline<E_IN, Double, DoubleStream>
implements DoubleStream {
@@ -127,12 +128,12 @@
// Shape-specific methods
@Override
- final StreamShape getOutputShape() {
+ public final StreamShape getOutputShape() {
return StreamShape.DOUBLE_VALUE;
}
@Override
- final <P_IN> Node<Double> evaluateToNode(PipelineHelper<Double> helper,
+ public final <P_IN> Node<Double> evaluateToNode(PipelineHelper<Double> helper,
Spliterator<P_IN> spliterator,
boolean flattenTree,
IntFunction<Double[]> generator) {
@@ -140,7 +141,7 @@
}
@Override
- final <P_IN> Spliterator<Double> wrap(PipelineHelper<Double> ph,
+ public final <P_IN> Spliterator<Double> wrap(PipelineHelper<Double> ph,
Supplier<Spliterator<P_IN>> supplier,
boolean isParallel) {
return new StreamSpliterators.DoubleWrappingSpliterator<>(ph, supplier, isParallel);
@@ -148,19 +149,19 @@
@Override
@SuppressWarnings("unchecked")
- final Spliterator.OfDouble lazySpliterator(Supplier<? extends Spliterator<Double>> supplier) {
+ public final Spliterator.OfDouble lazySpliterator(Supplier<? extends Spliterator<Double>> supplier) {
return new StreamSpliterators.DelegatingSpliterator.OfDouble((Supplier<Spliterator.OfDouble>) supplier);
}
@Override
- final void forEachWithCancel(Spliterator<Double> spliterator, Sink<Double> sink) {
+ public final void forEachWithCancel(Spliterator<Double> spliterator, Sink<Double> sink) {
Spliterator.OfDouble spl = adapt(spliterator);
DoubleConsumer adaptedSink = adapt(sink);
do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
@Override
- final Node.Builder<Double> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Double[]> generator) {
+ public final Node.Builder<Double> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Double[]> generator) {
return Nodes.doubleBuilder(exactSizeIfKnown);
}
@@ -190,7 +191,7 @@
return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble<Double>(sink) {
@Override
public void accept(double t) {
@@ -207,7 +208,7 @@
return new ReferencePipeline.StatelessOp<Double, U>(this, StreamShape.DOUBLE_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<U> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<U> sink) {
return new Sink.ChainedDouble<U>(sink) {
@Override
public void accept(double t) {
@@ -224,7 +225,7 @@
return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedDouble<Integer>(sink) {
@Override
public void accept(double t) {
@@ -241,7 +242,7 @@
return new LongPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedDouble<Long>(sink) {
@Override
public void accept(double t) {
@@ -257,7 +258,7 @@
return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble<Double>(sink) {
@Override
public void begin(long size) {
@@ -283,7 +284,7 @@
return this;
return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_ORDERED) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return sink;
}
};
@@ -295,7 +296,7 @@
return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
StreamOpFlag.NOT_SIZED) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble<Double>(sink) {
@Override
public void begin(long size) {
@@ -318,7 +319,7 @@
return new StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE,
0) {
@Override
- Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble<Double>(sink) {
@Override
public void accept(double t) {
@@ -513,8 +514,9 @@
* Source stage of a DoubleStream
*
* @param <E_IN> type of elements in the upstream source
+ * @hide Visibility for CTS only (OpenJDK 8 streams tests).
*/
- static class Head<E_IN> extends DoublePipeline<E_IN> {
+ public static class Head<E_IN> extends DoublePipeline<E_IN> {
/**
* Constructor for the source stage of a DoubleStream.
*
@@ -524,7 +526,7 @@
* in {@link StreamOpFlag}
* @param parallel {@code true} if the pipeline is parallel
*/
- Head(Supplier<? extends Spliterator<Double>> source,
+ public Head(Supplier<? extends Spliterator<Double>> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@@ -537,18 +539,18 @@
* in {@link StreamOpFlag}
* @param parallel {@code true} if the pipeline is parallel
*/
- Head(Spliterator<Double> source,
+ public Head(Spliterator<Double> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
throw new UnsupportedOperationException();
}
@Override
- final Sink<E_IN> opWrapSink(int flags, Sink<Double> sink) {
+ public final Sink<E_IN> opWrapSink(int flags, Sink<Double> sink) {
throw new UnsupportedOperationException();
}
@@ -581,8 +583,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatelessOp<E_IN> extends DoublePipeline<E_IN> {
+ public abstract static class StatelessOp<E_IN> extends DoublePipeline<E_IN> {
/**
* Construct a new DoubleStream by appending a stateless intermediate
* operation to an existing stream.
@@ -591,7 +594,7 @@
* @param inputShape the stream shape for the upstream pipeline stage
* @param opFlags operation flags for the new stage
*/
- StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -599,7 +602,7 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return false;
}
}
@@ -609,8 +612,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatefulOp<E_IN> extends DoublePipeline<E_IN> {
+ public abstract static class StatefulOp<E_IN> extends DoublePipeline<E_IN> {
/**
* Construct a new DoubleStream by appending a stateful intermediate
* operation to an existing stream.
@@ -619,7 +623,7 @@
* @param inputShape the stream shape for the upstream pipeline stage
* @param opFlags operation flags for the new stage
*/
- StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -627,12 +631,12 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return true;
}
@Override
- abstract <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
+ public abstract <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
Spliterator<P_IN> spliterator,
IntFunction<Double[]> generator);
}
diff --git a/ojluni/src/main/java/java/util/stream/IntPipeline.java b/ojluni/src/main/java/java/util/stream/IntPipeline.java
index 5c3a8f1..60ab3b3 100644
--- a/ojluni/src/main/java/java/util/stream/IntPipeline.java
+++ b/ojluni/src/main/java/java/util/stream/IntPipeline.java
@@ -49,8 +49,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-abstract class IntPipeline<E_IN>
+public abstract class IntPipeline<E_IN>
extends AbstractPipeline<E_IN, Integer, IntStream>
implements IntStream {
@@ -130,41 +131,41 @@
// Shape-specific methods
@Override
- final StreamShape getOutputShape() {
+ public final StreamShape getOutputShape() {
return StreamShape.INT_VALUE;
}
@Override
- final <P_IN> Node<Integer> evaluateToNode(PipelineHelper<Integer> helper,
- Spliterator<P_IN> spliterator,
- boolean flattenTree,
- IntFunction<Integer[]> generator) {
+ public final <P_IN> Node<Integer> evaluateToNode(PipelineHelper<Integer> helper,
+ Spliterator<P_IN> spliterator,
+ boolean flattenTree,
+ IntFunction<Integer[]> generator) {
return Nodes.collectInt(helper, spliterator, flattenTree);
}
@Override
- final <P_IN> Spliterator<Integer> wrap(PipelineHelper<Integer> ph,
- Supplier<Spliterator<P_IN>> supplier,
- boolean isParallel) {
+ public final <P_IN> Spliterator<Integer> wrap(PipelineHelper<Integer> ph,
+ Supplier<Spliterator<P_IN>> supplier,
+ boolean isParallel) {
return new StreamSpliterators.IntWrappingSpliterator<>(ph, supplier, isParallel);
}
@Override
@SuppressWarnings("unchecked")
- final Spliterator.OfInt lazySpliterator(Supplier<? extends Spliterator<Integer>> supplier) {
+ public final Spliterator.OfInt lazySpliterator(Supplier<? extends Spliterator<Integer>> supplier) {
return new StreamSpliterators.DelegatingSpliterator.OfInt((Supplier<Spliterator.OfInt>) supplier);
}
@Override
- final void forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) {
+ public final void forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) {
Spliterator.OfInt spl = adapt(spliterator);
IntConsumer adaptedSink = adapt(sink);
do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
@Override
- final Node.Builder<Integer> makeNodeBuilder(long exactSizeIfKnown,
- IntFunction<Integer[]> generator) {
+ public final Node.Builder<Integer> makeNodeBuilder(long exactSizeIfKnown,
+ IntFunction<Integer[]> generator) {
return Nodes.intBuilder(exactSizeIfKnown);
}
@@ -188,7 +189,7 @@
return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedInt<Long>(sink) {
@Override
public void accept(int t) {
@@ -204,7 +205,7 @@
return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedInt<Double>(sink) {
@Override
public void accept(int t) {
@@ -226,7 +227,7 @@
return new StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt<Integer>(sink) {
@Override
public void accept(int t) {
@@ -243,7 +244,7 @@
return new ReferencePipeline.StatelessOp<Integer, U>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<U> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<U> sink) {
return new Sink.ChainedInt<U>(sink) {
@Override
public void accept(int t) {
@@ -260,7 +261,7 @@
return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedInt<Long>(sink) {
@Override
public void accept(int t) {
@@ -277,7 +278,7 @@
return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedInt<Double>(sink) {
@Override
public void accept(int t) {
@@ -293,7 +294,7 @@
return new StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt<Integer>(sink) {
@Override
public void begin(long size) {
@@ -319,7 +320,7 @@
return this;
return new StatelessOp<Integer>(this, StreamShape.INT_VALUE, StreamOpFlag.NOT_ORDERED) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return sink;
}
};
@@ -331,7 +332,7 @@
return new StatelessOp<Integer>(this, StreamShape.INT_VALUE,
StreamOpFlag.NOT_SIZED) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt<Integer>(sink) {
@Override
public void begin(long size) {
@@ -354,7 +355,7 @@
return new StatelessOp<Integer>(this, StreamShape.INT_VALUE,
0) {
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt<Integer>(sink) {
@Override
public void accept(int t) {
@@ -510,8 +511,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- static class Head<E_IN> extends IntPipeline<E_IN> {
+ public static class Head<E_IN> extends IntPipeline<E_IN> {
/**
* Constructor for the source stage of an IntStream.
*
@@ -521,7 +523,7 @@
* in {@link StreamOpFlag}
* @param parallel {@code true} if the pipeline is parallel
*/
- Head(Supplier<? extends Spliterator<Integer>> source,
+ public Head(Supplier<? extends Spliterator<Integer>> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@@ -534,18 +536,18 @@
* in {@link StreamOpFlag}
* @param parallel {@code true} if the pipeline is parallel
*/
- Head(Spliterator<Integer> source,
+ public Head(Spliterator<Integer> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
throw new UnsupportedOperationException();
}
@Override
- final Sink<E_IN> opWrapSink(int flags, Sink<Integer> sink) {
+ public final Sink<E_IN> opWrapSink(int flags, Sink<Integer> sink) {
throw new UnsupportedOperationException();
}
@@ -577,8 +579,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatelessOp<E_IN> extends IntPipeline<E_IN> {
+ public abstract static class StatelessOp<E_IN> extends IntPipeline<E_IN> {
/**
* Construct a new IntStream by appending a stateless intermediate
* operation to an existing stream.
@@ -586,7 +589,7 @@
* @param inputShape The stream shape for the upstream pipeline stage
* @param opFlags Operation flags for the new stage
*/
- StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -594,7 +597,7 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return false;
}
}
@@ -604,8 +607,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatefulOp<E_IN> extends IntPipeline<E_IN> {
+ public abstract static class StatefulOp<E_IN> extends IntPipeline<E_IN> {
/**
* Construct a new IntStream by appending a stateful intermediate
* operation to an existing stream.
@@ -613,7 +617,7 @@
* @param inputShape The stream shape for the upstream pipeline stage
* @param opFlags Operation flags for the new stage
*/
- StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -621,12 +625,12 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return true;
}
@Override
- abstract <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
+ public abstract <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
Spliterator<P_IN> spliterator,
IntFunction<Integer[]> generator);
}
diff --git a/ojluni/src/main/java/java/util/stream/LongPipeline.java b/ojluni/src/main/java/java/util/stream/LongPipeline.java
index 88e919e..e7f6a5ad 100644
--- a/ojluni/src/main/java/java/util/stream/LongPipeline.java
+++ b/ojluni/src/main/java/java/util/stream/LongPipeline.java
@@ -50,8 +50,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-abstract class LongPipeline<E_IN>
+public abstract class LongPipeline<E_IN>
extends AbstractPipeline<E_IN, Long, LongStream>
implements LongStream {
@@ -128,12 +129,12 @@
// Shape-specific methods
@Override
- final StreamShape getOutputShape() {
+ public final StreamShape getOutputShape() {
return StreamShape.LONG_VALUE;
}
@Override
- final <P_IN> Node<Long> evaluateToNode(PipelineHelper<Long> helper,
+ public final <P_IN> Node<Long> evaluateToNode(PipelineHelper<Long> helper,
Spliterator<P_IN> spliterator,
boolean flattenTree,
IntFunction<Long[]> generator) {
@@ -141,7 +142,7 @@
}
@Override
- final <P_IN> Spliterator<Long> wrap(PipelineHelper<Long> ph,
+ public final <P_IN> Spliterator<Long> wrap(PipelineHelper<Long> ph,
Supplier<Spliterator<P_IN>> supplier,
boolean isParallel) {
return new StreamSpliterators.LongWrappingSpliterator<>(ph, supplier, isParallel);
@@ -149,19 +150,19 @@
@Override
@SuppressWarnings("unchecked")
- final Spliterator.OfLong lazySpliterator(Supplier<? extends Spliterator<Long>> supplier) {
+ public final Spliterator.OfLong lazySpliterator(Supplier<? extends Spliterator<Long>> supplier) {
return new StreamSpliterators.DelegatingSpliterator.OfLong((Supplier<Spliterator.OfLong>) supplier);
}
@Override
- final void forEachWithCancel(Spliterator<Long> spliterator, Sink<Long> sink) {
+ public final void forEachWithCancel(Spliterator<Long> spliterator, Sink<Long> sink) {
Spliterator.OfLong spl = adapt(spliterator);
LongConsumer adaptedSink = adapt(sink);
do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
@Override
- final Node.Builder<Long> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Long[]> generator) {
+ public final Node.Builder<Long> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Long[]> generator) {
return Nodes.longBuilder(exactSizeIfKnown);
}
@@ -185,7 +186,7 @@
return new DoublePipeline.StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedLong<Double>(sink) {
@Override
public void accept(long t) {
@@ -207,7 +208,7 @@
return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong<Long>(sink) {
@Override
public void accept(long t) {
@@ -224,7 +225,7 @@
return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<U> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<U> sink) {
return new Sink.ChainedLong<U>(sink) {
@Override
public void accept(long t) {
@@ -241,7 +242,7 @@
return new IntPipeline.StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedLong<Integer>(sink) {
@Override
public void accept(long t) {
@@ -258,7 +259,7 @@
return new DoublePipeline.StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedLong<Double>(sink) {
@Override
public void accept(long t) {
@@ -274,7 +275,7 @@
return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong<Long>(sink) {
@Override
public void begin(long size) {
@@ -300,7 +301,7 @@
return this;
return new StatelessOp<Long>(this, StreamShape.LONG_VALUE, StreamOpFlag.NOT_ORDERED) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return sink;
}
};
@@ -312,7 +313,7 @@
return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
StreamOpFlag.NOT_SIZED) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong<Long>(sink) {
@Override
public void begin(long size) {
@@ -335,7 +336,7 @@
return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
0) {
@Override
- Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong<Long>(sink) {
@Override
public void accept(long t) {
@@ -493,8 +494,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visibility for CTS only (OpenJDK 8 streams tests).
*/
- static class Head<E_IN> extends LongPipeline<E_IN> {
+ public static class Head<E_IN> extends LongPipeline<E_IN> {
/**
* Constructor for the source stage of a LongStream.
*
@@ -504,7 +506,7 @@
* in {@link StreamOpFlag}
* @param parallel {@code true} if the pipeline is parallel
*/
- Head(Supplier<? extends Spliterator<Long>> source,
+ public Head(Supplier<? extends Spliterator<Long>> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@@ -517,18 +519,18 @@
* in {@link StreamOpFlag}
* @param parallel {@code true} if the pipeline is parallel
*/
- Head(Spliterator<Long> source,
+ public Head(Spliterator<Long> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
throw new UnsupportedOperationException();
}
@Override
- final Sink<E_IN> opWrapSink(int flags, Sink<Long> sink) {
+ public final Sink<E_IN> opWrapSink(int flags, Sink<Long> sink) {
throw new UnsupportedOperationException();
}
@@ -557,8 +559,9 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatelessOp<E_IN> extends LongPipeline<E_IN> {
+ public abstract static class StatelessOp<E_IN> extends LongPipeline<E_IN> {
/**
* Construct a new LongStream by appending a stateless intermediate
* operation to an existing stream.
@@ -566,7 +569,7 @@
* @param inputShape The stream shape for the upstream pipeline stage
* @param opFlags Operation flags for the new stage
*/
- StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -574,7 +577,7 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return false;
}
}
@@ -584,16 +587,18 @@
*
* @param <E_IN> type of elements in the upstream source
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatefulOp<E_IN> extends LongPipeline<E_IN> {
+ public abstract static class StatefulOp<E_IN> extends LongPipeline<E_IN> {
/**
* Construct a new LongStream by appending a stateful intermediate
* operation to an existing stream.
* @param upstream The upstream pipeline stage
* @param inputShape The stream shape for the upstream pipeline stage
* @param opFlags Operation flags for the new stage
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -601,12 +606,12 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return true;
}
@Override
- abstract <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
+ public abstract <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
Spliterator<P_IN> spliterator,
IntFunction<Long[]> generator);
}
diff --git a/ojluni/src/main/java/java/util/stream/Node.java b/ojluni/src/main/java/java/util/stream/Node.java
index 2b4360b..4a72ca4 100644
--- a/ojluni/src/main/java/java/util/stream/Node.java
+++ b/ojluni/src/main/java/java/util/stream/Node.java
@@ -56,8 +56,9 @@
*
* @param <T> the type of elements.
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-interface Node<T> {
+public interface Node<T> {
/**
* Returns a {@link Spliterator} describing the elements contained in this
diff --git a/ojluni/src/main/java/java/util/stream/PipelineHelper.java b/ojluni/src/main/java/java/util/stream/PipelineHelper.java
index f510131..06a4f92 100644
--- a/ojluni/src/main/java/java/util/stream/PipelineHelper.java
+++ b/ojluni/src/main/java/java/util/stream/PipelineHelper.java
@@ -51,8 +51,9 @@
*
* @param <P_OUT> type of output elements from the pipeline
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-abstract class PipelineHelper<P_OUT> {
+public abstract class PipelineHelper<P_OUT> {
/**
* Gets the stream shape for the source of the pipeline segment.
@@ -69,7 +70,7 @@
* @return the combined stream and operation flags
* @see StreamOpFlag
*/
- abstract int getStreamAndOpFlags();
+ public abstract int getStreamAndOpFlags();
/**
* Returns the exact output size of the portion of the output resulting from
@@ -150,7 +151,7 @@
* @return a {@code Sink} that implements the pipeline stages and sends
* results to the provided {@code Sink}
*/
- abstract<P_IN> Sink<P_IN> wrapSink(Sink<P_OUT> sink);
+ public abstract<P_IN> Sink<P_IN> wrapSink(Sink<P_OUT> sink);
/**
*
@@ -197,7 +198,7 @@
* @param generator a factory function for array instances
* @return the {@code Node} containing all output elements
*/
- abstract<P_IN> Node<P_OUT> evaluate(Spliterator<P_IN> spliterator,
+ public abstract<P_IN> Node<P_OUT> evaluate(Spliterator<P_IN> spliterator,
boolean flatten,
IntFunction<P_OUT[]> generator);
}
diff --git a/ojluni/src/main/java/java/util/stream/ReferencePipeline.java b/ojluni/src/main/java/java/util/stream/ReferencePipeline.java
index 8f5da0e..8957ee5 100644
--- a/ojluni/src/main/java/java/util/stream/ReferencePipeline.java
+++ b/ojluni/src/main/java/java/util/stream/ReferencePipeline.java
@@ -53,8 +53,9 @@
* @param <P_OUT> type of elements in produced by this stage
*
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-abstract class ReferencePipeline<P_IN, P_OUT>
+public abstract class ReferencePipeline<P_IN, P_OUT>
extends AbstractPipeline<P_IN, P_OUT, Stream<P_OUT>>
implements Stream<P_OUT> {
@@ -97,12 +98,12 @@
// Shape-specific methods
@Override
- final StreamShape getOutputShape() {
+ public final StreamShape getOutputShape() {
return StreamShape.REFERENCE;
}
@Override
- final <P_IN> Node<P_OUT> evaluateToNode(PipelineHelper<P_OUT> helper,
+ public final <P_IN> Node<P_OUT> evaluateToNode(PipelineHelper<P_OUT> helper,
Spliterator<P_IN> spliterator,
boolean flattenTree,
IntFunction<P_OUT[]> generator) {
@@ -110,24 +111,24 @@
}
@Override
- final <P_IN> Spliterator<P_OUT> wrap(PipelineHelper<P_OUT> ph,
+ public final <P_IN> Spliterator<P_OUT> wrap(PipelineHelper<P_OUT> ph,
Supplier<Spliterator<P_IN>> supplier,
boolean isParallel) {
return new StreamSpliterators.WrappingSpliterator<>(ph, supplier, isParallel);
}
@Override
- final Spliterator<P_OUT> lazySpliterator(Supplier<? extends Spliterator<P_OUT>> supplier) {
+ public final Spliterator<P_OUT> lazySpliterator(Supplier<? extends Spliterator<P_OUT>> supplier) {
return new StreamSpliterators.DelegatingSpliterator<>(supplier);
}
@Override
- final void forEachWithCancel(Spliterator<P_OUT> spliterator, Sink<P_OUT> sink) {
+ public final void forEachWithCancel(Spliterator<P_OUT> spliterator, Sink<P_OUT> sink) {
do { } while (!sink.cancellationRequested() && spliterator.tryAdvance(sink));
}
@Override
- final Node.Builder<P_OUT> makeNodeBuilder(long exactSizeIfKnown, IntFunction<P_OUT[]> generator) {
+ public final Node.Builder<P_OUT> makeNodeBuilder(long exactSizeIfKnown, IntFunction<P_OUT[]> generator) {
return Nodes.builder(exactSizeIfKnown, generator);
}
@@ -150,7 +151,7 @@
return this;
return new StatelessOp<P_OUT, P_OUT>(this, StreamShape.REFERENCE, StreamOpFlag.NOT_ORDERED) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return sink;
}
};
@@ -162,7 +163,7 @@
return new StatelessOp<P_OUT, P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SIZED) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return new Sink.ChainedReference<P_OUT, P_OUT>(sink) {
@Override
public void begin(long size) {
@@ -186,7 +187,7 @@
return new StatelessOp<P_OUT, R>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
return new Sink.ChainedReference<P_OUT, R>(sink) {
@Override
public void accept(P_OUT u) {
@@ -203,7 +204,7 @@
return new IntPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedReference<P_OUT, Integer>(sink) {
@Override
public void accept(P_OUT u) {
@@ -220,7 +221,7 @@
return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedReference<P_OUT, Long>(sink) {
@Override
public void accept(P_OUT u) {
@@ -237,7 +238,7 @@
return new DoublePipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedReference<P_OUT, Double>(sink) {
@Override
public void accept(P_OUT u) {
@@ -255,7 +256,7 @@
return new StatelessOp<P_OUT, R>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
return new Sink.ChainedReference<P_OUT, R>(sink) {
@Override
public void begin(long size) {
@@ -282,7 +283,7 @@
return new IntPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedReference<P_OUT, Integer>(sink) {
IntConsumer downstreamAsInt = downstream::accept;
@Override
@@ -310,7 +311,7 @@
return new DoublePipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedReference<P_OUT, Double>(sink) {
DoubleConsumer downstreamAsDouble = downstream::accept;
@Override
@@ -338,7 +339,7 @@
return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedReference<P_OUT, Long>(sink) {
LongConsumer downstreamAsLong = downstream::accept;
@Override
@@ -365,7 +366,7 @@
return new StatelessOp<P_OUT, P_OUT>(this, StreamShape.REFERENCE,
0) {
@Override
- Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
+ public Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return new Sink.ChainedReference<P_OUT, P_OUT>(sink) {
@Override
public void accept(P_OUT u) {
@@ -535,8 +536,9 @@
* @param <E_IN> type of elements in the upstream source
* @param <E_OUT> type of elements in produced by this stage
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- static class Head<E_IN, E_OUT> extends ReferencePipeline<E_IN, E_OUT> {
+ public static class Head<E_IN, E_OUT> extends ReferencePipeline<E_IN, E_OUT> {
/**
* Constructor for the source stage of a Stream.
*
@@ -545,7 +547,7 @@
* @param sourceFlags the source flags for the stream source, described
* in {@link StreamOpFlag}
*/
- Head(Supplier<? extends Spliterator<?>> source,
+ public Head(Supplier<? extends Spliterator<?>> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@@ -557,18 +559,18 @@
* @param sourceFlags the source flags for the stream source, described
* in {@link StreamOpFlag}
*/
- Head(Spliterator<?> source,
+ public Head(Spliterator<?> source,
int sourceFlags, boolean parallel) {
super(source, sourceFlags, parallel);
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
throw new UnsupportedOperationException();
}
@Override
- final Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink) {
+ public final Sink<E_IN> opWrapSink(int flags, Sink<E_OUT> sink) {
throw new UnsupportedOperationException();
}
@@ -601,8 +603,9 @@
* @param <E_IN> type of elements in the upstream source
* @param <E_OUT> type of elements in produced by this stage
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatelessOp<E_IN, E_OUT>
+ public abstract static class StatelessOp<E_IN, E_OUT>
extends ReferencePipeline<E_IN, E_OUT> {
/**
* Construct a new Stream by appending a stateless intermediate
@@ -612,7 +615,7 @@
* @param inputShape The stream shape for the upstream pipeline stage
* @param opFlags Operation flags for the new stage
*/
- StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatelessOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -620,7 +623,7 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return false;
}
}
@@ -631,8 +634,9 @@
* @param <E_IN> type of elements in the upstream source
* @param <E_OUT> type of elements in produced by this stage
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class StatefulOp<E_IN, E_OUT>
+ public abstract static class StatefulOp<E_IN, E_OUT>
extends ReferencePipeline<E_IN, E_OUT> {
/**
* Construct a new Stream by appending a stateful intermediate operation
@@ -641,7 +645,7 @@
* @param inputShape The stream shape for the upstream pipeline stage
* @param opFlags Operation flags for the new stage
*/
- StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
+ public StatefulOp(AbstractPipeline<?, E_IN, ?> upstream,
StreamShape inputShape,
int opFlags) {
super(upstream, opFlags);
@@ -649,12 +653,12 @@
}
@Override
- final boolean opIsStateful() {
+ public final boolean opIsStateful() {
return true;
}
@Override
- abstract <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
+ public abstract <P_IN> Node<E_OUT> opEvaluateParallel(PipelineHelper<E_OUT> helper,
Spliterator<P_IN> spliterator,
IntFunction<E_OUT[]> generator);
}
diff --git a/ojluni/src/main/java/java/util/stream/Sink.java b/ojluni/src/main/java/java/util/stream/Sink.java
index d2a366d..032fd45 100644
--- a/ojluni/src/main/java/java/util/stream/Sink.java
+++ b/ojluni/src/main/java/java/util/stream/Sink.java
@@ -113,8 +113,9 @@
*
* @param <T> type of elements for value streams
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-interface Sink<T> extends Consumer<T> {
+public interface Sink<T> extends Consumer<T> {
/**
* Resets the sink state to receive a fresh data set. This must be called
* before sending any data to the sink. After calling {@link #end()},
diff --git a/ojluni/src/main/java/java/util/stream/SliceOps.java b/ojluni/src/main/java/java/util/stream/SliceOps.java
index 34d5530..3042197 100644
--- a/ojluni/src/main/java/java/util/stream/SliceOps.java
+++ b/ojluni/src/main/java/java/util/stream/SliceOps.java
@@ -130,7 +130,7 @@
}
@Override
- <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
+ public <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper, Spliterator<P_IN> spliterator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
if (size > 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
return new StreamSpliterators.SliceSpliterator.OfRef<>(
@@ -157,7 +157,7 @@
}
@Override
- <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+ public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
Spliterator<P_IN> spliterator,
IntFunction<T[]> generator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -186,7 +186,7 @@
}
@Override
- Sink<T> opWrapSink(int flags, Sink<T> sink) {
+ public Sink<T> opWrapSink(int flags, Sink<T> sink) {
return new Sink.ChainedReference<T, T>(sink) {
long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE;
@@ -246,7 +246,7 @@
}
@Override
- <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
+ public <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
Spliterator<P_IN> spliterator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
if (size > 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
@@ -266,7 +266,7 @@
}
@Override
- <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
+ public <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
Spliterator<P_IN> spliterator,
IntFunction<Integer[]> generator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -295,7 +295,7 @@
}
@Override
- Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
+ public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt<Integer>(sink) {
long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE;
@@ -355,7 +355,7 @@
}
@Override
- <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
+ public <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
Spliterator<P_IN> spliterator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
if (size > 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
@@ -375,7 +375,7 @@
}
@Override
- <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
+ public <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
Spliterator<P_IN> spliterator,
IntFunction<Long[]> generator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -404,7 +404,7 @@
}
@Override
- Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
+ public Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong<Long>(sink) {
long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE;
@@ -464,7 +464,7 @@
}
@Override
- <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
+ public <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
Spliterator<P_IN> spliterator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
if (size > 0 && spliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
@@ -484,7 +484,7 @@
}
@Override
- <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
+ public <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
Spliterator<P_IN> spliterator,
IntFunction<Double[]> generator) {
long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -513,7 +513,7 @@
}
@Override
- Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
+ public Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble<Double>(sink) {
long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE;
diff --git a/ojluni/src/main/java/java/util/stream/SpinedBuffer.java b/ojluni/src/main/java/java/util/stream/SpinedBuffer.java
index 163692c..c91c4ff 100644
--- a/ojluni/src/main/java/java/util/stream/SpinedBuffer.java
+++ b/ojluni/src/main/java/java/util/stream/SpinedBuffer.java
@@ -52,8 +52,9 @@
*
* @param <E> the type of elements in this list
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-class SpinedBuffer<E>
+public class SpinedBuffer<E>
extends AbstractSpinedBuffer
implements Consumer<E>, Iterable<E> {
@@ -93,7 +94,7 @@
* is negative
*/
@SuppressWarnings("unchecked")
- SpinedBuffer(int initialCapacity) {
+ public SpinedBuffer(int initialCapacity) {
super(initialCapacity);
curChunk = (E[]) new Object[1 << initialChunkPower];
}
@@ -102,7 +103,7 @@
* Constructs an empty list with an initial capacity of sixteen.
*/
@SuppressWarnings("unchecked")
- SpinedBuffer() {
+ public SpinedBuffer() {
super();
curChunk = (E[]) new Object[1 << initialChunkPower];
}
@@ -414,8 +415,9 @@
* @param <E> the wrapper type for this primitive type
* @param <T_ARR> the array type for this primitive type
* @param <T_CONS> the Consumer type for this primitive type
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- abstract static class OfPrimitive<E, T_ARR, T_CONS>
+ public abstract static class OfPrimitive<E, T_ARR, T_CONS>
extends AbstractSpinedBuffer implements Iterable<E> {
/*
@@ -719,12 +721,13 @@
/**
* An ordered collection of {@code int} values.
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- static class OfInt extends SpinedBuffer.OfPrimitive<Integer, int[], IntConsumer>
+ public static class OfInt extends SpinedBuffer.OfPrimitive<Integer, int[], IntConsumer>
implements IntConsumer {
- OfInt() { }
+ public OfInt() { }
- OfInt(int initialCapacity) {
+ public OfInt(int initialCapacity) {
super(initialCapacity);
}
@@ -832,12 +835,13 @@
/**
* An ordered collection of {@code long} values.
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- static class OfLong extends SpinedBuffer.OfPrimitive<Long, long[], LongConsumer>
+ public static class OfLong extends SpinedBuffer.OfPrimitive<Long, long[], LongConsumer>
implements LongConsumer {
- OfLong() { }
+ public OfLong() { }
- OfLong(int initialCapacity) {
+ public OfLong(int initialCapacity) {
super(initialCapacity);
}
@@ -946,13 +950,14 @@
/**
* An ordered collection of {@code double} values.
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
- static class OfDouble
+ public static class OfDouble
extends SpinedBuffer.OfPrimitive<Double, double[], DoubleConsumer>
implements DoubleConsumer {
- OfDouble() { }
+ public OfDouble() { }
- OfDouble(int initialCapacity) {
+ public OfDouble(int initialCapacity) {
super(initialCapacity);
}
diff --git a/ojluni/src/main/java/java/util/stream/StreamOpFlag.java b/ojluni/src/main/java/java/util/stream/StreamOpFlag.java
index 8fecfed..3477a33 100644
--- a/ojluni/src/main/java/java/util/stream/StreamOpFlag.java
+++ b/ojluni/src/main/java/java/util/stream/StreamOpFlag.java
@@ -200,8 +200,9 @@
* For specific details see the {@link AbstractPipeline} constructors.
*
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-enum StreamOpFlag {
+public enum StreamOpFlag {
/*
* Each characteristic takes up 2 bits in a bit set to accommodate
@@ -457,7 +458,7 @@
*
* @return the bitmap for setting this characteristic
*/
- int set() {
+ public int set() {
return set;
}
@@ -466,7 +467,7 @@
*
* @return the bitmap for clearing this characteristic
*/
- int clear() {
+ public int clear() {
return clear;
}
@@ -475,7 +476,7 @@
*
* @return true if a stream-based flag, otherwise false.
*/
- boolean isStreamFlag() {
+ public boolean isStreamFlag() {
return maskTable.get(Type.STREAM) > 0;
}
@@ -487,7 +488,7 @@
* operation flags
* @return true if this flag is known, otherwise false.
*/
- boolean isKnown(int flags) {
+ public boolean isKnown(int flags) {
return (flags & preserve) == set;
}
@@ -498,7 +499,7 @@
* @param flags the operation flags or combined stream and operations flags.
* @return true if this flag is preserved, otherwise false.
*/
- boolean isCleared(int flags) {
+ public boolean isCleared(int flags) {
return (flags & preserve) == clear;
}
@@ -508,7 +509,7 @@
* @param flags the combined stream and operations flags.
* @return true if this flag is preserved, otherwise false.
*/
- boolean isPreserved(int flags) {
+ public boolean isPreserved(int flags) {
return (flags & preserve) == preserve;
}
@@ -518,34 +519,34 @@
* @param t the flag type.
* @return true if this flag can be set for the flag type, otherwise false.
*/
- boolean canSet(Type t) {
+ public boolean canSet(Type t) {
return (maskTable.get(t) & SET_BITS) > 0;
}
/**
* The bit mask for spliterator characteristics
*/
- static final int SPLITERATOR_CHARACTERISTICS_MASK = createMask(Type.SPLITERATOR);
+ public static final int SPLITERATOR_CHARACTERISTICS_MASK = createMask(Type.SPLITERATOR);
/**
* The bit mask for source stream flags.
*/
- static final int STREAM_MASK = createMask(Type.STREAM);
+ public static final int STREAM_MASK = createMask(Type.STREAM);
/**
* The bit mask for intermediate operation flags.
*/
- static final int OP_MASK = createMask(Type.OP);
+ public static final int OP_MASK = createMask(Type.OP);
/**
* The bit mask for terminal operation flags.
*/
- static final int TERMINAL_OP_MASK = createMask(Type.TERMINAL_OP);
+ public static final int TERMINAL_OP_MASK = createMask(Type.TERMINAL_OP);
/**
* The bit mask for upstream terminal operation flags.
*/
- static final int UPSTREAM_TERMINAL_OP_MASK = createMask(Type.UPSTREAM_TERMINAL_OP);
+ public static final int UPSTREAM_TERMINAL_OP_MASK = createMask(Type.UPSTREAM_TERMINAL_OP);
private static int createMask(Type t) {
int mask = 0;
@@ -582,52 +583,52 @@
* The initial value to be combined with the stream flags of the first
* stream in the pipeline.
*/
- static final int INITIAL_OPS_VALUE = FLAG_MASK_IS | FLAG_MASK_NOT;
+ public static final int INITIAL_OPS_VALUE = FLAG_MASK_IS | FLAG_MASK_NOT;
/**
* The bit value to set or inject {@link #DISTINCT}.
*/
- static final int IS_DISTINCT = DISTINCT.set;
+ public static final int IS_DISTINCT = DISTINCT.set;
/**
* The bit value to clear {@link #DISTINCT}.
*/
- static final int NOT_DISTINCT = DISTINCT.clear;
+ public static final int NOT_DISTINCT = DISTINCT.clear;
/**
* The bit value to set or inject {@link #SORTED}.
*/
- static final int IS_SORTED = SORTED.set;
+ public static final int IS_SORTED = SORTED.set;
/**
* The bit value to clear {@link #SORTED}.
*/
- static final int NOT_SORTED = SORTED.clear;
+ public static final int NOT_SORTED = SORTED.clear;
/**
* The bit value to set or inject {@link #ORDERED}.
*/
- static final int IS_ORDERED = ORDERED.set;
+ public static final int IS_ORDERED = ORDERED.set;
/**
* The bit value to clear {@link #ORDERED}.
*/
- static final int NOT_ORDERED = ORDERED.clear;
+ public static final int NOT_ORDERED = ORDERED.clear;
/**
* The bit value to set {@link #SIZED}.
*/
- static final int IS_SIZED = SIZED.set;
+ public static final int IS_SIZED = SIZED.set;
/**
* The bit value to clear {@link #SIZED}.
*/
- static final int NOT_SIZED = SIZED.clear;
+ public static final int NOT_SIZED = SIZED.clear;
/**
* The bit value to inject {@link #SHORT_CIRCUIT}.
*/
- static final int IS_SHORT_CIRCUIT = SHORT_CIRCUIT.set;
+ public static final int IS_SHORT_CIRCUIT = SHORT_CIRCUIT.set;
private static int getMask(int flags) {
return (flags == 0)
@@ -683,7 +684,7 @@
* The value {#link INITIAL_OPS_VALUE} must be used as the seed value.
* @return the updated combined stream and operation flags.
*/
- static int combineOpFlags(int newStreamOrOpFlags, int prevCombOpFlags) {
+ public static int combineOpFlags(int newStreamOrOpFlags, int prevCombOpFlags) {
// 0x01 or 0x10 nibbles are transformed to 0x11
// 0x00 nibbles remain unchanged
// Then all the bits are flipped
@@ -700,7 +701,7 @@
* @param combOpFlags the combined stream and operation flags.
* @return the stream flags.
*/
- static int toStreamFlags(int combOpFlags) {
+ public static int toStreamFlags(int combOpFlags) {
// By flipping the nibbles 0x11 become 0x00 and 0x01 become 0x10
// Shift left 1 to restore set flags and mask off anything other than the set flags
return ((~combOpFlags) >> 1) & FLAG_MASK_IS & combOpFlags;
@@ -712,7 +713,7 @@
* @param streamFlags the stream flags.
* @return the spliterator characteristic bit set.
*/
- static int toCharacteristics(int streamFlags) {
+ public static int toCharacteristics(int streamFlags) {
return streamFlags & SPLITERATOR_CHARACTERISTICS_MASK;
}
@@ -729,7 +730,7 @@
* bit set.
* @return the stream flags.
*/
- static int fromCharacteristics(Spliterator<?> spliterator) {
+ public static int fromCharacteristics(Spliterator<?> spliterator) {
int characteristics = spliterator.characteristics();
if ((characteristics & Spliterator.SORTED) != 0 && spliterator.getComparator() != null) {
// Do not propagate the SORTED characteristic if it does not correspond
@@ -747,7 +748,7 @@
* @param characteristics the spliterator characteristic bit set.
* @return the stream flags.
*/
- static int fromCharacteristics(int characteristics) {
+ public static int fromCharacteristics(int characteristics) {
return characteristics & SPLITERATOR_CHARACTERISTICS_MASK;
}
}
diff --git a/ojluni/src/main/java/java/util/stream/StreamShape.java b/ojluni/src/main/java/java/util/stream/StreamShape.java
index 9051be2..2c5f83b 100644
--- a/ojluni/src/main/java/java/util/stream/StreamShape.java
+++ b/ojluni/src/main/java/java/util/stream/StreamShape.java
@@ -45,8 +45,9 @@
* primitive type.
*
* @since 1.8
+ * @hide Visible for CTS testing only (OpenJDK8 tests).
*/
-enum StreamShape {
+public enum StreamShape {
/**
* The shape specialization corresponding to {@code Stream} and elements
* that are object references.
diff --git a/ojluni/src/test/artrun b/ojluni/src/test/artrun
index 5315eb7..3037adb 100755
--- a/ojluni/src/test/artrun
+++ b/ojluni/src/test/artrun
@@ -62,27 +62,39 @@
if [[ -z $ANDROID_ROOT ]]; then
# Already set to /system for actual android devices
- ANDROID_ROOT=$ANDROID_HOST_OUT
+ ANDROID_ROOT="$ANDROID_HOST_OUT"
fi
-LIBDIR=$(find_libdir)
-LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR
+LIBDIR="$(find_libdir)"
+LD_LIBRARY_PATH="$ANDROID_ROOT/$LIBDIR"
DEBUG_OPTION=""
-
DELETE_ANDROID_DATA=false
# If ANDROID_DATA is the system ANDROID_DATA or is not set, use our own,
# and ensure we delete it at the end.
if [ "$ANDROID_DATA" = "/data" ] || [ "$ANDROID_DATA" = "" ]; then
- ANDROID_DATA=$PWD/android-data$$
- IMAGE_DIRECTORY=$ANDROID_DATA/image
+ # TODO: use /data/tmp/... for android, and mktemp for host
+ #ANDROID_DATA=$PWD/android-data$$
+ ANDROID_DATA="$(mktemp -q -d -t "$(basename "$0").XXXXXX")"
+ IMAGE_DIRECTORY="$ANDROID_DATA/image"
mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64}
mkdir -p $IMAGE_DIRECTORY
DELETE_ANDROID_DATA=true
fi
+# Clean up the temporary files we made earlier on.
+function finish {
+ if $DELETE_ANDROID_DATA; then
+ [[ -d $ANDROID_DATA ]] && rm -rf "$ANDROID_DATA"
+ fi
+}
-IMAGE_LOCATION=$IMAGE_DIRECTORY/core-extrabootclasspath.art
+trap finish EXIT
+# Dummy image location name. Art ignores the bootclasspath setting if a boot image
+# already exists, so we force it to create a new boot image with our correct bootclasspath.
+IMAGE_LOCATION="$IMAGE_DIRECTORY/core-extrabootclasspath.art"
+
+# TODO: Get this list from somewhere else, a makefile perhaps?
BOOT_DEXJARS=(
bouncycastle-hostdex.jar
apache-xml-hostdex.jar
@@ -90,7 +102,7 @@
core-libart-hostdex.jar
core-lambda-stubs-hostdex.jar
conscrypt-hostdex.jar
-core-ojtests-hostdex.jar
+core-ojtests-hostdex.jar # This is the *one* addition that makes our OJ tests actually run. The rest of these are standard jars on the bootclasspath.
core-oj-hostdex.jar
okhttp-hostdex.jar)
@@ -124,3 +136,6 @@
-Ximage:$IMAGE_LOCATION \
$DEBUG_OPTION \
"$@"
+
+
+temp_dir="$(mktemp -q -d -t "$(basename "$0").XXXXXX")"
diff --git a/ojluni/src/test/artrun-testng b/ojluni/src/test/artrun-testng
index 93c9b3d..f5aa95d 100755
--- a/ojluni/src/test/artrun-testng
+++ b/ojluni/src/test/artrun-testng
@@ -14,4 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-./artrun org.testng.TestNG -verbose 3 ./testng.xml
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+$DIR/artrun -Xmx512m org.testng.TestNG -verbose 3 "$DIR/testng.xml"
diff --git a/ojluni/src/test/dist/test-src.zip b/ojluni/src/test/dist/test-src.zip
new file mode 100644
index 0000000..3d65f35
--- /dev/null
+++ b/ojluni/src/test/dist/test-src.zip
Binary files differ
diff --git a/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatefulTestOp.java b/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatefulTestOp.java
index 5414cfd..904b4e5 100644
--- a/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatefulTestOp.java
+++ b/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatefulTestOp.java
@@ -37,18 +37,18 @@
case REFERENCE:
return new ReferencePipeline.StatefulOp<Object, T>(upstream, op.inputShape(), op.opGetFlags()) {
@Override
- Sink opWrapSink(int flags, Sink sink) {
+ public Sink opWrapSink(int flags, Sink sink) {
return op.opWrapSink(flags, isParallel(), sink);
}
@Override
- <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
+ public <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
Spliterator<P_IN> spliterator) {
return op.opEvaluateParallelLazy(helper, spliterator);
}
@Override
- <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+ public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
Spliterator<P_IN> spliterator,
IntFunction<T[]> generator) {
return op.opEvaluateParallel(helper, spliterator, generator);
@@ -57,18 +57,18 @@
case INT_VALUE:
return new IntPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
@Override
- Sink opWrapSink(int flags, Sink sink) {
+ public Sink opWrapSink(int flags, Sink sink) {
return op.opWrapSink(flags, isParallel(), sink);
}
@Override
- <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
+ public <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
Spliterator<P_IN> spliterator) {
return op.opEvaluateParallelLazy(helper, spliterator);
}
@Override
- <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
+ public <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
Spliterator<P_IN> spliterator,
IntFunction<Integer[]> generator) {
return (Node<Integer>) op.opEvaluateParallel(helper, spliterator, generator);
@@ -77,18 +77,18 @@
case LONG_VALUE:
return new LongPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
@Override
- Sink opWrapSink(int flags, Sink sink) {
+ public Sink opWrapSink(int flags, Sink sink) {
return op.opWrapSink(flags, isParallel(), sink);
}
@Override
- <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
+ public <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
Spliterator<P_IN> spliterator) {
return op.opEvaluateParallelLazy(helper, spliterator);
}
@Override
- <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
+ public <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
Spliterator<P_IN> spliterator,
IntFunction<Long[]> generator) {
return (Node<Long>) op.opEvaluateParallel(helper, spliterator, generator);
@@ -97,18 +97,18 @@
case DOUBLE_VALUE:
return new DoublePipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
@Override
- Sink opWrapSink(int flags, Sink sink) {
+ public Sink opWrapSink(int flags, Sink sink) {
return op.opWrapSink(flags, isParallel(), sink);
}
@Override
- <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
+ public <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
Spliterator<P_IN> spliterator) {
return op.opEvaluateParallelLazy(helper, spliterator);
}
@Override
- <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
+ public <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
Spliterator<P_IN> spliterator,
IntFunction<Double[]> generator) {
return (Node<Double>) op.opEvaluateParallel(helper, spliterator, generator);
diff --git a/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatelessTestOp.java b/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatelessTestOp.java
index 77460b7..3a6194b 100644
--- a/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatelessTestOp.java
+++ b/ojluni/src/test/java/util/stream/bootlib/java/util/stream/StatelessTestOp.java
@@ -47,14 +47,14 @@
case LONG_VALUE:
return new LongPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
@Override
- Sink opWrapSink(int flags, Sink sink) {
+ public Sink opWrapSink(int flags, Sink sink) {
return op.opWrapSink(flags, isParallel(), sink);
}
};
case DOUBLE_VALUE:
return new DoublePipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
@Override
- Sink opWrapSink(int flags, Sink sink) {
+ public Sink opWrapSink(int flags, Sink sink) {
return op.opWrapSink(flags, isParallel(), sink);
}
};
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/MapTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/MapTest.java
index 74efed5..7c42e16 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/MapTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/MapTest.java
@@ -23,11 +23,12 @@
package org.openjdk.tests.java.util;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.stream.LambdaTestHelpers;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectionAndMapModifyStreamTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectionAndMapModifyStreamTest.java
index 9a74214..9f1ed75 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectionAndMapModifyStreamTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectionAndMapModifyStreamTest.java
@@ -22,6 +22,8 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
@@ -35,7 +37,6 @@
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.function.Supplier;
-import java.util.stream.LambdaTestHelpers;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatOpTest.java
index 43c5134..175b93c 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatOpTest.java
@@ -22,20 +22,20 @@
*/
package org.openjdk.tests.java.util.stream;
-import java.util.Spliterator;
-import java.util.stream.BaseStream;
-import java.util.stream.OpTestCase;
-import java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
import org.testng.annotations.Test;
+import java.util.Spliterator;
+import java.util.stream.BaseStream;
import java.util.stream.Stream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.DoubleStream;
-import java.util.stream.TestData;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
import static org.testng.Assert.assertEquals;
/**
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatTest.java
index cac59c2..4cd8b11 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ConcatTest.java
@@ -41,7 +41,7 @@
import java.util.stream.LongStream;
import java.util.stream.Stream;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
import static org.testng.Assert.*;
@Test
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java
index 5bf2876..38ec1ed 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java
@@ -29,17 +29,19 @@
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.DoubleStream;
-import java.util.stream.DoubleStreamTestDataProvider;
import java.util.stream.IntStream;
-import java.util.stream.IntStreamTestDataProvider;
import java.util.stream.LongStream;
-import java.util.stream.LongStreamTestDataProvider;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
import org.testng.annotations.Test;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java
index f59a4f3..03ae74c 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java
@@ -24,6 +24,12 @@
import org.testng.annotations.Test;
+import java.util.Spliterator;
+import org.openjdk.testlib.java.util.stream.CollectorOps;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
@@ -32,18 +38,14 @@
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
-import java.util.stream.CollectorOps;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* DistinctOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
index cbd9534..499d5e8 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
@@ -22,15 +22,27 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
-import java.util.stream.*;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* ExplodeOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FilterOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FilterOpTest.java
index 12ff052..0827e42 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FilterOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FilterOpTest.java
@@ -22,14 +22,24 @@
*/
package org.openjdk.tests.java.util.stream;
-import java.util.Collection;
-import java.util.stream.*;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
import org.testng.annotations.Test;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* FilterOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindAnyOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindAnyOpTest.java
index 64a9240..55cfdbc 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindAnyOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindAnyOpTest.java
@@ -22,15 +22,27 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.*;
import java.util.function.BiConsumer;
-import java.util.stream.*;
+import java.util.function.Function;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
-import java.util.function.Function;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindFirstOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindFirstOpTest.java
index 02e3d07..256933e 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindFirstOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/FindFirstOpTest.java
@@ -22,14 +22,20 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.*;
import java.util.*;
-import java.util.stream.*;
+
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
import java.util.function.Function;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java
index e7337e6..2f00461 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java
@@ -24,14 +24,28 @@
import org.testng.annotations.Test;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
-import java.util.stream.*;
-import static java.util.stream.LambdaTestHelpers.countTo;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
+
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* ForEachOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/GroupByOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/GroupByOpTest.java
index dc9e197..3433020 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/GroupByOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/GroupByOpTest.java
@@ -22,6 +22,11 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -33,22 +38,18 @@
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
-import java.util.stream.LambdaTestHelpers;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.countTo;
-import static java.util.stream.LambdaTestHelpers.mDoubler;
-import static java.util.stream.LambdaTestHelpers.mId;
-import static java.util.stream.LambdaTestHelpers.mZero;
-import static java.util.stream.LambdaTestHelpers.pEven;
-import static java.util.stream.LambdaTestHelpers.pFalse;
-import static java.util.stream.LambdaTestHelpers.pOdd;
-import static java.util.stream.LambdaTestHelpers.pTrue;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.countTo;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.mDoubler;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.mId;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.mZero;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pFalse;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pOdd;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pTrue;
/**
* GroupByOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java
index 61f2e29..a01c3ef 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java
@@ -25,6 +25,15 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestScenario;
+import org.openjdk.testlib.java.util.stream.IntStreamTestScenario;
+import org.openjdk.testlib.java.util.stream.LongStreamTestScenario;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.StreamTestScenario;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -34,19 +43,12 @@
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.DoubleStream;
-import java.util.stream.DoubleStreamTestScenario;
import java.util.stream.IntStream;
-import java.util.stream.IntStreamTestScenario;
-import java.util.stream.LambdaTestHelpers;
import java.util.stream.LongStream;
-import java.util.stream.LongStreamTestScenario;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import java.util.stream.StreamTestScenario;
-import java.util.stream.TestData;
-import static java.util.stream.LambdaTestHelpers.assertUnique;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.assertUnique;
@Test
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntReduceTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntReduceTest.java
index baf9007..515d86e 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntReduceTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntReduceTest.java
@@ -22,16 +22,17 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.stream.IntStream;
-import java.util.stream.IntStreamTestDataProvider;
-import java.util.stream.OpTestCase;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.OptionalInt;
-import java.util.stream.TestData;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
public class IntReduceTest extends OpTestCase {
public void testReduce() {
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java
index 51d1362..39071a3 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java
@@ -22,8 +22,20 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.Collection;
-import java.util.stream.*;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
@@ -31,7 +43,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import static java.util.stream.LambdaTestHelpers.assertCountSum;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.assertCountSum;
/**
* SliceOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntUniqOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntUniqOpTest.java
index 3ec5d21..005c350 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntUniqOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntUniqOpTest.java
@@ -22,13 +22,20 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.Collection;
-import java.util.stream.*;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.assertCountSum;
-import static java.util.stream.LambdaTestHelpers.assertUnique;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.assertCountSum;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.assertUnique;
/**
* UniqOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java
index 4f7aaf6..2677ad2 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java
@@ -22,11 +22,24 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import org.testng.annotations.Test;
-import java.util.stream.*;
+import java.util.Spliterator;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* MapOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java
index dc825da..c3ad512 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java
@@ -22,6 +22,14 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -36,36 +44,30 @@
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.DoubleStream;
-import java.util.stream.DoubleStreamTestDataProvider;
import java.util.stream.IntStream;
-import java.util.stream.IntStreamTestDataProvider;
import java.util.stream.LongStream;
-import java.util.stream.LongStreamTestDataProvider;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.countTo;
-import static java.util.stream.LambdaTestHelpers.dpEven;
-import static java.util.stream.LambdaTestHelpers.dpFalse;
-import static java.util.stream.LambdaTestHelpers.dpOdd;
-import static java.util.stream.LambdaTestHelpers.dpTrue;
-import static java.util.stream.LambdaTestHelpers.ipEven;
-import static java.util.stream.LambdaTestHelpers.ipFalse;
-import static java.util.stream.LambdaTestHelpers.ipOdd;
-import static java.util.stream.LambdaTestHelpers.ipTrue;
-import static java.util.stream.LambdaTestHelpers.lpEven;
-import static java.util.stream.LambdaTestHelpers.lpFalse;
-import static java.util.stream.LambdaTestHelpers.lpOdd;
-import static java.util.stream.LambdaTestHelpers.lpTrue;
-import static java.util.stream.LambdaTestHelpers.pEven;
-import static java.util.stream.LambdaTestHelpers.pFalse;
-import static java.util.stream.LambdaTestHelpers.pOdd;
-import static java.util.stream.LambdaTestHelpers.pTrue;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.countTo;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.dpEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.dpFalse;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.dpOdd;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.dpTrue;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.ipEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.ipFalse;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.ipOdd;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.ipTrue;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.lpEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.lpFalse;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.lpOdd;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.lpTrue;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pFalse;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pOdd;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pTrue;
/**
* MatchOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java
index eed4a82..6eb6b72 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java
@@ -22,14 +22,27 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
-import java.util.stream.*;
+
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.countTo;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.countTo;
/**
* MinMaxTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveAverageOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveAverageOpTest.java
index 82491e5..0ceee6b 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveAverageOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveAverageOpTest.java
@@ -22,6 +22,13 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.stream.*;
import org.testng.annotations.Test;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java
index 6f2822f9..e002076 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java
@@ -22,7 +22,19 @@
*/
package org.openjdk.tests.java.util.stream;
-import java.util.stream.*;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java
index 20ae203..5ccffcc 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/RangeTest.java
@@ -22,15 +22,16 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.SpliteratorTestHelper;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.Arrays;
import java.util.Optional;
import java.util.Spliterator;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
-import java.util.stream.OpTestCase;
-import java.util.stream.SpliteratorTestHelper;
import java.util.stream.Stream;
-import java.util.stream.TestData;
import org.testng.annotations.Test;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceByOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceByOpTest.java
index 3fcb469..0c3e925 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceByOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceByOpTest.java
@@ -22,20 +22,21 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.List;
-import java.util.stream.LambdaTestHelpers;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
-import java.util.stream.StreamTestDataProvider;
import org.testng.annotations.Test;
import java.util.HashSet;
import java.util.Map;
-import java.util.stream.TestData;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.reducing;
-import static java.util.stream.LambdaTestHelpers.*;
/**
* ReduceByOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceTest.java
index fd4c687..60be124 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ReduceTest.java
@@ -22,16 +22,17 @@
*/
package org.openjdk.tests.java.util.stream;
-import java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.stream.Stream;
-import java.util.stream.StreamTestDataProvider;
import org.testng.annotations.Test;
import java.util.List;
import java.util.Optional;
-import java.util.stream.TestData;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* ReduceOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SequentialOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SequentialOpTest.java
index efa5c62..263adca 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SequentialOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SequentialOpTest.java
@@ -22,9 +22,11 @@
*/
package org.openjdk.tests.java.util.stream;
-import java.util.stream.LambdaTestHelpers;
-import java.util.stream.OpTestCase;
-import java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import org.testng.annotations.Test;
import java.util.Iterator;
@@ -35,7 +37,6 @@
import java.util.function.UnaryOperator;
import java.util.Spliterator;
import java.util.stream.Stream;
-import java.util.stream.TestData;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java
index 44499d0..3d84d9a 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java
@@ -22,6 +22,11 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import org.testng.annotations.Test;
import java.util.*;
@@ -31,15 +36,11 @@
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
-import java.util.stream.LambdaTestHelpers;
import java.util.stream.LongStream;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* SliceOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java
index 3ca690e..6df240d 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java
@@ -24,6 +24,12 @@
import org.testng.annotations.Test;
+import org.openjdk.testlib.java.util.stream.CollectorOps;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+import org.openjdk.testlib.java.util.stream.*;
+
import java.util.*;
import java.util.Spliterators;
import java.util.concurrent.atomic.AtomicInteger;
@@ -31,9 +37,14 @@
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
-import java.util.stream.*;
+import java.util.stream.BaseStream;
+import java.util.stream.DoubleStream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* SortedOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SpliteratorTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SpliteratorTest.java
index d69c585..2664edb 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SpliteratorTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SpliteratorTest.java
@@ -24,12 +24,14 @@
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.SpliteratorTestHelper;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+
import java.util.function.Supplier;
import java.util.Spliterator;
-import java.util.stream.*;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java
index d8d46fd..e70ee00 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java
@@ -22,6 +22,11 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -31,11 +36,8 @@
import java.util.function.Function;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
-import java.util.stream.LambdaTestHelpers;
import java.util.stream.LongStream;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
-import java.util.stream.TestData;
import static java.util.stream.Collectors.toList;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamCloseTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamCloseTest.java
index 51ffd4b..a29ab9c 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamCloseTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamCloseTest.java
@@ -22,13 +22,14 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+
import java.util.Arrays;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.countTo;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.countTo;
/**
* StreamCloseTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamLinkTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamLinkTest.java
index b4cae89..09554f3 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamLinkTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamLinkTest.java
@@ -22,7 +22,20 @@
*/
package org.openjdk.tests.java.util.stream;
-import java.util.stream.*;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
+import java.util.stream.BaseStream;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java
index f373978..7be1836 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java
@@ -22,6 +22,15 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.SpliteratorTestHelper;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@@ -33,30 +42,22 @@
import java.util.function.LongConsumer;
import java.util.function.UnaryOperator;
import java.util.stream.DoubleStream;
-import java.util.stream.DoubleStreamTestDataProvider;
import java.util.stream.IntStream;
-import java.util.stream.IntStreamTestDataProvider;
-import java.util.stream.LambdaTestHelpers;
import java.util.stream.LongStream;
-import java.util.stream.LongStreamTestDataProvider;
-import java.util.stream.OpTestCase;
-import java.util.stream.SpliteratorTestHelper;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
import org.testng.Assert;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.countTo;
-import static java.util.stream.LambdaTestHelpers.dpEven;
-import static java.util.stream.LambdaTestHelpers.ipEven;
-import static java.util.stream.LambdaTestHelpers.irDoubler;
-import static java.util.stream.LambdaTestHelpers.lpEven;
-import static java.util.stream.LambdaTestHelpers.mDoubler;
-import static java.util.stream.LambdaTestHelpers.pEven;
-import static java.util.stream.LambdaTestHelpers.permuteStreamFunctions;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.countTo;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.dpEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.ipEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.irDoubler;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.lpEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.mDoubler;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.pEven;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.permuteStreamFunctions;
@Test
public class StreamSpliteratorTest extends OpTestCase {
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SummaryStatisticsTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SummaryStatisticsTest.java
index 3850b83..9d32048 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SummaryStatisticsTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SummaryStatisticsTest.java
@@ -22,17 +22,18 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+
import java.util.ArrayList;
import java.util.DoubleSummaryStatistics;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.LongSummaryStatistics;
import java.util.stream.Collectors;
-import java.util.stream.OpTestCase;
import org.testng.annotations.Test;
-import static java.util.stream.LambdaTestHelpers.countTo;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.countTo;
/**
* TestSummaryStatistics
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TabulatorsTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TabulatorsTest.java
index f539df5..486a9cf 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TabulatorsTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TabulatorsTest.java
@@ -22,6 +22,8 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -44,12 +46,7 @@
import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.Collectors;
-import java.util.stream.LambdaTestHelpers;
-import java.util.stream.OpTestCase;
import java.util.stream.Stream;
-import java.util.stream.StreamOpFlagTestHelper;
-import java.util.stream.StreamTestDataProvider;
-import java.util.stream.TestData;
import org.testng.annotations.Test;
@@ -63,9 +60,9 @@
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
-import static java.util.stream.LambdaTestHelpers.assertContents;
-import static java.util.stream.LambdaTestHelpers.assertContentsUnordered;
-import static java.util.stream.LambdaTestHelpers.mDoubler;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.assertContents;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.assertContentsUnordered;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.mDoubler;
/**
* TabulatorsTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TeeOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TeeOpTest.java
index 777158f..b2f0143 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TeeOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/TeeOpTest.java
@@ -22,11 +22,23 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import java.util.function.Consumer;
import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer;
import java.util.function.LongConsumer;
-import java.util.stream.*;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
import org.testng.annotations.Test;
@@ -34,7 +46,7 @@
import java.util.Collections;
import java.util.List;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
/**
* TeeOpTest
diff --git a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ToArrayOpTest.java b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ToArrayOpTest.java
index 5132d9d..00fc8e3 100644
--- a/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ToArrayOpTest.java
+++ b/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ToArrayOpTest.java
@@ -22,13 +22,25 @@
*/
package org.openjdk.tests.java.util.stream;
+import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.LambdaTestHelpers;
+import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.OpTestCase;
+import org.openjdk.testlib.java.util.stream.StreamTestDataProvider;
+import org.openjdk.testlib.java.util.stream.TestData;
+
import org.testng.annotations.Test;
import java.util.*;
import java.util.function.Function;
-import java.util.stream.*;
+import java.util.stream.BaseStream;
+import java.util.stream.Stream;
+import java.util.stream.IntStream;
+import java.util.stream.LongStream;
+import java.util.stream.DoubleStream;
-import static java.util.stream.LambdaTestHelpers.*;
+import static org.openjdk.testlib.java.util.stream.LambdaTestHelpers.*;
import static org.testng.Assert.assertEquals;
diff --git a/ojluni/src/test/java/util/stream/testlib/TEST.properties b/ojluni/src/test/java/util/stream/testlib/TEST.properties
new file mode 100644
index 0000000..64e54e9
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/TEST.properties
@@ -0,0 +1 @@
+# This file identifies root(s) of the test-ng hierarchy.
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/CollectorOps.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/CollectorOps.java
new file mode 100644
index 0000000..7bc56cb
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/CollectorOps.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+import java.util.stream.*;
+
+/** Test helper class for java.util.stream test framework */
+public final class CollectorOps {
+ private CollectorOps() { }
+
+ public static <E_IN> StatefulTestOp<E_IN> collector() {
+ return new StatefulCollector<>(0, StreamShape.REFERENCE);
+ }
+
+ /* Utility classes for collecting output of intermediate pipeline stages */
+ public static class StatefulCollector<E_IN> implements StatefulTestOp<E_IN> {
+ private final int opFlags;
+ private final StreamShape inputShape;
+
+ public StatefulCollector(int opFlags, StreamShape inputShape) {
+ this.opFlags = opFlags;
+ this.inputShape = inputShape;
+ }
+
+ @Override
+ public StreamShape inputShape() {
+ return inputShape;
+ }
+
+ @Override
+ public StreamShape outputShape() {
+ return inputShape;
+ }
+
+ @Override
+ public int opGetFlags() {
+ return opFlags;
+ }
+
+ @Override
+ public Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_IN> sink) {
+ return sink;
+ }
+
+ @Override
+ public <P_IN> Node<E_IN> opEvaluateParallel(PipelineHelper<E_IN> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<E_IN[]> generator) {
+ return helper.evaluate(spliterator, false, generator);
+ }
+ }
+
+ public static class TestParallelSizedOp<T> extends StatefulCollector<T> {
+ public TestParallelSizedOp() {
+ this(StreamShape.REFERENCE);
+ }
+
+ protected TestParallelSizedOp(StreamShape shape) {
+ super(0, shape);
+ }
+
+ @Override
+ public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<T[]> generator) {
+ int flags = helper.getStreamAndOpFlags();
+
+ Assert.assertTrue(StreamOpFlag.SIZED.isKnown(flags));
+ return super.opEvaluateParallel(helper, spliterator, generator);
+ }
+
+ public static class OfInt extends TestParallelSizedOp<Integer> {
+ public OfInt() {
+ super(StreamShape.INT_VALUE);
+ }
+ }
+
+ public static class OfLong extends TestParallelSizedOp<Long> {
+ public OfLong() {
+ super(StreamShape.LONG_VALUE);
+ }
+ }
+
+ public static class OfDouble extends TestParallelSizedOp<Double> {
+ public OfDouble() {
+ super(StreamShape.DOUBLE_VALUE);
+ }
+ }
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/DoubleStreamTestDataProvider.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/DoubleStreamTestDataProvider.java
new file mode 100644
index 0000000..700d9c9
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/DoubleStreamTestDataProvider.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+import java.util.stream.*;
+
+/** TestNG DataProvider for double-valued streams */
+public class DoubleStreamTestDataProvider {
+ private static final double[] to0 = new double[0];
+ private static final double[] to1 = new double[1];
+ private static final double[] to10 = new double[10];
+ private static final double[] to100 = new double[100];
+ private static final double[] to1000 = new double[1000];
+ private static final double[] reversed = new double[100];
+ private static final double[] ones = new double[100];
+ private static final double[] twice = new double[200];
+ private static final double[] pseudoRandom;
+
+ private static final Object[][] testData;
+ private static final Object[][] spliteratorTestData;
+
+ static {
+ double[][] arrays = {to0, to1, to10, to100, to1000};
+ for (double[] arr : arrays) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = i;
+ }
+ }
+ for (int i = 0; i < reversed.length; i++) {
+ reversed[i] = reversed.length - i;
+ }
+ for (int i = 0; i < ones.length; i++) {
+ ones[i] = 1;
+ }
+ System.arraycopy(to100, 0, twice, 0, to100.length);
+ System.arraycopy(to100, 0, twice, to100.length, to100.length);
+ pseudoRandom = new double[LambdaTestHelpers.LONG_STRING.length()];
+ for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+ pseudoRandom[i] = (double) LambdaTestHelpers.LONG_STRING.charAt(i);
+ }
+ }
+
+ static final Object[][] arrays = {
+ {"empty", to0},
+ {"0..1", to1},
+ {"0..10", to10},
+ {"0..100", to100},
+ {"0..1000", to1000},
+ {"100x[1]", ones},
+ {"2x[0..100]", twice},
+ {"reverse 0..100", reversed},
+ {"pseudorandom", pseudoRandom}
+ };
+
+ static {
+ {
+ List<Object[]> list = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final double[] doubles = (double[]) data[1];
+
+ list.add(new Object[]{"array:" + name,
+ TestData.Factory.ofArray("array:" + name, doubles)});
+
+ SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+ for (double i : doubles) {
+ isl.accept(i);
+ }
+ list.add(new Object[]{"SpinedList:" + name,
+ TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+ }
+ testData = list.toArray(new Object[0][]);
+ }
+
+ {
+ List<Object[]> spliterators = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final double[] doubles = (double[]) data[1];
+
+ SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+ for (double i : doubles) {
+ isl.accept(i);
+ }
+
+ spliterators.add(splitDescr("Arrays.s(array):" + name,
+ () -> Arrays.spliterator(doubles)));
+ spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+ () -> Arrays.spliterator(doubles, 0, doubles.length / 2)));
+
+ spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+ () -> isl.spliterator()));
+
+ spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+ () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0)));
+ spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+ () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+ // Need more!
+ }
+ spliteratorTestData = spliterators.toArray(new Object[0][]);
+ }
+
+ }
+
+ static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfDouble> s) {
+ return new Object[] { description, s };
+ }
+
+ // Return an array of ( String name, DoubleStreamTestData )
+ @DataProvider(name = "DoubleStreamTestData")
+ public static Object[][] makeDoubleStreamTestData() {
+ return testData;
+ }
+
+ // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
+ @DataProvider(name = "DoubleSpliterator")
+ public static Object[][] spliteratorProvider() {
+ return spliteratorTestData;
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/DoubleStreamTestScenario.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/DoubleStreamTestScenario.java
new file mode 100644
index 0000000..cdaf01d
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/DoubleStreamTestScenario.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2013, 2015, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+
+import org.openjdk.testlib.java.util.stream.FlagDeclaringOp;
+
+import java.util.stream.*;
+
+/**
+ * Test scenarios for double streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results. Each scenario describes a different way of computing the
+ * stream contents. The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+ STREAM_FOR_EACH_WITH_CLOSE(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ DoubleStream s = m.apply(data.stream());
+ if (s.isParallel()) {
+ s = s.sequential();
+ }
+ s.forEach(b);
+ s.close();
+ }
+ },
+
+ STREAM_TO_ARRAY(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ for (double t : m.apply(data.stream()).toArray()) {
+ b.accept(t);
+ }
+ }
+ },
+
+ STREAM_ITERATOR(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ for (PrimitiveIterator.OfDouble seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+ b.accept(seqIter.nextDouble());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ for (Spliterator.OfDouble spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) {
+ }
+ }
+ },
+
+ // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+ STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR_FOREACH(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ m.apply(data.stream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ m.apply(data.parallelStream()).sequential().forEach(b);
+ }
+ },
+
+ // Wrap as parallel stream + forEachOrdered
+ PAR_STREAM_FOR_EACH_ORDERED(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ // @@@ Want to explicitly select ordered equalator
+ m.apply(data.parallelStream()).forEachOrdered(b);
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ for (Spliterator.OfDouble spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) {
+ }
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR_FOREACH(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ PAR_STREAM_TO_ARRAY(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ for (double t : m.apply(data.parallelStream()).toArray())
+ b.accept(t);
+ }
+ },
+
+ // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+ PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ DoubleStream s = m.apply(data.parallelStream());
+ Spliterator.OfDouble sp = s.spliterator();
+ DoubleStream ss = StreamSupport.doubleStream(() -> sp,
+ StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+ | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+ for (double t : ss.toArray())
+ b.accept(t);
+ }
+ },
+
+ PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ DoubleStream pipe2 = m.apply(pipe1);
+
+ for (double t : pipe2.toArray())
+ b.accept(t);
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing
+ PAR_STREAM_FOR_EACH(true, false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ m.apply(data.parallelStream()).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+ PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ m.apply(pipe1).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+ ;
+
+ // The set of scenarios that clean the SIZED flag
+ public static final Set<DoubleStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+ EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+ private boolean isParallel;
+
+ private final boolean isOrdered;
+
+ DoubleStreamTestScenario(boolean isParallel) {
+ this(isParallel, true);
+ }
+
+ DoubleStreamTestScenario(boolean isParallel, boolean isOrdered) {
+ this.isParallel = isParallel;
+ this.isOrdered = isOrdered;
+ }
+
+ public StreamShape getShape() {
+ return StreamShape.DOUBLE_VALUE;
+ }
+
+ public boolean isParallel() {
+ return isParallel;
+ }
+
+ public boolean isOrdered() {
+ return isOrdered;
+ }
+
+ public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+ _run(data, (DoubleConsumer) b, (Function<S_IN, DoubleStream>) m);
+ }
+
+ abstract <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m);
+
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/FlagDeclaringOp.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/FlagDeclaringOp.java
new file mode 100644
index 0000000..ecfeed2
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/FlagDeclaringOp.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.stream.Sink;
+import java.util.stream.StreamShape;
+
+/**
+ * An operation that injects or clears flags but otherwise performs no operation on elements.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class FlagDeclaringOp<T> implements StatelessTestOp<T, T> {
+ private final int flags;
+ private final StreamShape shape;
+
+ public FlagDeclaringOp(int flags) {
+ this(flags, StreamShape.REFERENCE);
+ }
+
+ public FlagDeclaringOp(int flags, StreamShape shape) {
+ this.flags = flags;
+ this.shape = shape;
+ }
+
+ @Override
+ public StreamShape outputShape() {
+ return shape;
+ }
+
+ @Override
+ public StreamShape inputShape() {
+ return shape;
+ }
+
+ @Override
+ public int opGetFlags() {
+ return flags;
+ }
+
+ @Override
+ public Sink<T> opWrapSink(int flags, boolean parallel, Sink sink) {
+ return sink;
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntStreamTestDataProvider.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntStreamTestDataProvider.java
new file mode 100644
index 0000000..972cf31
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntStreamTestDataProvider.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+import java.util.stream.*;
+
+/** TestNG DataProvider for int-valued streams */
+public class IntStreamTestDataProvider {
+ private static final int[] to0 = new int[0];
+ private static final int[] to1 = new int[1];
+ private static final int[] to10 = new int[10];
+ private static final int[] to100 = new int[100];
+ private static final int[] to1000 = new int[1000];
+ private static final int[] reversed = new int[100];
+ private static final int[] ones = new int[100];
+ private static final int[] twice = new int[200];
+ private static final int[] pseudoRandom;
+
+ private static final Object[][] testData;
+ private static final Object[][] spliteratorTestData;
+
+ static {
+ int[][] arrays = {to0, to1, to10, to100, to1000};
+ for (int[] arr : arrays) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = i;
+ }
+ }
+ for (int i = 0; i < reversed.length; i++) {
+ reversed[i] = reversed.length - i;
+ }
+ for (int i = 0; i < ones.length; i++) {
+ ones[i] = 1;
+ }
+ System.arraycopy(to100, 0, twice, 0, to100.length);
+ System.arraycopy(to100, 0, twice, to100.length, to100.length);
+ pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
+ for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+ pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+ }
+ }
+
+ static final Object[][] arrays = {
+ {"empty", to0},
+ {"0..1", to1},
+ {"0..10", to10},
+ {"0..100", to100},
+ {"0..1000", to1000},
+ {"100x[1]", ones},
+ {"2x[0..100]", twice},
+ {"reverse 0..100", reversed},
+ {"pseudorandom", pseudoRandom}
+ };
+
+ static {
+ {
+ List<Object[]> list = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final int[] ints = (int[]) data[1];
+
+ list.add(new Object[]{"array:" +
+ name, TestData.Factory.ofArray("array:" + name, ints)});
+
+ SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+ for (int i : ints) {
+ isl.accept(i);
+ }
+ list.add(new Object[]{"SpinedList:" + name,
+ TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+ list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length,
+ () -> IntStream.range(0, ints.length)));
+ list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
+ () -> IntStream.rangeClosed(0, ints.length)));
+ }
+ testData = list.toArray(new Object[0][]);
+ }
+
+ {
+ List<Object[]> spliterators = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final int[] ints = (int[]) data[1];
+
+ SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+ for (int i : ints) {
+ isl.accept(i);
+ }
+
+ spliterators.add(splitDescr("Arrays.s(array):" + name,
+ () -> Arrays.spliterator(ints)));
+ spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+ () -> Arrays.spliterator(ints, 0, ints.length / 2)));
+
+ spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+ () -> isl.spliterator()));
+
+ spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+ () -> Spliterators.spliterator(isl.iterator(), ints.length, 0)));
+ spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+ () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+ spliterators.add(splitDescr("IntStream.intRange(0,l):" + name,
+ () -> IntStream.range(0, ints.length).spliterator()));
+ spliterators.add(splitDescr("IntStream.intRangeClosed(0,l):" + name,
+ () -> IntStream.rangeClosed(0, ints.length).spliterator()));
+ // Need more!
+ }
+ spliteratorTestData = spliterators.toArray(new Object[0][]);
+ }
+
+ }
+
+ static <T> Object[] streamDataDescr(String description, Supplier<IntStream> s) {
+ return new Object[] { description, TestData.Factory.ofIntSupplier(description, s) };
+ }
+
+ static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfInt> s) {
+ return new Object[] { description, s };
+ }
+
+ // Return an array of ( String name, IntStreamTestData )
+ @DataProvider(name = "IntStreamTestData")
+ public static Object[][] makeIntStreamTestData() {
+ return testData;
+ }
+
+ // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
+ @DataProvider(name = "IntSpliterator")
+ public static Object[][] spliteratorProvider() {
+ return spliteratorTestData;
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntStreamTestScenario.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntStreamTestScenario.java
new file mode 100644
index 0000000..8b87dc5
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntStreamTestScenario.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2012, 2015, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+import java.util.stream.*;
+
+import org.openjdk.testlib.java.util.stream.FlagDeclaringOp;
+
+/**
+ * Test scenarios for int streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results. Each scenario describes a different way of computing the
+ * stream contents. The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+ STREAM_FOR_EACH_WITH_CLOSE(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ IntStream s = m.apply(data.stream());
+ if (s.isParallel()) {
+ s = s.sequential();
+ }
+ s.forEach(b);
+ s.close();
+ }
+ },
+
+ STREAM_TO_ARRAY(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ for (int t : m.apply(data.stream()).toArray()) {
+ b.accept(t);
+ }
+ }
+ },
+
+ STREAM_ITERATOR(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ for (PrimitiveIterator.OfInt seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+ b.accept(seqIter.nextInt());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ for (Spliterator.OfInt spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) {
+ }
+ }
+ },
+
+ // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+ STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR_FOREACH(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ m.apply(data.stream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ m.apply(data.parallelStream()).sequential().forEach(b);
+ }
+ },
+
+ // Wrap as parallel stream + forEachOrdered
+ PAR_STREAM_FOR_EACH_ORDERED(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ // @@@ Want to explicitly select ordered equalator
+ m.apply(data.parallelStream()).forEachOrdered(b);
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ for (Spliterator.OfInt spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) {
+ }
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR_FOREACH(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ PAR_STREAM_TO_ARRAY(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ for (int t : m.apply(data.parallelStream()).toArray())
+ b.accept(t);
+ }
+ },
+
+ // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+ PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ IntStream s = m.apply(data.parallelStream());
+ Spliterator.OfInt sp = s.spliterator();
+ IntStream ss = StreamSupport.intStream(() -> sp,
+ StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+ | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED),
+ true);
+ for (int t : ss.toArray())
+ b.accept(t);
+ }
+ },
+
+ PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ IntStream pipe2 = m.apply(pipe1);
+
+ for (int t : pipe2.toArray())
+ b.accept(t);
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing
+ PAR_STREAM_FOR_EACH(true, false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ m.apply(data.parallelStream()).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+ PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ m.apply(pipe1).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+ ;
+
+ // The set of scenarios that clean the SIZED flag
+ public static final Set<IntStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+ EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+ private final boolean isParallel;
+
+ private final boolean isOrdered;
+
+ IntStreamTestScenario(boolean isParallel) {
+ this(isParallel, true);
+ }
+
+ IntStreamTestScenario(boolean isParallel, boolean isOrdered) {
+ this.isParallel = isParallel;
+ this.isOrdered = isOrdered;
+ }
+
+ public StreamShape getShape() {
+ return StreamShape.INT_VALUE;
+ }
+
+ public boolean isParallel() {
+ return isParallel;
+ }
+
+ public boolean isOrdered() {
+ return isOrdered;
+ }
+
+ public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+ _run(data, (IntConsumer) b, (Function<S_IN, IntStream>) m);
+ }
+
+ abstract <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m);
+
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntermediateTestOp.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntermediateTestOp.java
new file mode 100644
index 0000000..0bba8b8
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/IntermediateTestOp.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.stream.AbstractPipeline;
+
+/**
+ * A base type for test operations
+ */
+interface IntermediateTestOp<E_IN, E_OUT> {
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+ IntermediateTestOp<?, T> op) {
+ if (op instanceof StatelessTestOp)
+ return StatelessTestOp.chain(upstream, (StatelessTestOp) op);
+
+ if (op instanceof StatefulTestOp)
+ return StatefulTestOp.chain(upstream, (StatefulTestOp) op);
+
+ throw new IllegalStateException("Unknown test op type: " + op.getClass().getName());
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LambdaTestHelpers.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LambdaTestHelpers.java
new file mode 100644
index 0000000..1cf37df
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LambdaTestHelpers.java
@@ -0,0 +1,463 @@
+/*
+ * Copyright (c) 1997, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.*;
+import java.util.stream.*;
+import java.util.function.BiConsumer;
+import java.util.function.BiPredicate;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleConsumer;
+import java.util.function.DoublePredicate;
+import java.util.function.Function;
+import java.util.function.IntBinaryOperator;
+import java.util.function.IntConsumer;
+import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
+import java.util.function.IntUnaryOperator;
+import java.util.function.LongBinaryOperator;
+import java.util.function.LongConsumer;
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
+ */
+public class LambdaTestHelpers {
+ public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
+
+ @SuppressWarnings("rawtypes")
+ public static final Consumer bEmpty = x -> { };
+ @SuppressWarnings("rawtypes")
+ public static final IntConsumer bIntEmpty = x -> { };
+ @SuppressWarnings("rawtypes")
+ public static final BiConsumer bBiEmpty = (x,y) -> { };
+ @SuppressWarnings("rawtypes")
+ public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
+ @SuppressWarnings("rawtypes")
+ public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
+ public static final Function<Integer, Integer> mZero = x -> 0;
+ public static final Function<Integer, Integer> mId = x -> x;
+ public static final Function<Integer, Integer> mDoubler = x -> x * 2;
+ public static final Function<Integer, Stream<Integer>> mfId = e -> Collections.singletonList(e).stream();
+ public static final Function<Integer, Stream<Integer>> mfNull = e -> Collections.<Integer>emptyList().stream();
+ public static final Function<Integer, Stream<Integer>> mfLt = e -> {
+ List<Integer> l = new ArrayList<>();
+ for (int i=0; i<e; i++)
+ l.add(i);
+ return l.stream();
+ };
+ public static final ToIntFunction<Integer> imDoubler = x -> x * 2;
+ public static final ToLongFunction<Long> lmDoubler = x -> x * 2;
+ public static final ToDoubleFunction<Double> dmDoubler = x -> x * 2;
+ public static final Predicate<Integer> pFalse = x -> false;
+ public static final Predicate<Integer> pTrue = x -> true;
+ public static final Predicate<Integer> pEven = x -> 0 == x % 2;
+ public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
+ public static final IntPredicate ipFalse = x -> false;
+ public static final IntPredicate ipTrue = x -> true;
+ public static final IntPredicate ipEven = x -> 0 == x % 2;
+ public static final IntPredicate ipOdd = x -> 1 == x % 2;
+ public static final LongPredicate lpFalse = x -> false;
+ public static final LongPredicate lpTrue = x -> true;
+ public static final LongPredicate lpEven = x -> 0 == x % 2;
+ public static final LongPredicate lpOdd = x -> 1 == x % 2;
+ public static final DoublePredicate dpFalse = x -> false;
+ public static final DoublePredicate dpTrue = x -> true;
+ public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
+ public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
+ public static final BinaryOperator<Integer> rPlus = (x, y) -> x+y;
+ public static final BinaryOperator<Integer> rMax = (x, y) -> Math.max(x, y);
+ public static final BinaryOperator<Integer> rMin = (x, y) -> Math.min(x,y);
+ public static final IntBinaryOperator irPlus = (x, y) -> x+y;
+ public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
+ public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
+ public static final IntUnaryOperator irDoubler = x -> x * 2;
+ public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
+ public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
+ public static final Comparator<Integer> cInteger = (a, b) -> Integer.compare(a, b);
+ public static final BiPredicate<?, ?> bipFalse = (x, y) -> false;
+ public static final BiPredicate<?, ?> bipTrue = (x, y) -> true;
+ public static final BiPredicate<Integer, Integer> bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
+ public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
+ public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
+
+ public static final IntFunction<Integer[]> integerArrayGenerator = s -> new Integer[s];
+
+ public static final IntFunction<Object[]> objectArrayGenerator = s -> new Object[s];
+
+ public static final Function<String, Stream<Character>> flattenChars = string -> {
+ List<Character> l = new ArrayList<>();
+ for (int i=0; i<string.length(); i++)
+ l.add(string.charAt(i));
+ return l.stream();
+ };
+
+ public static final Function<String, IntStream> flattenInt
+ = string -> IntStream.range(0, string.length()).map(string::charAt);
+
+ public static <T, R> Function<T, R> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
+ Objects.requireNonNull(predicate);
+
+ return t -> predicate.test(t) ? forTrue : forFalse;
+ }
+
+ public static <T> Function<T, T> identity() {
+ return t -> t;
+ }
+
+ public static<V, T, R> Function<V, R> compose(Function<? super T, ? extends R> after, Function<? super V, ? extends T> before) {
+ Objects.requireNonNull(before);
+ return (V v) -> after.apply(before.apply(v));
+ }
+
+ public static List<Integer> empty() {
+ ArrayList<Integer> list = new ArrayList<>();
+ list.add(null);
+ return list;
+ }
+
+ public static List<Integer> countTo(int n) {
+ return range(1, n);
+ }
+
+ public static List<Integer> range(int l, int u) {
+ ArrayList<Integer> list = new ArrayList<>(u - l + 1);
+ for (int i=l; i<=u; i++) {
+ list.add(i);
+ }
+ return list;
+ }
+
+ public static List<Integer> repeat(int value, int n) {
+ ArrayList<Integer> list = new ArrayList<>(n);
+ for (int i=1; i<=n; i++) {
+ list.add(value);
+ }
+ return list;
+ }
+
+ public static List<Double> asDoubles(List<Integer> integers) {
+ ArrayList<Double> list = new ArrayList<>();
+ for (Integer i : integers) {
+ list.add((double) i);
+ }
+ return list;
+ }
+
+ public static List<Long> asLongs(List<Integer> integers) {
+ ArrayList<Long> list = new ArrayList<>();
+ for (Integer i : integers) {
+ list.add((long) i);
+ }
+ return list;
+ }
+
+ public static void assertCountSum(Stream<? super Integer> it, int count, int sum) {
+ assertCountSum(it.iterator(), count, sum);
+ }
+
+ public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
+ assertCountSum(it.iterator(), count, sum);
+ }
+
+ public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
+ int c = 0;
+ int s = 0;
+ while (it.hasNext()) {
+ int i = (Integer) it.next();
+ c++;
+ s += i;
+ }
+
+ assertEquals(c, count);
+ assertEquals(s, sum);
+ }
+
+ public static void assertConcat(Iterator<Character> it, String result) {
+ StringBuilder sb = new StringBuilder();
+ while (it.hasNext()) {
+ sb.append(it.next());
+ }
+
+ assertEquals(result, sb.toString());
+ }
+
+ public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
+ i = toBoxedList(i).iterator();
+
+ if (!i.hasNext())
+ return;
+ T last = i.next();
+ while (i.hasNext()) {
+ T t = i.next();
+ assertTrue(last.compareTo(t) <= 0);
+ assertTrue(t.compareTo(last) >= 0);
+ last = t;
+ }
+ }
+
+ public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
+ if (i instanceof PrimitiveIterator.OfInt
+ || i instanceof PrimitiveIterator.OfDouble
+ || i instanceof PrimitiveIterator.OfLong) {
+ i = toBoxedList(i).iterator();
+ }
+
+ if (!i.hasNext())
+ return;
+ T last = i.next();
+ while (i.hasNext()) {
+ T t = i.next();
+ assertTrue(comp.compare(last, t) <= 0);
+ assertTrue(comp.compare(t, last) >= 0);
+ last = t;
+ }
+ }
+
+ public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
+ assertSorted(iter.iterator());
+ }
+
+ public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
+ assertSorted(iter.iterator(), comp);
+ }
+
+ public static <T> void assertUnique(Iterable<T> iter) {
+ assertUnique(iter.iterator());
+ }
+
+ public static<T> void assertUnique(Iterator<T> iter) {
+ if (!iter.hasNext()) {
+ return;
+ }
+
+ if (iter instanceof PrimitiveIterator.OfInt
+ || iter instanceof PrimitiveIterator.OfDouble
+ || iter instanceof PrimitiveIterator.OfLong) {
+ iter = toBoxedList(iter).iterator();
+ }
+
+ Set<T> uniq = new HashSet<>();
+ while(iter.hasNext()) {
+ T each = iter.next();
+ assertTrue(!uniq.contains(each), "Not unique");
+ uniq.add(each);
+ }
+ }
+
+ public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
+ if (actual instanceof Collection && expected instanceof Collection) {
+ assertEquals(actual, expected);
+ } else {
+ assertContents(actual.iterator(), expected.iterator());
+ }
+ }
+
+ public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
+ assertEquals(toBoxedList(actual), toBoxedList(expected));
+ }
+
+ @SafeVarargs
+ @SuppressWarnings("varargs")
+ public static<T> void assertContents(Iterator<T> actual, T... expected) {
+ assertContents(actual, Arrays.asList(expected).iterator());
+ }
+
+ /**
+ * The all consuming consumer (rampant capitalist) that can accepting a reference or any primitive value.
+ */
+ private static interface OmnivorousConsumer<T>
+ extends Consumer<T>, IntConsumer, LongConsumer, DoubleConsumer { }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static<T> Consumer<T> toBoxingConsumer(Consumer<? super T> c) {
+ return (Consumer<T>) new OmnivorousConsumer() {
+ @Override
+ public void accept(Object t) {
+ c.accept((T) t);
+ }
+
+ @Override
+ public void accept(int t) {
+ accept((Object) t);
+ }
+
+ @Override
+ public void accept(long t) {
+ accept((Object) t);
+ }
+
+ @Override
+ public void accept(double t) {
+ accept((Object) t);
+ }
+ };
+ }
+
+ /**
+ * Convert an iterator to a list using forEach with an implementation of
+ * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+ *
+ * This ensures equality comparisons for test results do not trip
+ * the boxing trip-wires.
+ */
+ private static<T> List<T> toBoxedList(Iterator<T> it) {
+ List<T> l = new ArrayList<>();
+ it.forEachRemaining(toBoxingConsumer(l::add));
+ return l;
+ }
+
+ /**
+ * Convert a spliterator to a list using forEach with an implementation of
+ * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+ *
+ * This ensures equality comparisons for test results do not trip
+ * the boxing trip-wires.
+ */
+ public static<T> List<T> toBoxedList(Spliterator<T> sp) {
+ List<T> l = new ArrayList<>();
+ sp.forEachRemaining(toBoxingConsumer(l::add));
+ return l;
+ }
+
+ /**
+ * Convert an iterator to a multi-set, represented as a Map, using forEach with an implementation of
+ * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+ *
+ * This ensures equality comparisons for test results do not trip
+ * the boxing trip-wires.
+ */
+ @SuppressWarnings("unchecked")
+ private static<T> Map<T, Integer> toBoxedMultiset(Iterator<T> it) {
+ Map<Object, Integer> result = new HashMap<>();
+
+ it.forEachRemaining(toBoxingConsumer(o -> {
+ if (result.containsKey(o))
+ result.put(o, result.get(o) + 1);
+ else
+ result.put(o, 1);
+ }));
+
+ return (Map<T, Integer>) result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static<T> Map<T, Integer> toBoxedMultiset(Spliterator<T> it) {
+ Map<Object, Integer> result = new HashMap<>();
+
+ it.forEachRemaining(toBoxingConsumer(o -> {
+ if (result.containsKey(o))
+ result.put(o, result.get(o) + 1);
+ else
+ result.put(o, 1);
+ }));
+
+ return (Map<T, Integer>) result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void assertContentsEqual(Object a, Object b) {
+ if (a instanceof Iterable && b instanceof Iterable)
+ assertContents((Iterable) a, (Iterable) b);
+ else
+ assertEquals(a, b);
+ }
+
+ public static<T> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
+ assertContentsUnordered(actual.iterator(), expected.iterator());
+ }
+
+ public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
+ assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
+ }
+
+ public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
+ try {
+ r.run();
+ }
+ catch (AssertionError ae) {
+ AssertionError cloned = new AssertionError(ae.getMessage() + String.format("%n%s", additionalInfo.get()));
+ cloned.setStackTrace(ae.getStackTrace());
+ if (ae.getCause() != null)
+ cloned.initCause(ae.getCause());
+ throw cloned;
+ }
+ }
+
+ public static <T, S extends BaseStream<T, S>>
+ List<Function<S, S>> permuteStreamFunctions(List<Function<S, S>> opFunctions) {
+ List<List<Function<S, S>>> opFunctionPermutations = perm(opFunctions);
+
+ List<Function<S, S>> appliedFunctions = new ArrayList<>();
+ for (List<Function<S, S>> fs : opFunctionPermutations) {
+ Function<S, S> applied = s -> {
+ for (Function<S, S> f : fs) {
+ s = f.apply(s);
+ }
+ return s;
+ };
+ appliedFunctions.add(applied);
+ }
+
+ return appliedFunctions;
+ }
+
+ private static <T> List<T> sub(List<T> l, int index) {
+ List<T> subL = new ArrayList<>(l);
+ subL.remove(index);
+ return subL;
+ }
+
+ public static <T> List<List<T>> perm(List<T> l) {
+ List<List<T>> result = new ArrayList<>();
+ for (int i = 0; i < l.size(); i++) {
+ for (List<T> perm : perm(sub(l, i))) {
+ perm.add(0, l.get(i));
+ result.add(perm);
+ }
+ }
+ result.add(new ArrayList<T>());
+
+ return result;
+ }
+
+ public static String flagsToString(int flags) {
+ StringJoiner sj = new StringJoiner(", ", "StreamOpFlag[", "]");
+ if (StreamOpFlag.DISTINCT.isKnown(flags)) sj.add("IS_DISTINCT");
+ if (StreamOpFlag.ORDERED.isKnown(flags)) sj.add("IS_ORDERED");
+ if (StreamOpFlag.SIZED.isKnown(flags)) sj.add("IS_SIZED");
+ if (StreamOpFlag.SORTED.isKnown(flags)) sj.add("IS_SORTED");
+ if (StreamOpFlag.SHORT_CIRCUIT.isKnown(flags)) sj.add("IS_SHORT_CIRCUIT");
+ return sj.toString();
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LambdaTestMode.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LambdaTestMode.java
new file mode 100644
index 0000000..260068f
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LambdaTestMode.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+/**
+ * Runtime modes of test execution.
+ */
+public enum LambdaTestMode {
+ /**
+ * Execution mode with no particular runtime constraints.
+ */
+ NORMAL,
+
+ /**
+ * Execution mode where tests are executed for testing lambda serialization
+ * and deserialization.
+ *
+ * <p>This mode may be queried by tests or data supplied by data
+ * providers, which cannot otherwise be assigned to the test group
+ * <em>serialization-hostile</em>, to not execute or declare
+ * serialization-hostile code or data.
+ *
+ * <p>This mode is enabled if the boolean system property
+ * {@code org.openjdk.java.util.stream.sand.mode} is declared with a
+ * {@code true} value.
+ */
+ SERIALIZATION;
+
+ /**
+ * {@code true} if tests are executed in the mode for testing lambda
+ * Serialization ANd Deserialization (SAND).
+ */
+ private static final boolean IS_LAMBDA_SERIALIZATION_MODE =
+ Boolean.getBoolean("org.openjdk.java.util.stream.sand.mode");
+
+ /**
+ *
+ * @return the mode of test execution.
+ */
+ public static LambdaTestMode getMode() {
+ return IS_LAMBDA_SERIALIZATION_MODE ? SERIALIZATION : NORMAL;
+ }
+
+ /**
+ *
+ * @return {@code true} if normal test mode.
+ */
+ public static boolean isNormalMode() {
+ return getMode() == NORMAL;
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LoggingTestCase.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LoggingTestCase.java
new file mode 100644
index 0000000..f0bad56
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LoggingTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.testng.Assert;
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * LoggingTestCase
+ *
+ */
+@Test
+public class LoggingTestCase extends Assert {
+ private Map<String, Object> context = new HashMap<>();
+
+ @BeforeMethod
+ public void before() {
+ context.clear();
+ }
+
+ @AfterMethod
+ public void after(ITestResult result) {
+ if (!result.isSuccess()) {
+ List<Object> list = new ArrayList<>();
+ Collections.addAll(list, result.getParameters());
+ list.add(context.toString());
+ result.setParameters(list.toArray(new Object[list.size()]));
+ }
+ }
+
+ protected void setContext(String key, Object value) {
+ context.put(key, value);
+ }
+
+ protected void clearContext(String key) {
+ context.remove(key);
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LongStreamTestDataProvider.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LongStreamTestDataProvider.java
new file mode 100644
index 0000000..63a39e6
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LongStreamTestDataProvider.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+import java.util.stream.*;
+
+/** TestNG DataProvider for long-valued streams */
+public class LongStreamTestDataProvider {
+ private static final long[] to0 = new long[0];
+ private static final long[] to1 = new long[1];
+ private static final long[] to10 = new long[10];
+ private static final long[] to100 = new long[100];
+ private static final long[] to1000 = new long[1000];
+ private static final long[] reversed = new long[100];
+ private static final long[] ones = new long[100];
+ private static final long[] twice = new long[200];
+ private static final long[] pseudoRandom;
+
+ private static final Object[][] testData;
+ private static final Object[][] spliteratorTestData;
+
+ static {
+ long[][] arrays = {to0, to1, to10, to100, to1000};
+ for (long[] arr : arrays) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = i;
+ }
+ }
+ for (int i = 0; i < reversed.length; i++) {
+ reversed[i] = reversed.length - i;
+ }
+ for (int i = 0; i < ones.length; i++) {
+ ones[i] = 1;
+ }
+ System.arraycopy(to100, 0, twice, 0, to100.length);
+ System.arraycopy(to100, 0, twice, to100.length, to100.length);
+ pseudoRandom = new long[LambdaTestHelpers.LONG_STRING.length()];
+ for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+ pseudoRandom[i] = (long) LambdaTestHelpers.LONG_STRING.charAt(i);
+ }
+ }
+
+ static final Object[][] arrays = {
+ {"empty", to0},
+ {"0..1", to1},
+ {"0..10", to10},
+ {"0..100", to100},
+ {"0..1000", to1000},
+ {"100x[1]", ones},
+ {"2x[0..100]", twice},
+ {"reverse 0..100", reversed},
+ {"pseudorandom", pseudoRandom}
+ };
+
+ static {
+ {
+ List<Object[]> list = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final long[] longs = (long[]) data[1];
+
+ list.add(new Object[]{"array:" + name,
+ TestData.Factory.ofArray("array:" + name, longs)});
+
+ SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+ for (long i : longs) {
+ isl.accept(i);
+ }
+ list.add(new Object[]{"SpinedList:" + name,
+ TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+ list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length,
+ () -> LongStream.range(0, longs.length)));
+ list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
+ () -> LongStream.rangeClosed(0, longs.length)));
+ }
+ testData = list.toArray(new Object[0][]);
+ }
+
+ {
+ List<Object[]> spliterators = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final long[] longs = (long[]) data[1];
+
+ SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+ for (long i : longs) {
+ isl.accept(i);
+ }
+
+ spliterators.add(splitDescr("Arrays.s(array):" + name,
+ () -> Arrays.spliterator(longs)));
+ spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+ () -> Arrays.spliterator(longs, 0, longs.length / 2)));
+
+ spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+ () -> isl.spliterator()));
+
+ spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+ () -> Spliterators.spliterator(isl.iterator(), longs.length, 0)));
+ spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+ () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+ spliterators.add(splitDescr("LongStream.longRange(0,l):" + name,
+ () -> LongStream.range(0, longs.length).spliterator()));
+ spliterators.add(splitDescr("LongStream.longRangeClosed(0,l):" + name,
+ () -> LongStream.rangeClosed(0, longs.length).spliterator()));
+ // Need more!
+ }
+ spliteratorTestData = spliterators.toArray(new Object[0][]);
+ }
+
+ }
+
+ static <T> Object[] streamDataDescr(String description, Supplier<LongStream> s) {
+ return new Object[] { description, TestData.Factory.ofLongSupplier(description, s) };
+ }
+
+ static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfLong> s) {
+ return new Object[] { description, s };
+ }
+
+ // Return an array of ( String name, LongStreamTestData )
+ @DataProvider(name = "LongStreamTestData")
+ public static Object[][] makeLongStreamTestData() {
+ return testData;
+ }
+
+ // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
+ @DataProvider(name = "LongSpliterator")
+ public static Object[][] spliteratorProvider() {
+ return spliteratorTestData;
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LongStreamTestScenario.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LongStreamTestScenario.java
new file mode 100644
index 0000000..88b3639
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/LongStreamTestScenario.java
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2013, 2015, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.LongConsumer;
+import java.util.stream.*;
+
+import org.openjdk.testlib.java.util.stream.FlagDeclaringOp;
+
+/**
+ * Test scenarios for long streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results. Each scenario describes a different way of computing the
+ * stream contents. The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+ STREAM_FOR_EACH_WITH_CLOSE(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ LongStream s = m.apply(data.stream());
+ if (s.isParallel()) {
+ s = s.sequential();
+ }
+ s.forEach(b);
+ s.close();
+ }
+ },
+
+ STREAM_TO_ARRAY(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ for (long t : m.apply(data.stream()).toArray()) {
+ b.accept(t);
+ }
+ }
+ },
+
+ STREAM_ITERATOR(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ for (PrimitiveIterator.OfLong seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+ b.accept(seqIter.nextLong());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ for (Spliterator.OfLong spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) {
+ }
+ }
+ },
+
+ // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+ STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR_FOREACH(false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ m.apply(data.stream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ m.apply(data.parallelStream()).sequential().forEach(b);
+ }
+ },
+
+ // Wrap as parallel stream + forEachOrdered
+ PAR_STREAM_FOR_EACH_ORDERED(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ // @@@ Want to explicitly select ordered equalator
+ m.apply(data.parallelStream()).forEachOrdered(b);
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ for (Spliterator.OfLong spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) {
+ }
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR_FOREACH(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ PAR_STREAM_TO_ARRAY(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ for (long t : m.apply(data.parallelStream()).toArray())
+ b.accept(t);
+ }
+ },
+
+ // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+ PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ LongStream s = m.apply(data.parallelStream());
+ Spliterator.OfLong sp = s.spliterator();
+ LongStream ss = StreamSupport.longStream(() -> sp,
+ StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+ | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+ for (long t : ss.toArray())
+ b.accept(t);
+ }
+ },
+
+ PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ LongStream pipe2 = m.apply(pipe1);
+
+ for (long t : pipe2.toArray())
+ b.accept(t);
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing
+ PAR_STREAM_FOR_EACH(true, false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ m.apply(data.parallelStream()).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+ PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+ <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ m.apply(pipe1).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+ ;
+
+ // The set of scenarios that clean the SIZED flag
+ public static final Set<LongStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+ EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+ private boolean isParallel;
+
+ private final boolean isOrdered;
+
+ LongStreamTestScenario(boolean isParallel) {
+ this(isParallel, true);
+ }
+
+ LongStreamTestScenario(boolean isParallel, boolean isOrdered) {
+ this.isParallel = isParallel;
+ this.isOrdered = isOrdered;
+ }
+
+ public StreamShape getShape() {
+ return StreamShape.LONG_VALUE;
+ }
+
+ public boolean isParallel() {
+ return isParallel;
+ }
+
+ public boolean isOrdered() {
+ return isOrdered;
+ }
+
+ public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+ _run(data, (LongConsumer) b, (Function<S_IN, LongStream>) m);
+ }
+
+ abstract <T, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m);
+
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/OpTestCase.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/OpTestCase.java
new file mode 100644
index 0000000..b8c5c63
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/OpTestCase.java
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2012, 2015, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.*;
+
+import org.testng.annotations.Test;
+
+/**
+ * Base class for streams test cases. Provides 'exercise' methods for taking
+ * lambdas that construct and modify streams, and evaluates them in different
+ * ways and asserts that they produce equivalent results.
+ */
+@Test
+public abstract class OpTestCase extends LoggingTestCase {
+
+ private final Map<StreamShape, Set<? extends BaseStreamTestScenario>> testScenarios;
+
+ protected OpTestCase() {
+ testScenarios = new EnumMap<>(StreamShape.class);
+ testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class)));
+ testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class)));
+ testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class)));
+ testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class)));
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static int getStreamFlags(BaseStream s) {
+ return ((AbstractPipeline) s).getStreamFlags();
+ }
+
+ /**
+ * An asserter for results produced when exercising of stream or terminal
+ * tests.
+ *
+ * @param <R> the type of result to assert on
+ */
+ public interface ResultAsserter<R> {
+ /**
+ * Assert a result produced when exercising of stream or terminal
+ * test.
+ *
+ * @param actual the actual result
+ * @param expected the expected result
+ * @param isOrdered true if the pipeline is ordered
+ * @param isParallel true if the pipeline is parallel
+ */
+ void assertResult(R actual, R expected, boolean isOrdered, boolean isParallel);
+ }
+
+ // Exercise stream operations
+
+ public interface BaseStreamTestScenario {
+ StreamShape getShape();
+
+ boolean isParallel();
+
+ boolean isOrdered();
+
+ <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m);
+ }
+
+ protected <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ Collection<U> exerciseOps(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+ return withData(data).stream(m).exercise();
+ }
+
+ // Run multiple versions of exercise(), returning the result of the first, and asserting that others return the same result
+ // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+ @SafeVarargs
+ protected final<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ Collection<U> exerciseOpsMulti(TestData<T, S_IN> data,
+ Function<S_IN, S_OUT>... ms) {
+ Collection<U> result = null;
+ for (Function<S_IN, S_OUT> m : ms) {
+ if (result == null)
+ result = withData(data).stream(m).exercise();
+ else {
+ Collection<U> r2 = withData(data).stream(m).exercise();
+ assertEquals(result, r2);
+ }
+ }
+ return result;
+ }
+
+ // Run multiple versions of exercise() for an Integer stream, returning the result of the first, and asserting that others return the same result
+ // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+ // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+ protected final
+ Collection<Integer> exerciseOpsInt(TestData.OfRef<Integer> data,
+ Function<Stream<Integer>, Stream<Integer>> mRef,
+ Function<IntStream, IntStream> mInt,
+ Function<LongStream, LongStream> mLong,
+ Function<DoubleStream, DoubleStream> mDouble) {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ Function<Stream<Integer>, Stream<Integer>>[] ms = new Function[4];
+ ms[0] = mRef;
+ ms[1] = s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e);
+ ms[2] = s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e);
+ ms[3] = s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e);
+ return exerciseOpsMulti(data, ms);
+ }
+
+ // Run multiple versions of exercise() with multiple terminal operations for all kinds of stream, , and asserting against the expected result
+ // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+ protected final<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ void exerciseTerminalOpsMulti(TestData<T, S_IN> data,
+ R expected,
+ Map<String, Function<S_IN, S_OUT>> streams,
+ Map<String, Function<S_OUT, R>> terminals) {
+ for (Map.Entry<String, Function<S_IN, S_OUT>> se : streams.entrySet()) {
+ setContext("Intermediate stream", se.getKey());
+ for (Map.Entry<String, Function<S_OUT, R>> te : terminals.entrySet()) {
+ setContext("Terminal stream", te.getKey());
+ withData(data)
+ .terminal(se.getValue(), te.getValue())
+ .expectedResult(expected)
+ .exercise();
+
+ }
+ }
+ }
+
+ // Run multiple versions of exercise() with multiple terminal operation for all kinds of stream, and asserting against the expected result
+ // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+ // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+ protected final
+ void exerciseTerminalOpsInt(TestData<Integer, Stream<Integer>> data,
+ Collection<Integer> expected,
+ String desc,
+ Function<Stream<Integer>, Stream<Integer>> mRef,
+ Function<IntStream, IntStream> mInt,
+ Function<LongStream, LongStream> mLong,
+ Function<DoubleStream, DoubleStream> mDouble,
+ Map<String, Function<Stream<Integer>, Collection<Integer>>> terminals) {
+
+ Map<String, Function<Stream<Integer>, Stream<Integer>>> m = new HashMap<>();
+ m.put("Ref " + desc, mRef);
+ m.put("Int " + desc, s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e));
+ m.put("Long " + desc, s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e));
+ m.put("Double " + desc, s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e));
+
+ exerciseTerminalOpsMulti(data, expected, m, terminals);
+ }
+
+
+ protected <T, U, S_OUT extends BaseStream<U, S_OUT>>
+ Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m) {
+ TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+ return withData(data1).stream(m).exercise();
+ }
+
+ protected <T, U, S_OUT extends BaseStream<U, S_OUT>, I extends Iterable<U>>
+ Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m, I expected) {
+ TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+ return withData(data1).stream(m).expectedResult(expected).exercise();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <U, S_OUT extends BaseStream<U, S_OUT>>
+ Collection<U> exerciseOps(int[] data, Function<IntStream, S_OUT> m) {
+ return withData(TestData.Factory.ofArray("int array", data)).stream(m).exercise();
+ }
+
+ protected Collection<Integer> exerciseOps(int[] data, Function<IntStream, IntStream> m, int[] expected) {
+ TestData.OfInt data1 = TestData.Factory.ofArray("int array", data);
+ return withData(data1).stream(m).expectedResult(expected).exercise();
+ }
+
+ protected <T, S_IN extends BaseStream<T, S_IN>> DataStreamBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
+ Objects.requireNonNull(data);
+ return new DataStreamBuilder<>(data);
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public class DataStreamBuilder<T, S_IN extends BaseStream<T, S_IN>> {
+ final TestData<T, S_IN> data;
+
+ private DataStreamBuilder(TestData<T, S_IN> data) {
+ this.data = Objects.requireNonNull(data);
+ }
+
+ public <U, S_OUT extends BaseStream<U, S_OUT>>
+ ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> ops(IntermediateTestOp... ops) {
+ return new ExerciseDataStreamBuilder<>(data, (S_IN s) -> (S_OUT) chain(s, ops));
+ }
+
+ public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+ stream(Function<S_IN, S_OUT> m) {
+ return new ExerciseDataStreamBuilder<>(data, m);
+ }
+
+ public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+ stream(Function<S_IN, S_OUT> m, IntermediateTestOp<U, U> additionalOp) {
+ return new ExerciseDataStreamBuilder<>(data, s -> (S_OUT) chain(m.apply(s), additionalOp));
+ }
+
+ public <R> ExerciseDataTerminalBuilder<T, T, R, S_IN, S_IN>
+ terminal(Function<S_IN, R> terminalF) {
+ return new ExerciseDataTerminalBuilder<>(data, s -> s, terminalF);
+ }
+
+ public <U, R, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT>
+ terminal(Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+ return new ExerciseDataTerminalBuilder<>(data, streamF, terminalF);
+ }
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public class ExerciseDataStreamBuilder<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+ final TestData<T, S_IN> data;
+ final Function<S_IN, S_OUT> m;
+ final StreamShape shape;
+
+ Set<BaseStreamTestScenario> testSet = new HashSet<>();
+
+ Collection<U> refResult;
+
+ Consumer<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
+
+ Consumer<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
+
+ ResultAsserter<Iterable<U>> resultAsserter = (act, exp, ord, par) -> {
+ if (par & !ord) {
+ LambdaTestHelpers.assertContentsUnordered(act, exp);
+ }
+ else {
+ LambdaTestHelpers.assertContentsEqual(act, exp);
+ }
+ };
+
+ private ExerciseDataStreamBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+ this.data = data;
+
+ this.m = Objects.requireNonNull(m);
+
+ this.shape = ((AbstractPipeline<?, U, ?>) m.apply(data.stream())).getOutputShape();
+
+ // Have to initiate from the output shape of the last stream
+ // This means the stream mapper is required first rather than last
+ testSet.addAll(testScenarios.get(shape));
+ }
+
+ //
+
+ public <I extends Iterable<U>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
+ List<U> l = new ArrayList<>();
+ expectedResult.forEach(l::add);
+ refResult = l;
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(int[] expectedResult) {
+ List l = new ArrayList();
+ for (int anExpectedResult : expectedResult) {
+ l.add(anExpectedResult);
+ }
+ refResult = l;
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(long[] expectedResult) {
+ List l = new ArrayList();
+ for (long anExpectedResult : expectedResult) {
+ l.add(anExpectedResult);
+ }
+ refResult = l;
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(double[] expectedResult) {
+ List l = new ArrayList();
+ for (double anExpectedResult : expectedResult) {
+ l.add(anExpectedResult);
+ }
+ refResult = l;
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> before(Consumer<TestData<T, S_IN>> before) {
+ this.before = Objects.requireNonNull(before);
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> after(Consumer<TestData<T, S_IN>> after) {
+ this.after = Objects.requireNonNull(after);
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(BaseStreamTestScenario... tests) {
+ return without(Arrays.asList(tests));
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(Collection<? extends BaseStreamTestScenario> tests) {
+ for (BaseStreamTestScenario ts : tests) {
+ if (ts.getShape() == shape) {
+ testSet.remove(ts);
+ }
+ }
+
+ if (testSet.isEmpty()) {
+ throw new IllegalStateException("Test scenario set is empty");
+ }
+
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(BaseStreamTestScenario... tests) {
+ return with(Arrays.asList(tests));
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(Collection<? extends BaseStreamTestScenario> tests) {
+ testSet = new HashSet<>();
+
+ for (BaseStreamTestScenario ts : tests) {
+ if (ts.getShape() == shape) {
+ testSet.add(ts);
+ }
+ }
+
+ if (testSet.isEmpty()) {
+ throw new IllegalStateException("Test scenario set is empty");
+ }
+
+ return this;
+ }
+
+ public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> resultAsserter(ResultAsserter<Iterable<U>> resultAsserter) {
+ this.resultAsserter = resultAsserter;
+ return this;
+ }
+
+ // Build method
+
+ public Collection<U> exercise() {
+ final boolean isStreamOrdered;
+ if (refResult == null) {
+ // Induce the reference result
+ before.accept(data);
+ S_OUT sOut = m.apply(data.stream());
+ isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
+ Node<U> refNodeResult = ((AbstractPipeline<?, U, ?>) sOut).evaluateToArrayNode(size -> (U[]) new Object[size]);
+ refResult = LambdaTestHelpers.toBoxedList(refNodeResult.spliterator());
+ after.accept(data);
+ }
+ else {
+ S_OUT sOut = m.apply(data.stream());
+ isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
+ }
+
+ List<Error> errors = new ArrayList<>();
+ for (BaseStreamTestScenario test : testSet) {
+ try {
+ before.accept(data);
+
+ List<U> result = new ArrayList<>();
+ test.run(data, LambdaTestHelpers.<U>toBoxingConsumer(result::add), m);
+
+ Runnable asserter = () -> resultAsserter.assertResult(result, refResult, isStreamOrdered && test.isOrdered(), test.isParallel());
+
+ if (refResult.size() > 1000) {
+ LambdaTestHelpers.launderAssertion(
+ asserter,
+ () -> String.format("%n%s: [actual size=%d] != [expected size=%d]", test, result.size(), refResult.size()));
+ }
+ else {
+ LambdaTestHelpers.launderAssertion(
+ asserter,
+ () -> String.format("%n%s: [actual] %s != [expected] %s", test, result, refResult));
+ }
+
+ after.accept(data);
+ } catch (Throwable t) {
+ errors.add(new Error(String.format("%s: %s", test, t), t));
+ }
+ }
+
+ if (!errors.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+ int i = 1;
+ for (Error t : errors) {
+ sb.append(i++).append(": ");
+ if (t instanceof AssertionError) {
+ sb.append(t).append("\n");
+ }
+ else {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ t.getCause().printStackTrace(pw);
+ pw.flush();
+ sb.append(t).append("\n").append(sw);
+ }
+ }
+ sb.append("--");
+
+ fail(String.format("%d failure(s) for test data: %s\n%s", i - 1, data.toString(), sb));
+ }
+
+ return refResult;
+ }
+ }
+
+ // Exercise terminal operations
+
+ interface BaseTerminalTestScenario<U, R, S_OUT extends BaseStream<U, S_OUT>> {
+ boolean requiresSingleStageSource();
+
+ boolean requiresParallelSource();
+
+ default R run(Function<S_OUT, R> terminalF, S_OUT source, StreamShape shape) {
+ return terminalF.apply(source);
+ }
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ enum TerminalTestScenario implements BaseTerminalTestScenario {
+ SINGLE_SEQUENTIAL(true, false),
+
+ SINGLE_SEQUENTIAL_SHORT_CIRCUIT(true, false) {
+ @Override
+ public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+ source = (BaseStream) chain(source, new ShortCircuitOp(shape));
+ return terminalF.apply(source);
+ }
+ },
+
+ SINGLE_PARALLEL(true, true),
+
+ ALL_SEQUENTIAL(false, false),
+
+ ALL_SEQUENTIAL_SHORT_CIRCUIT(false, false) {
+ @Override
+ public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+ source = (BaseStream) chain(source, new ShortCircuitOp(shape));
+ return terminalF.apply(source);
+ }
+ },
+
+ ALL_PARALLEL(false, true),
+
+ ALL_PARALLEL_SEQUENTIAL(false, false) {
+ @Override
+ public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+ return terminalF.apply(source.sequential());
+ }
+ },
+ ;
+
+ private final boolean requiresSingleStageSource;
+ private final boolean isParallel;
+
+ TerminalTestScenario(boolean requiresSingleStageSource, boolean isParallel) {
+ this.requiresSingleStageSource = requiresSingleStageSource;
+ this.isParallel = isParallel;
+ }
+
+ @Override
+ public boolean requiresSingleStageSource() {
+ return requiresSingleStageSource;
+ }
+
+ @Override
+ public boolean requiresParallelSource() {
+ return isParallel;
+ }
+
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public class ExerciseDataTerminalBuilder<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+ final TestData<T, S_IN> data;
+ final Function<S_IN, S_OUT> streamF;
+ final Function<S_OUT, R> terminalF;
+
+ R refResult;
+
+ ResultAsserter<R> resultAsserter = (act, exp, ord, par) -> LambdaTestHelpers.assertContentsEqual(act, exp);
+
+ private ExerciseDataTerminalBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+ this.data = data;
+ this.streamF = Objects.requireNonNull(streamF);
+ this.terminalF = Objects.requireNonNull(terminalF);
+ }
+
+ //
+
+ public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> expectedResult(R expectedResult) {
+ this.refResult = expectedResult;
+ return this;
+ }
+
+ public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> equalator(BiConsumer<R, R> equalityAsserter) {
+ resultAsserter = (act, exp, ord, par) -> equalityAsserter.accept(act, exp);
+ return this;
+ }
+
+ public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> resultAsserter(ResultAsserter<R> resultAsserter) {
+ this.resultAsserter = resultAsserter;
+ return this;
+ }
+
+ // Build method
+
+ public R exercise() {
+ S_OUT out = streamF.apply(data.stream()).sequential();
+ AbstractPipeline ap = (AbstractPipeline) out;
+ boolean isOrdered = StreamOpFlag.ORDERED.isKnown(ap.getStreamFlags());
+ StreamShape shape = ap.getOutputShape();
+
+ EnumSet<TerminalTestScenario> tests = EnumSet.allOf(TerminalTestScenario.class);
+ // Sequentially collect the output that will be input to the terminal op
+ Node<U> node = ap.evaluateToArrayNode(size -> (U[]) new Object[size]);
+ if (refResult == null) {
+ // Induce the reference result
+ S_OUT source = (S_OUT) createPipeline(shape, node.spliterator(),
+ StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
+ false);
+
+ refResult = (R) TerminalTestScenario.SINGLE_SEQUENTIAL.run(terminalF, source, shape);
+ tests.remove(TerminalTestScenario.SINGLE_SEQUENTIAL);
+ }
+
+ for (BaseTerminalTestScenario test : tests) {
+ S_OUT source;
+ if (test.requiresSingleStageSource()) {
+ source = (S_OUT) createPipeline(shape, node.spliterator(),
+ StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
+ test.requiresParallelSource());
+ }
+ else {
+ source = streamF.apply(test.requiresParallelSource()
+ ? data.parallelStream() : data.stream());
+ }
+
+ R result = (R) test.run(terminalF, source, shape);
+
+ LambdaTestHelpers.launderAssertion(
+ () -> resultAsserter.assertResult(result, refResult, isOrdered, test.requiresParallelSource()),
+ () -> String.format("%s: %s != %s", test, refResult, result));
+ }
+
+ return refResult;
+ }
+
+ AbstractPipeline createPipeline(StreamShape shape, Spliterator s, int flags, boolean parallel) {
+ switch (shape) {
+ case REFERENCE: return new ReferencePipeline.Head<>(s, flags, parallel);
+ case INT_VALUE: return new IntPipeline.Head(s, flags, parallel);
+ case LONG_VALUE: return new LongPipeline.Head(s, flags, parallel);
+ case DOUBLE_VALUE: return new DoublePipeline.Head(s, flags, parallel);
+ default: throw new IllegalStateException("Unknown shape: " + shape);
+ }
+ }
+ }
+
+ protected <T, R> R exerciseTerminalOps(Collection<T> data, Function<Stream<T>, R> m, R expected) {
+ TestData.OfRef<T> data1
+ = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+ return withData(data1).terminal(m).expectedResult(expected).exercise();
+ }
+
+ protected <T, R, S_IN extends BaseStream<T, S_IN>> R
+ exerciseTerminalOps(TestData<T, S_IN> data,
+ Function<S_IN, R> terminalF) {
+ return withData(data).terminal(terminalF).exercise();
+ }
+
+ protected <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> R
+ exerciseTerminalOps(TestData<T, S_IN> data,
+ Function<S_IN, S_OUT> streamF,
+ Function<S_OUT, R> terminalF) {
+ return withData(data).terminal(streamF, terminalF).exercise();
+ }
+
+ //
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static <T> AbstractPipeline<?, T, ?> chain(AbstractPipeline upstream, IntermediateTestOp<?, T> op) {
+ return (AbstractPipeline<?, T, ?>) IntermediateTestOp.chain(upstream, op);
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private static AbstractPipeline<?, ?, ?> chain(AbstractPipeline pipe, IntermediateTestOp... ops) {
+ for (IntermediateTestOp op : ops)
+ pipe = chain(pipe, op);
+ return pipe;
+ }
+
+ @SuppressWarnings("rawtypes")
+ private static <T> AbstractPipeline<?, T, ?> chain(BaseStream pipe, IntermediateTestOp<?, T> op) {
+ return chain((AbstractPipeline) pipe, op);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static AbstractPipeline<?, ?, ?> chain(BaseStream pipe, IntermediateTestOp... ops) {
+ return chain((AbstractPipeline) pipe, ops);
+ }
+
+ // Test data
+
+ static class ShortCircuitOp<T> implements StatelessTestOp<T,T> {
+ private final StreamShape shape;
+
+ ShortCircuitOp(StreamShape shape) {
+ this.shape = shape;
+ }
+
+ @Override
+ public Sink<T> opWrapSink(int flags, boolean parallel, Sink<T> sink) {
+ return sink;
+ }
+
+ @Override
+ public int opGetFlags() {
+ return StreamOpFlag.IS_SHORT_CIRCUIT;
+ }
+
+ @Override
+ public StreamShape outputShape() {
+ return shape;
+ }
+
+ @Override
+ public StreamShape inputShape() {
+ return shape;
+ }
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/SpliteratorTestHelper.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/SpliteratorTestHelper.java
new file mode 100644
index 0000000..b41f7de
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/SpliteratorTestHelper.java
@@ -0,0 +1,727 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.annotations.Test;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Spliterator;
+import java.util.function.*;
+
+import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+/**
+ * Assertion methods for spliterators, to be called from other tests
+ */
+public class SpliteratorTestHelper {
+
+ public interface ContentAsserter<T> {
+ void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered);
+ }
+
+ private static ContentAsserter<Object> DEFAULT_CONTENT_ASSERTER
+ = SpliteratorTestHelper::assertContents;
+
+ @SuppressWarnings("unchecked")
+ private static <T> ContentAsserter<T> defaultContentAsserter() {
+ return (ContentAsserter<T>) DEFAULT_CONTENT_ASSERTER;
+ }
+
+ public static void testSpliterator(Supplier<Spliterator<Integer>> supplier) {
+ testSpliterator(supplier, defaultContentAsserter());
+ }
+
+ public static void testSpliterator(Supplier<Spliterator<Integer>> supplier,
+ ContentAsserter<Integer> asserter) {
+ testSpliterator(supplier, (Consumer<Integer> b) -> b, asserter);
+ }
+
+ public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier) {
+ testIntSpliterator(supplier, defaultContentAsserter());
+ }
+
+ public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier,
+ ContentAsserter<Integer> asserter) {
+ class BoxingAdapter implements Consumer<Integer>, IntConsumer {
+ private final Consumer<Integer> b;
+
+ BoxingAdapter(Consumer<Integer> b) {
+ this.b = b;
+ }
+
+ @Override
+ public void accept(Integer value) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public void accept(int value) {
+ b.accept(value);
+ }
+ }
+
+ testSpliterator(supplier, BoxingAdapter::new, asserter);
+ }
+
+ public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier) {
+ testLongSpliterator(supplier, defaultContentAsserter());
+ }
+
+ public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier,
+ ContentAsserter<Long> asserter) {
+ class BoxingAdapter implements Consumer<Long>, LongConsumer {
+ private final Consumer<Long> b;
+
+ BoxingAdapter(Consumer<Long> b) {
+ this.b = b;
+ }
+
+ @Override
+ public void accept(Long value) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public void accept(long value) {
+ b.accept(value);
+ }
+ }
+
+ testSpliterator(supplier, BoxingAdapter::new, asserter);
+ }
+
+ public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier) {
+ testDoubleSpliterator(supplier, defaultContentAsserter());
+ }
+
+ public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier,
+ ContentAsserter<Double> asserter) {
+ class BoxingAdapter implements Consumer<Double>, DoubleConsumer {
+ private final Consumer<Double> b;
+
+ BoxingAdapter(Consumer<Double> b) {
+ this.b = b;
+ }
+
+ @Override
+ public void accept(Double value) {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public void accept(double value) {
+ b.accept(value);
+ }
+ }
+
+ testSpliterator(supplier, BoxingAdapter::new, asserter);
+ }
+
+ static <T, S extends Spliterator<T>> void testSpliterator(Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ ArrayList<T> fromForEach = new ArrayList<>();
+ Spliterator<T> spliterator = supplier.get();
+ Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
+ spliterator.forEachRemaining(addToFromForEach);
+
+ Collection<T> exp = Collections.unmodifiableList(fromForEach);
+
+ testNullPointerException(supplier);
+ testForEach(exp, supplier, boxingAdapter, asserter);
+ testTryAdvance(exp, supplier, boxingAdapter, asserter);
+ testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, asserter);
+ testMixedTraverseAndSplit(exp, supplier, boxingAdapter, asserter);
+ testSplitAfterFullTraversal(supplier, boxingAdapter);
+ testSplitOnce(exp, supplier, boxingAdapter, asserter);
+ testSplitSixDeep(exp, supplier, boxingAdapter, asserter);
+ testSplitUntilNull(exp, supplier, boxingAdapter, asserter);
+ }
+
+ //
+
+ private static <T, S extends Spliterator<T>> void testNullPointerException(Supplier<S> s) {
+ S sp = s.get();
+ // Have to check instances and use casts to avoid tripwire messages and
+ // directly test the primitive methods
+ if (sp instanceof Spliterator.OfInt) {
+ Spliterator.OfInt psp = (Spliterator.OfInt) sp;
+ executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((IntConsumer) null));
+ executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((IntConsumer) null));
+ }
+ else if (sp instanceof Spliterator.OfLong) {
+ Spliterator.OfLong psp = (Spliterator.OfLong) sp;
+ executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((LongConsumer) null));
+ executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((LongConsumer) null));
+ }
+ else if (sp instanceof Spliterator.OfDouble) {
+ Spliterator.OfDouble psp = (Spliterator.OfDouble) sp;
+ executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((DoubleConsumer) null));
+ executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((DoubleConsumer) null));
+ }
+ else {
+ executeAndCatch(NullPointerException.class, () -> sp.forEachRemaining(null));
+ executeAndCatch(NullPointerException.class, () -> sp.tryAdvance(null));
+ }
+ }
+
+ private static <T, S extends Spliterator<T>> void testForEach(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ S spliterator = supplier.get();
+ long sizeIfKnown = spliterator.getExactSizeIfKnown();
+ boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+ ArrayList<T> fromForEach = new ArrayList<>();
+ spliterator = supplier.get();
+ Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
+ spliterator.forEachRemaining(addToFromForEach);
+
+ // Assert that forEach now produces no elements
+ spliterator.forEachRemaining(boxingAdapter.apply(
+ e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+ // Assert that tryAdvance now produce no elements
+ spliterator.tryAdvance(boxingAdapter.apply(
+ e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+ // assert that size, tryAdvance, and forEach are consistent
+ if (sizeIfKnown >= 0) {
+ assertEquals(sizeIfKnown, exp.size());
+ }
+ assertEquals(fromForEach.size(), exp.size());
+
+ asserter.assertContents(fromForEach, exp, isOrdered);
+ }
+
+ private static <T, S extends Spliterator<T>> void testTryAdvance(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ S spliterator = supplier.get();
+ long sizeIfKnown = spliterator.getExactSizeIfKnown();
+ boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+ spliterator = supplier.get();
+ ArrayList<T> fromTryAdvance = new ArrayList<>();
+ Consumer<T> addToFromTryAdvance = boxingAdapter.apply(fromTryAdvance::add);
+ while (spliterator.tryAdvance(addToFromTryAdvance)) { }
+
+ // Assert that forEach now produces no elements
+ spliterator.forEachRemaining(boxingAdapter.apply(
+ e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+ // Assert that tryAdvance now produce no elements
+ spliterator.tryAdvance(boxingAdapter.apply(
+ e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+ // assert that size, tryAdvance, and forEach are consistent
+ if (sizeIfKnown >= 0) {
+ assertEquals(sizeIfKnown, exp.size());
+ }
+ assertEquals(fromTryAdvance.size(), exp.size());
+
+ asserter.assertContents(fromTryAdvance, exp, isOrdered);
+ }
+
+ private static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ S spliterator = supplier.get();
+ long sizeIfKnown = spliterator.getExactSizeIfKnown();
+ boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+ // tryAdvance first few elements, then forEach rest
+ ArrayList<T> dest = new ArrayList<>();
+ spliterator = supplier.get();
+ Consumer<T> addToDest = boxingAdapter.apply(dest::add);
+ for (int i = 0; i < 10 && spliterator.tryAdvance(addToDest); i++) { }
+ spliterator.forEachRemaining(addToDest);
+
+ // Assert that forEach now produces no elements
+ spliterator.forEachRemaining(boxingAdapter.apply(
+ e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+ // Assert that tryAdvance now produce no elements
+ spliterator.tryAdvance(boxingAdapter.apply(
+ e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+ if (sizeIfKnown >= 0) {
+ assertEquals(sizeIfKnown, dest.size());
+ }
+ assertEquals(dest.size(), exp.size());
+
+ asserter.assertContents(dest, exp, isOrdered);
+ }
+
+ private static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ S spliterator = supplier.get();
+ long sizeIfKnown = spliterator.getExactSizeIfKnown();
+ boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+ // tryAdvance first few elements, then forEach rest
+ ArrayList<T> dest = new ArrayList<>();
+ spliterator = supplier.get();
+ Consumer<T> b = boxingAdapter.apply(dest::add);
+
+ Spliterator<T> spl1, spl2, spl3;
+ spliterator.tryAdvance(b);
+ spl2 = spliterator.trySplit();
+ if (spl2 != null) {
+ spl2.tryAdvance(b);
+ spl1 = spl2.trySplit();
+ if (spl1 != null) {
+ spl1.tryAdvance(b);
+ spl1.forEachRemaining(b);
+ }
+ spl2.tryAdvance(b);
+ spl2.forEachRemaining(b);
+ }
+ spliterator.tryAdvance(b);
+ spl3 = spliterator.trySplit();
+ if (spl3 != null) {
+ spl3.tryAdvance(b);
+ spl3.forEachRemaining(b);
+ }
+ spliterator.tryAdvance(b);
+ spliterator.forEachRemaining(b);
+
+ if (sizeIfKnown >= 0) {
+ assertEquals(sizeIfKnown, dest.size());
+ }
+ assertEquals(dest.size(), exp.size());
+
+ asserter.assertContents(dest, exp, isOrdered);
+ }
+
+ private static <T, S extends Spliterator<T>> void testSplitAfterFullTraversal(
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter) {
+ // Full traversal using tryAdvance
+ Spliterator<T> spliterator = supplier.get();
+ while (spliterator.tryAdvance(boxingAdapter.apply(e -> { }))) { }
+ Spliterator<T> split = spliterator.trySplit();
+ assertNull(split);
+
+ // Full traversal using forEach
+ spliterator = supplier.get();
+ spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
+ split = spliterator.trySplit();
+ assertNull(split);
+
+ // Full traversal using tryAdvance then forEach
+ spliterator = supplier.get();
+ spliterator.tryAdvance(boxingAdapter.apply(e -> { }));
+ spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
+ split = spliterator.trySplit();
+ assertNull(split);
+ }
+
+ private static <T, S extends Spliterator<T>> void testSplitOnce(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ S spliterator = supplier.get();
+ long sizeIfKnown = spliterator.getExactSizeIfKnown();
+ boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+ ArrayList<T> fromSplit = new ArrayList<>();
+ Spliterator<T> s1 = supplier.get();
+ Spliterator<T> s2 = s1.trySplit();
+ long s1Size = s1.getExactSizeIfKnown();
+ long s2Size = (s2 != null) ? s2.getExactSizeIfKnown() : 0;
+ Consumer<T> addToFromSplit = boxingAdapter.apply(fromSplit::add);
+ if (s2 != null)
+ s2.forEachRemaining(addToFromSplit);
+ s1.forEachRemaining(addToFromSplit);
+
+ if (sizeIfKnown >= 0) {
+ assertEquals(sizeIfKnown, fromSplit.size());
+ if (s1Size >= 0 && s2Size >= 0)
+ assertEquals(sizeIfKnown, s1Size + s2Size);
+ }
+
+ asserter.assertContents(fromSplit, exp, isOrdered);
+ }
+
+ private static <T, S extends Spliterator<T>> void testSplitSixDeep(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ S spliterator = supplier.get();
+ boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+ for (int depth=0; depth < 6; depth++) {
+ List<T> dest = new ArrayList<>();
+ spliterator = supplier.get();
+
+ assertSpliterator(spliterator);
+
+ // verify splitting with forEach
+ splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), false);
+ asserter.assertContents(dest, exp, isOrdered);
+
+ // verify splitting with tryAdvance
+ dest.clear();
+ spliterator = supplier.get();
+ splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), true);
+ asserter.assertContents(dest, exp, isOrdered);
+ }
+ }
+
+ static void splitSixDeepVisitorUnsafe(int depth, int curLevel, List dest,
+ Spliterator spliterator, UnaryOperator boxingAdapter,
+ int rootCharacteristics, boolean useTryAdvance) {
+ splitSixDeepVisitor(depth, curLevel, dest, spliterator, boxingAdapter, rootCharacteristics, useTryAdvance);
+ }
+
+ // Android-changed: Workaround for jack type inference bug
+ private static <T>
+ // private static <T, S extends Spliterator<T>>
+ // Android-changed: Workaround for jack type inference bug
+ void splitSixDeepVisitor(int depth, int curLevel,
+ List<T> dest, Spliterator<T> spliterator, UnaryOperator<Consumer<T>> boxingAdapter,
+ // List<T> dest, S spliterator, UnaryOperator<Consumer<T>> boxingAdapter,
+ int rootCharacteristics, boolean useTryAdvance) {
+ if (curLevel < depth) {
+ long beforeSize = spliterator.getExactSizeIfKnown();
+ Spliterator<T> split = spliterator.trySplit();
+ if (split != null) {
+ assertSpliterator(split, rootCharacteristics);
+ assertSpliterator(spliterator, rootCharacteristics);
+
+ if ((rootCharacteristics & Spliterator.SUBSIZED) != 0 &&
+ (rootCharacteristics & Spliterator.SIZED) != 0) {
+ assertEquals(beforeSize, split.estimateSize() + spliterator.estimateSize());
+ }
+ // Android-changed: Workaround for jack type inference bug
+ splitSixDeepVisitorUnsafe(depth, curLevel + 1, dest, split, boxingAdapter, rootCharacteristics, useTryAdvance);
+ // splitSixDeepVisitor(depth, curLevel + 1, dest, split, boxingAdapter, rootCharacteristics, useTryAdvance);
+ }
+ splitSixDeepVisitor(depth, curLevel + 1, dest, spliterator, boxingAdapter, rootCharacteristics, useTryAdvance);
+ }
+ else {
+ long sizeIfKnown = spliterator.getExactSizeIfKnown();
+ if (useTryAdvance) {
+ Consumer<T> addToDest = boxingAdapter.apply(dest::add);
+ int count = 0;
+ while (spliterator.tryAdvance(addToDest)) {
+ ++count;
+ }
+
+ if (sizeIfKnown >= 0)
+ assertEquals(sizeIfKnown, count);
+
+ // Assert that forEach now produces no elements
+ spliterator.forEachRemaining(boxingAdapter.apply(
+ e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+
+ Spliterator<T> split = spliterator.trySplit();
+ assertNull(split);
+ }
+ else {
+ List<T> leafDest = new ArrayList<>();
+ Consumer<T> addToLeafDest = boxingAdapter.apply(leafDest::add);
+ spliterator.forEachRemaining(addToLeafDest);
+
+ if (sizeIfKnown >= 0)
+ assertEquals(sizeIfKnown, leafDest.size());
+
+ // Assert that forEach now produces no elements
+ spliterator.tryAdvance(boxingAdapter.apply(
+ e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+ Spliterator<T> split = spliterator.trySplit();
+ assertNull(split);
+
+ dest.addAll(leafDest);
+ }
+ }
+ }
+
+ private static <T, S extends Spliterator<T>> void testSplitUntilNull(
+ Collection<T> exp,
+ Supplier<S> supplier,
+ UnaryOperator<Consumer<T>> boxingAdapter,
+ ContentAsserter<T> asserter) {
+ Spliterator<T> s = supplier.get();
+ boolean isOrdered = s.hasCharacteristics(Spliterator.ORDERED);
+ assertSpliterator(s);
+
+ List<T> splits = new ArrayList<>();
+ Consumer<T> c = boxingAdapter.apply(splits::add);
+
+ testSplitUntilNull(new SplitNode<T>(c, s));
+ asserter.assertContents(splits, exp, isOrdered);
+ }
+
+ private static class SplitNode<T> {
+ // Constant for every node
+ final Consumer<T> c;
+ final int rootCharacteristics;
+
+ final Spliterator<T> s;
+
+ SplitNode(Consumer<T> c, Spliterator<T> s) {
+ this(c, s.characteristics(), s);
+ }
+
+ private SplitNode(Consumer<T> c, int rootCharacteristics, Spliterator<T> s) {
+ this.c = c;
+ this.rootCharacteristics = rootCharacteristics;
+ this.s = s;
+ }
+
+ SplitNode<T> fromSplit(Spliterator<T> split) {
+ return new SplitNode<>(c, rootCharacteristics, split);
+ }
+ }
+
+ /**
+ * Set the maximum stack capacity to 0.25MB. This should be more than enough to detect a bad spliterator
+ * while not unduly disrupting test infrastructure given the test data sizes that are used are small.
+ * Note that j.u.c.ForkJoinPool sets the max queue size to 64M (1 << 26).
+ */
+ private static final int MAXIMUM_STACK_CAPACITY = 1 << 18; // 0.25MB
+
+ private static <T> void testSplitUntilNull(SplitNode<T> e) {
+ // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
+ // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
+ // for a spliterator that is badly behaved.
+ Deque<SplitNode<T>> stack = new ArrayDeque<>();
+ stack.push(e);
+
+ int iteration = 0;
+ while (!stack.isEmpty()) {
+ assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");
+
+ e = stack.pop();
+ Spliterator<T> parentAndRightSplit = e.s;
+
+ long parentEstimateSize = parentAndRightSplit.estimateSize();
+ assertTrue(parentEstimateSize >= 0,
+ String.format("Split size estimate %d < 0", parentEstimateSize));
+
+ long parentSize = parentAndRightSplit.getExactSizeIfKnown();
+ Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
+ if (leftSplit == null) {
+ parentAndRightSplit.forEachRemaining(e.c);
+ continue;
+ }
+
+ assertSpliterator(leftSplit, e.rootCharacteristics);
+ assertSpliterator(parentAndRightSplit, e.rootCharacteristics);
+
+ if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0
+ && parentAndRightSplit.estimateSize() > 0) {
+ assertTrue(leftSplit.estimateSize() < parentEstimateSize,
+ String.format("Left split size estimate %d >= parent split size estimate %d",
+ leftSplit.estimateSize(), parentEstimateSize));
+ assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
+ String.format("Right split size estimate %d >= parent split size estimate %d",
+ leftSplit.estimateSize(), parentEstimateSize));
+ }
+ else {
+ assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
+ String.format("Left split size estimate %d > parent split size estimate %d",
+ leftSplit.estimateSize(), parentEstimateSize));
+ assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
+ String.format("Right split size estimate %d > parent split size estimate %d",
+ leftSplit.estimateSize(), parentEstimateSize));
+ }
+
+ long leftSize = leftSplit.getExactSizeIfKnown();
+ long rightSize = parentAndRightSplit.getExactSizeIfKnown();
+ if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
+ assertEquals(parentSize, leftSize + rightSize,
+ String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
+ leftSize, rightSize, parentSize));
+
+ // Add right side to stack first so left side is popped off first
+ stack.push(e.fromSplit(parentAndRightSplit));
+ stack.push(e.fromSplit(leftSplit));
+ }
+ }
+
+ private static void assertSpliterator(Spliterator<?> s, int rootCharacteristics) {
+ if ((rootCharacteristics & Spliterator.SUBSIZED) != 0) {
+ assertTrue(s.hasCharacteristics(Spliterator.SUBSIZED),
+ "Child split is not SUBSIZED when root split is SUBSIZED");
+ }
+ assertSpliterator(s);
+ }
+
+ private static void assertSpliterator(Spliterator<?> s) {
+ if (s.hasCharacteristics(Spliterator.SUBSIZED)) {
+ assertTrue(s.hasCharacteristics(Spliterator.SIZED));
+ }
+ if (s.hasCharacteristics(Spliterator.SIZED)) {
+ assertTrue(s.estimateSize() != Long.MAX_VALUE);
+ assertTrue(s.getExactSizeIfKnown() >= 0);
+ }
+ try {
+ s.getComparator();
+ assertTrue(s.hasCharacteristics(Spliterator.SORTED));
+ } catch (IllegalStateException e) {
+ assertFalse(s.hasCharacteristics(Spliterator.SORTED));
+ }
+ }
+
+ private static<T> void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered) {
+ if (isOrdered) {
+ assertEquals(actual, expected);
+ }
+ else {
+ LambdaTestHelpers.assertContentsUnordered(actual, expected);
+ }
+ }
+
+ private static void executeAndCatch(Class<? extends Exception> expected, Runnable r) {
+ Exception caught = null;
+ try {
+ r.run();
+ }
+ catch (Exception e) {
+ caught = e;
+ }
+
+ assertNotNull(caught,
+ String.format("No Exception was thrown, expected an Exception of %s to be thrown",
+ expected.getName()));
+ assertTrue(expected.isInstance(caught),
+ String.format("Exception thrown %s not an instance of %s",
+ caught.getClass().getName(), expected.getName()));
+ }
+
+ static<U> void mixedTraverseAndSplit(Consumer<U> b, Spliterator<U> splTop) {
+ Spliterator<U> spl1, spl2, spl3;
+ splTop.tryAdvance(b);
+ spl2 = splTop.trySplit();
+ if (spl2 != null) {
+ spl2.tryAdvance(b);
+ spl1 = spl2.trySplit();
+ if (spl1 != null) {
+ spl1.tryAdvance(b);
+ spl1.forEachRemaining(b);
+ }
+ spl2.tryAdvance(b);
+ spl2.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ spl3 = splTop.trySplit();
+ if (spl3 != null) {
+ spl3.tryAdvance(b);
+ spl3.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ splTop.forEachRemaining(b);
+ }
+
+ static void mixedTraverseAndSplit(IntConsumer b, Spliterator.OfInt splTop) {
+ Spliterator.OfInt spl1, spl2, spl3;
+ splTop.tryAdvance(b);
+ spl2 = splTop.trySplit();
+ if (spl2 != null) {
+ spl2.tryAdvance(b);
+ spl1 = spl2.trySplit();
+ if (spl1 != null) {
+ spl1.tryAdvance(b);
+ spl1.forEachRemaining(b);
+ }
+ spl2.tryAdvance(b);
+ spl2.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ spl3 = splTop.trySplit();
+ if (spl3 != null) {
+ spl3.tryAdvance(b);
+ spl3.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ splTop.forEachRemaining(b);
+ }
+ static void mixedTraverseAndSplit(LongConsumer b, Spliterator.OfLong splTop) {
+ Spliterator.OfLong spl1, spl2, spl3;
+ splTop.tryAdvance(b);
+ spl2 = splTop.trySplit();
+ if (spl2 != null) {
+ spl2.tryAdvance(b);
+ spl1 = spl2.trySplit();
+ if (spl1 != null) {
+ spl1.tryAdvance(b);
+ spl1.forEachRemaining(b);
+ }
+ spl2.tryAdvance(b);
+ spl2.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ spl3 = splTop.trySplit();
+ if (spl3 != null) {
+ spl3.tryAdvance(b);
+ spl3.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ splTop.forEachRemaining(b);
+ }
+
+ static void mixedTraverseAndSplit(DoubleConsumer b, Spliterator.OfDouble splTop) {
+ Spliterator.OfDouble spl1, spl2, spl3;
+ splTop.tryAdvance(b);
+ spl2 = splTop.trySplit();
+ if (spl2 != null) {
+ spl2.tryAdvance(b);
+ spl1 = spl2.trySplit();
+ if (spl1 != null) {
+ spl1.tryAdvance(b);
+ spl1.forEachRemaining(b);
+ }
+ spl2.tryAdvance(b);
+ spl2.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ spl3 = splTop.trySplit();
+ if (spl3 != null) {
+ spl3.tryAdvance(b);
+ spl3.forEachRemaining(b);
+ }
+ splTop.tryAdvance(b);
+ splTop.forEachRemaining(b);
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StatefulTestOp.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StatefulTestOp.java
new file mode 100644
index 0000000..cba50bc
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StatefulTestOp.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+import java.util.stream.*;
+
+/**
+ * The base type for a stateful test operation.
+ */
+interface StatefulTestOp<E> extends IntermediateTestOp<E, E> {
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+ StatefulTestOp op) {
+ switch (op.outputShape()) {
+ case REFERENCE:
+ return new ReferencePipeline.StatefulOp<Object, T>(upstream, op.inputShape(), op.opGetFlags()) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+
+ @Override
+ public <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
+ Spliterator<P_IN> spliterator) {
+ return op.opEvaluateParallelLazy(helper, spliterator);
+ }
+
+ @Override
+ public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<T[]> generator) {
+ return op.opEvaluateParallel(helper, spliterator, generator);
+ }
+ };
+ case INT_VALUE:
+ return new IntPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+
+ @Override
+ public <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
+ Spliterator<P_IN> spliterator) {
+ return op.opEvaluateParallelLazy(helper, spliterator);
+ }
+
+ @Override
+ public <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<Integer[]> generator) {
+ return (Node<Integer>) op.opEvaluateParallel(helper, spliterator, generator);
+ }
+ };
+ case LONG_VALUE:
+ return new LongPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+
+ public @Override
+ <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
+ Spliterator<P_IN> spliterator) {
+ return op.opEvaluateParallelLazy(helper, spliterator);
+ }
+
+ public @Override
+ <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<Long[]> generator) {
+ return (Node<Long>) op.opEvaluateParallel(helper, spliterator, generator);
+ }
+ };
+ case DOUBLE_VALUE:
+ return new DoublePipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+
+ @Override
+ public <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
+ Spliterator<P_IN> spliterator) {
+ return op.opEvaluateParallelLazy(helper, spliterator);
+ }
+
+ @Override
+ public <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<Double[]> generator) {
+ return (Node<Double>) op.opEvaluateParallel(helper, spliterator, generator);
+ }
+ };
+ default: throw new IllegalStateException(op.outputShape().toString());
+ }
+ }
+
+ default StreamShape inputShape() { return StreamShape.REFERENCE; }
+
+ default StreamShape outputShape() { return StreamShape.REFERENCE; }
+
+ default int opGetFlags() { return 0; }
+
+ Sink<E> opWrapSink(int flags, boolean parallel, Sink<E> sink);
+
+ @SuppressWarnings("unchecked")
+ default <P_IN> Spliterator<E> opEvaluateParallelLazy(PipelineHelper<E> helper,
+ Spliterator<P_IN> spliterator) {
+ return opEvaluateParallel(helper, spliterator, i -> (E[]) new Object[i]).spliterator();
+ }
+
+ <P_IN> Node<E> opEvaluateParallel(PipelineHelper<E> helper,
+ Spliterator<P_IN> spliterator,
+ IntFunction<E[]> generator);
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StatelessTestOp.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StatelessTestOp.java
new file mode 100644
index 0000000..47f0857
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StatelessTestOp.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.stream.AbstractPipeline;
+import java.util.stream.DoublePipeline;
+import java.util.stream.IntPipeline;
+import java.util.stream.LongPipeline;
+import java.util.stream.ReferencePipeline;
+import java.util.stream.StreamShape;
+import java.util.stream.Sink;
+
+/**
+ * The base type of a stateless test operation
+ */
+interface StatelessTestOp<E_IN, E_OUT> extends IntermediateTestOp<E_IN, E_OUT> {
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+ StatelessTestOp<?, T> op) {
+ int flags = op.opGetFlags();
+ switch (op.outputShape()) {
+ case REFERENCE:
+ return new ReferencePipeline.StatelessOp<Object, T>(upstream, op.inputShape(), flags) {
+ @Override
+ public Sink opWrapSink(int flags, Sink<T> sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+ };
+ case INT_VALUE:
+ return new IntPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+ };
+ case LONG_VALUE:
+ return new LongPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+ };
+ case DOUBLE_VALUE:
+ return new DoublePipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+ @Override
+ public Sink opWrapSink(int flags, Sink sink) {
+ return op.opWrapSink(flags, isParallel(), sink);
+ }
+ };
+ default: throw new IllegalStateException(op.outputShape().toString());
+ }
+ }
+
+ default StreamShape inputShape() { return StreamShape.REFERENCE; }
+
+ default StreamShape outputShape() { return StreamShape.REFERENCE; }
+
+ default int opGetFlags() { return 0; }
+
+ Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_OUT> sink);
+}
+
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamOpFlagTestHelper.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamOpFlagTestHelper.java
new file mode 100644
index 0000000..7df6949
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamOpFlagTestHelper.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.EnumSet;
+import java.util.stream.BaseStream;
+import java.util.stream.StreamOpFlag;
+import java.util.stream.Stream;
+
+public class StreamOpFlagTestHelper {
+
+ /** EnumSet containing stream flags */
+ private static final EnumSet<StreamOpFlag> allStreamFlags;
+
+ static {
+ allStreamFlags = EnumSet.allOf(StreamOpFlag.class);
+ for (StreamOpFlag f : EnumSet.allOf(StreamOpFlag.class))
+ if (!f.isStreamFlag())
+ allStreamFlags.remove(f);
+ }
+
+
+ static EnumSet<StreamOpFlag> allStreamFlags() {
+ // EnumSet is mutable
+ return allStreamFlags.clone();
+ }
+
+ public static boolean isStreamOrdered(Stream<?> s) {
+ return StreamOpFlag.ORDERED.isKnown(OpTestCase.getStreamFlags(s));
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamTestDataProvider.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamTestDataProvider.java
new file mode 100644
index 0000000..f933d4c
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamTestDataProvider.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+import java.util.stream.SpinedBuffer;
+import java.util.stream.Stream;
+
+/**
+ * StreamTestDataProvider
+ *
+ * @author Brian Goetz
+ */
+/** TestNG DataProvider for ref-valued streams */
+public class StreamTestDataProvider {
+ private static final Integer[] to0 = new Integer[0];
+ private static final Integer[] to1 = new Integer[1];
+ private static final Integer[] to10 = new Integer[10];
+ private static final Integer[] to100 = new Integer[100];
+ private static final Integer[] to1000 = new Integer[1000];
+ private static final Integer[] reversed = new Integer[100];
+ private static final Integer[] ones = new Integer[100];
+ private static final Integer[] twice = new Integer[200];
+ private static final Integer[] pseudoRandom;
+
+ private static final Object[][] testData;
+ private static final Object[][] withNullTestData;
+ private static final Object[][] spliteratorTestData;
+
+ static {
+ Integer[][] arrays = {to0, to1, to10, to100, to1000};
+ for (Integer[] arr : arrays) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = i;
+ }
+ }
+ for (int i = 0; i < reversed.length; i++) {
+ reversed[i] = reversed.length - i;
+ }
+ for (int i = 0; i < ones.length; i++) {
+ ones[i] = 1;
+ }
+ System.arraycopy(to100, 0, twice, 0, to100.length);
+ System.arraycopy(to100, 0, twice, to100.length, to100.length);
+ pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
+ for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+ pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+ }
+ }
+
+ static final Object[][] arrays = {
+ {"empty", to0},
+ {"0..1", to1},
+ {"0..10", to10},
+ {"0..100", to100},
+ {"0..1000", to1000},
+ {"100x[1]", ones},
+ {"2x[0..100]", twice},
+ {"reverse 0..100", reversed},
+ {"pseudorandom", pseudoRandom}
+ };
+
+ static {
+ {
+ List<Object[]> list = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final Integer[] ints = (Integer[])data[1];
+ final List<Integer> intsAsList = Arrays.asList(ints);
+
+ list.add(arrayDataDescr("array:" + name, ints));
+ list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
+ list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
+ list.add(streamDataDescr("DelegatingStream(ArrayList):" + name,
+ () -> new ArrayList<>(intsAsList).stream()));
+ List<Integer> aList = new ArrayList<>(intsAsList);
+ if (LambdaTestMode.isNormalMode()) {
+ // Only include sub-lists for normal test execution mode
+ // This data is serialization-hostile since the state of the
+ // deserialized sub-list will be out of sync with the
+ // enclosing list.
+ list.add(collectionDataDescr("ArrayList.Sublist:" + name,
+ (ints.length) <= 1 ? aList.subList(0, 0) : aList.subList(1, ints.length / 2)));
+ }
+ list.add(collectionDataDescr("LinkedList:" + name, new LinkedList<>(intsAsList)));
+ list.add(collectionDataDescr("HashSet:" + name, new HashSet<>(intsAsList)));
+ list.add(collectionDataDescr("LinkedHashSet:" + name, new LinkedHashSet<>(intsAsList)));
+ list.add(collectionDataDescr("TreeSet:" + name, new TreeSet<>(intsAsList)));
+ SpinedBuffer<Integer> spinedBuffer = new SpinedBuffer<>();
+ intsAsList.forEach(spinedBuffer);
+ list.add(sbDataDescr("SpinedBuffer:" + name, spinedBuffer));
+
+ // @@@ Add more
+ }
+ testData = list.toArray(new Object[0][]);
+ }
+
+ // Simple combination of numbers and null values, probably excessive but may catch
+ // errors for initialization/termination/sequence
+ // @@@ This is separate from the other data for now until nulls are consitently supported by
+ // all operations
+ {
+ List<Object[]> list = new ArrayList<>();
+ int size = 5;
+ for (int i = 0; i < (1 << size) - 2; i++) {
+ Integer[] content = new Integer[size];
+ for (int e = 0; e < size; e++) {
+ content[e] = (i & (1 << e)) > 0 ? e + 1 : null;
+ }
+
+ // ORDERED
+ list.add(arrayDataDescr("array:" + i, content));
+ // not ORDERED, DISTINCT
+ list.add(collectionDataDescr("HashSet:" + i, new HashSet<>(Arrays.asList(content))));
+ }
+
+ withNullTestData = list.toArray(new Object[0][]);
+ }
+
+ {
+ List<Object[]> spliterators = new ArrayList<>();
+ for (Object[] data : arrays) {
+ final Object name = data[0];
+ final Integer[] ints = (Integer[])data[1];
+
+ spliterators.add(splitDescr("Arrays.s(array):" + name,
+ () -> Arrays.spliterator(ints)));
+ spliterators.add(splitDescr("arrays.s(array,o,l):" + name,
+ () -> Arrays.spliterator(ints, 0, ints.length/2)));
+ spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+ () -> {
+ SpinedBuffer<Integer> sb = new SpinedBuffer<>();
+ for (Integer i : ints)
+ sb.accept(i);
+ return sb.spliterator();
+ }));
+ spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator(), size):" + name,
+ () -> Spliterators.spliterator(Arrays.asList(ints).iterator(), ints.length, 0)));
+ spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator()):" + name,
+ () -> Spliterators.spliteratorUnknownSize(Arrays.asList(ints).iterator(), 0)));
+ // @@@ Add map and collection spliterators when spliterator() is exposed on Collection or Iterable
+ }
+ spliteratorTestData = spliterators.toArray(new Object[0][]);
+ }
+ }
+
+ static <T> Object[] arrayDataDescr(String description, T[] data) {
+ return new Object[] { description, TestData.Factory.ofArray(description, data)};
+ }
+
+ static <T> Object[] streamDataDescr(String description, Supplier<Stream<T>> supplier) {
+ return new Object[] { description, TestData.Factory.ofSupplier(description, supplier)};
+ }
+
+ static <T> Object[] collectionDataDescr(String description, Collection<T> data) {
+ return new Object[] { description, TestData.Factory.ofCollection(description, data)};
+ }
+
+ static <T> Object[] sbDataDescr(String description, SpinedBuffer<T> data) {
+ return new Object[] { description, TestData.Factory.ofSpinedBuffer(description, data)};
+ }
+
+ static <T> Object[] splitDescr(String description, Supplier<Spliterator<T>> ss) {
+ return new Object[] { description, ss };
+ }
+
+ // Return an array of ( String name, StreamTestData<Integer> )
+ @DataProvider(name = "StreamTestData<Integer>")
+ public static Object[][] makeStreamTestData() {
+ return testData;
+ }
+
+ @DataProvider(name = "withNull:StreamTestData<Integer>")
+ public static Object[][] makeStreamWithNullTestData() {
+ return withNullTestData;
+ }
+
+ // returns an array of (String name, Supplier<Spliterator<Integer>>)
+ @DataProvider(name = "Spliterator<Integer>")
+ public static Object[][] spliteratorProvider() {
+ return spliteratorTestData;
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamTestScenario.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamTestScenario.java
new file mode 100644
index 0000000..ab4cf9c
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/StreamTestScenario.java
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2012, 2015, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.*;
+
+import org.openjdk.testlib.java.util.stream.FlagDeclaringOp;
+
+/**
+ * Test scenarios for reference streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results. Each scenario describes a different way of computing the
+ * stream contents. The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum StreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+ STREAM_FOR_EACH_WITH_CLOSE(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ Stream<U> s = m.apply(data.stream());
+ if (s.isParallel()) {
+ s = s.sequential();
+ }
+ s.forEach(b);
+ s.close();
+ }
+ },
+
+ // Collec to list
+ STREAM_COLLECT(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (U t : m.apply(data.stream()).collect(Collectors.toList())) {
+ b.accept(t);
+ }
+ }
+ },
+
+ // To array
+ STREAM_TO_ARRAY(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (Object t : m.apply(data.stream()).toArray()) {
+ b.accept((U) t);
+ }
+ }
+ },
+
+ // Wrap as stream, and iterate in pull mode
+ STREAM_ITERATOR(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (Iterator<U> seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+ b.accept(seqIter.next());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (Spliterator<U> spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) { }
+ }
+ },
+
+ // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+ STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate in pull mode
+ STREAM_SPLITERATOR_FOREACH(false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ m.apply(data.stream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ // Wrap as parallel stream + sequential
+ PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ m.apply(data.parallelStream()).sequential().forEach(b);
+ }
+ },
+
+ // Wrap as parallel stream + forEachOrdered
+ PAR_STREAM_FOR_EACH_ORDERED(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ // @@@ Want to explicitly select ordered equalator
+ m.apply(data.parallelStream()).forEachOrdered(b);
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (Spliterator<U> spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) { }
+ }
+ },
+
+ // Wrap as stream, and spliterate then iterate sequentially
+ PAR_STREAM_SPLITERATOR_FOREACH(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+ }
+ },
+
+ // Wrap as parallel stream + toArray
+ PAR_STREAM_TO_ARRAY(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (Object t : m.apply(data.parallelStream()).toArray())
+ b.accept((U) t);
+ }
+ },
+
+ // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+ PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ Stream<U> s = m.apply(data.parallelStream());
+ Spliterator<U> sp = s.spliterator();
+ Stream<U> ss = StreamSupport.stream(() -> sp,
+ StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+ | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+ for (Object t : ss.toArray())
+ b.accept((U) t);
+ }
+ },
+
+ // Wrap as parallel stream + toArray and clear SIZED flag
+ PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ Stream<U> pipe2 = m.apply(pipe1);
+
+ for (Object t : pipe2.toArray())
+ b.accept((U) t);
+ }
+ },
+
+ // Wrap as parallel + collect to list
+ PAR_STREAM_COLLECT_TO_LIST(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (U u : m.apply(data.parallelStream()).collect(Collectors.toList()))
+ b.accept(u);
+ }
+ },
+
+ // Wrap sequential as parallel, + collect to list
+ STREAM_TO_PAR_STREAM_COLLECT_TO_LIST(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (U u : m.apply(data.stream().parallel()).collect(Collectors.toList()))
+ b.accept(u);
+ }
+ },
+
+ // Wrap parallel as sequential,, + collect
+ PAR_STREAM_TO_STREAM_COLLECT_TO_LIST(true) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ for (U u : m.apply(data.parallelStream().sequential()).collect(Collectors.toList()))
+ b.accept(u);
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing
+ PAR_STREAM_FOR_EACH(true, false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ m.apply(data.parallelStream()).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+
+ // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+ PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+ <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+ S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+ new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+ m.apply(pipe1).forEach(e -> {
+ synchronized (data) {
+ b.accept(e);
+ }
+ });
+ }
+ },
+ ;
+
+ // The set of scenarios that clean the SIZED flag
+ public static final Set<StreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+ EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+ private final boolean isParallel;
+
+ private final boolean isOrdered;
+
+ StreamTestScenario(boolean isParallel) {
+ this(isParallel, true);
+ }
+
+ StreamTestScenario(boolean isParallel, boolean isOrdered) {
+ this.isParallel = isParallel;
+ this.isOrdered = isOrdered;
+ }
+
+ public StreamShape getShape() {
+ return StreamShape.REFERENCE;
+ }
+
+ public boolean isParallel() {
+ return isParallel;
+ }
+
+ public boolean isOrdered() {
+ return isOrdered;
+ }
+
+ public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+ void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+ _run(data, b, (Function<S_IN, Stream<U>>) m);
+ }
+
+ abstract <T, U, S_IN extends BaseStream<T, S_IN>>
+ void _run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, Stream<U>> m);
+
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/TestData.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/TestData.java
new file mode 100644
index 0000000..59c38f3
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/TestData.java
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+import java.util.function.LongConsumer;
+import java.util.function.Supplier;
+import java.util.function.ToIntFunction;
+import java.util.stream.*;
+
+/** Describes a test data set for use in stream tests */
+public interface TestData<T, S extends BaseStream<T, S>>
+ extends Iterable<T> {
+
+ default int size() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ default Iterator<T> iterator() {
+ return Spliterators.iterator(spliterator());
+ }
+
+ Spliterator<T> spliterator();
+
+ default boolean isOrdered() {
+ return spliterator().hasCharacteristics(Spliterator.ORDERED);
+ }
+
+ StreamShape getShape();
+
+ default <A extends Collection<? super T>> A into(A target) {
+ spliterator().forEachRemaining(target::add);
+ return target;
+ }
+
+ S stream();
+
+ S parallelStream();
+
+ public interface OfRef<T> extends TestData<T, Stream<T>> { }
+
+ public interface OfInt extends TestData<Integer, IntStream> { }
+
+ public interface OfLong extends TestData<Long, LongStream> { }
+
+ public interface OfDouble extends TestData<Double, DoubleStream> { }
+
+ // @@@ Temporary garbage class to avoid triggering bugs with lambdas in static methods in interfaces
+ public static class Factory {
+ public static <T> OfRef<T> ofArray(String name, T[] array) {
+ return new AbstractTestData.RefTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+ Arrays::spliterator, a -> a.length);
+ }
+
+ public static <T> OfRef<T> ofCollection(String name, Collection<T> collection) {
+ return new AbstractTestData.RefTestData<>(name, collection, Collection::stream, Collection::parallelStream,
+ Collection::spliterator, Collection::size);
+ }
+
+ public static <T> OfRef<T> ofSpinedBuffer(String name, SpinedBuffer<T> buffer) {
+ return new AbstractTestData.RefTestData<>(name, buffer,
+ b -> StreamSupport.stream(b.spliterator(), false),
+ b -> StreamSupport.stream(b.spliterator(), true),
+ SpinedBuffer::spliterator,
+ b -> (int) b.count());
+ }
+
+ public static <T> OfRef<T> ofSupplier(String name, Supplier<Stream<T>> supplier) {
+ return new AbstractTestData.RefTestData<>(name, supplier,
+ Supplier::get,
+ s -> s.get().parallel(),
+ s -> s.get().spliterator(),
+ s -> (int) s.get().spliterator().getExactSizeIfKnown());
+ }
+
+ public static <T> OfRef<T> ofRefNode(String name, Node<T> node) {
+ return new AbstractTestData.RefTestData<>(name, node,
+ n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, false),
+ n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, true),
+ Node::spliterator,
+ n -> (int) n.count());
+ }
+
+ // int factories
+ public static <T> OfInt ofArray(String name, int[] array) {
+ return new AbstractTestData.IntTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+ Arrays::spliterator, a -> a.length);
+ }
+
+ public static OfInt ofSpinedBuffer(String name, SpinedBuffer.OfInt buffer) {
+ return new AbstractTestData.IntTestData<>(name, buffer,
+ b -> StreamSupport.intStream(b.spliterator(), false),
+ b -> StreamSupport.intStream(b.spliterator(), true),
+ SpinedBuffer.OfInt::spliterator,
+ b -> (int) b.count());
+ }
+
+ public static OfInt ofIntSupplier(String name, Supplier<IntStream> supplier) {
+ return new AbstractTestData.IntTestData<>(name, supplier,
+ Supplier::get,
+ s -> s.get().parallel(),
+ s -> s.get().spliterator(),
+ s -> (int) s.get().spliterator().getExactSizeIfKnown());
+ }
+
+ public static OfInt ofNode(String name, Node.OfInt node) {
+ int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+ return new AbstractTestData.IntTestData<>(name, node,
+ n -> StreamSupport.intStream(n::spliterator, characteristics, false),
+ n -> StreamSupport.intStream(n::spliterator, characteristics, true),
+ Node.OfInt::spliterator,
+ n -> (int) n.count());
+ }
+
+ // long factories
+ public static <T> OfLong ofArray(String name, long[] array) {
+ return new AbstractTestData.LongTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+ Arrays::spliterator, a -> a.length);
+ }
+
+ public static OfLong ofSpinedBuffer(String name, SpinedBuffer.OfLong buffer) {
+ return new AbstractTestData.LongTestData<>(name, buffer,
+ b -> StreamSupport.longStream(b.spliterator(), false),
+ b -> StreamSupport.longStream(b.spliterator(), true),
+ SpinedBuffer.OfLong::spliterator,
+ b -> (int) b.count());
+ }
+
+ public static OfLong ofLongSupplier(String name, Supplier<LongStream> supplier) {
+ return new AbstractTestData.LongTestData<>(name, supplier,
+ Supplier::get,
+ s -> s.get().parallel(),
+ s -> s.get().spliterator(),
+ s -> (int) s.get().spliterator().getExactSizeIfKnown());
+ }
+
+ public static OfLong ofNode(String name, Node.OfLong node) {
+ int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+ return new AbstractTestData.LongTestData<>(name, node,
+ n -> StreamSupport.longStream(n::spliterator, characteristics, false),
+ n -> StreamSupport.longStream(n::spliterator, characteristics, true),
+ Node.OfLong::spliterator,
+ n -> (int) n.count());
+ }
+
+ // double factories
+ public static <T> OfDouble ofArray(String name, double[] array) {
+ return new AbstractTestData.DoubleTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+ Arrays::spliterator, a -> a.length);
+ }
+
+ public static OfDouble ofSpinedBuffer(String name, SpinedBuffer.OfDouble buffer) {
+ return new AbstractTestData.DoubleTestData<>(name, buffer,
+ b -> StreamSupport.doubleStream(b.spliterator(), false),
+ b -> StreamSupport.doubleStream(b.spliterator(), true),
+ SpinedBuffer.OfDouble::spliterator,
+ b -> (int) b.count());
+ }
+
+ public static OfDouble ofDoubleSupplier(String name, Supplier<DoubleStream> supplier) {
+ return new AbstractTestData.DoubleTestData<>(name, supplier,
+ Supplier::get,
+ s -> s.get().parallel(),
+ s -> s.get().spliterator(),
+ s -> (int) s.get().spliterator().getExactSizeIfKnown());
+ }
+
+ public static OfDouble ofNode(String name, Node.OfDouble node) {
+ int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+ return new AbstractTestData.DoubleTestData<>(name, node,
+ n -> StreamSupport.doubleStream(n::spliterator, characteristics, false),
+ n -> StreamSupport.doubleStream(n::spliterator, characteristics, true),
+ Node.OfDouble::spliterator,
+ n -> (int) n.count());
+ }
+ }
+
+
+ abstract class AbstractTestData<T, S extends BaseStream<T, S>,
+ T_STATE,
+ T_SPLITR extends Spliterator<T>>
+ implements TestData<T, S> {
+ private final String name;
+ private final StreamShape shape;
+ protected final T_STATE state;
+ private final ToIntFunction<T_STATE> sizeFn;
+ private final Function<T_STATE, S> streamFn;
+ private final Function<T_STATE, S> parStreamFn;
+ private final Function<T_STATE, T_SPLITR> splitrFn;
+
+ AbstractTestData(String name,
+ StreamShape shape,
+ T_STATE state,
+ Function<T_STATE, S> streamFn,
+ Function<T_STATE, S> parStreamFn,
+ Function<T_STATE, T_SPLITR> splitrFn,
+ ToIntFunction<T_STATE> sizeFn) {
+ this.name = name;
+ this.shape = shape;
+ this.state = state;
+ this.streamFn = streamFn;
+ this.parStreamFn = parStreamFn;
+ this.splitrFn = splitrFn;
+ this.sizeFn = sizeFn;
+ }
+
+ @Override
+ public StreamShape getShape() {
+ return shape;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + name + "]";
+ }
+
+ @Override
+ public int size() {
+ return sizeFn.applyAsInt(state);
+ }
+
+ @Override
+ public T_SPLITR spliterator() {
+ return splitrFn.apply(state);
+ }
+
+ @Override
+ public S stream() {
+ return streamFn.apply(state);
+ }
+
+ @Override
+ public S parallelStream() {
+ return parStreamFn.apply(state);
+ }
+
+ public static class RefTestData<T, I>
+ extends AbstractTestData<T, Stream<T>, I, Spliterator<T>>
+ implements TestData.OfRef<T> {
+
+ protected RefTestData(String name,
+ I state,
+ Function<I, Stream<T>> streamFn,
+ Function<I, Stream<T>> parStreamFn,
+ Function<I, Spliterator<T>> splitrFn,
+ ToIntFunction<I> sizeFn) {
+ super(name, StreamShape.REFERENCE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+ }
+
+ }
+
+ static class IntTestData<I>
+ extends AbstractTestData<Integer, IntStream, I, Spliterator.OfInt>
+ implements TestData.OfInt {
+
+ protected IntTestData(String name,
+ I state,
+ Function<I, IntStream> streamFn,
+ Function<I, IntStream> parStreamFn,
+ Function<I, Spliterator.OfInt> splitrFn,
+ ToIntFunction<I> sizeFn) {
+ super(name, StreamShape.INT_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+ }
+
+ @Override
+ public PrimitiveIterator.OfInt iterator() {
+ return Spliterators.iterator(spliterator());
+ }
+
+ @Override
+ public <A extends Collection<? super Integer>> A into(A target) {
+ spliterator().forEachRemaining((IntConsumer) target::add);
+ return target;
+ }
+ }
+
+ static class LongTestData<I>
+ extends AbstractTestData<Long, LongStream, I, Spliterator.OfLong>
+ implements TestData.OfLong {
+
+ protected LongTestData(String name,
+ I state,
+ Function<I, LongStream> streamFn,
+ Function<I, LongStream> parStreamFn,
+ Function<I, Spliterator.OfLong> splitrFn,
+ ToIntFunction<I> sizeFn) {
+ super(name, StreamShape.LONG_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+ }
+
+ @Override
+ public PrimitiveIterator.OfLong iterator() {
+ return Spliterators.iterator(spliterator());
+ }
+
+ @Override
+ public <A extends Collection<? super Long>> A into(A target) {
+ spliterator().forEachRemaining((LongConsumer) target::add);
+ return target;
+ }
+ }
+
+ static class DoubleTestData<I>
+ extends AbstractTestData<Double, DoubleStream, I, Spliterator.OfDouble>
+ implements OfDouble {
+
+ protected DoubleTestData(String name,
+ I state,
+ Function<I, DoubleStream> streamFn,
+ Function<I, DoubleStream> parStreamFn,
+ Function<I, Spliterator.OfDouble> splitrFn,
+ ToIntFunction<I> sizeFn) {
+ super(name, StreamShape.DOUBLE_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+ }
+
+ @Override
+ public PrimitiveIterator.OfDouble iterator() {
+ return Spliterators.iterator(spliterator());
+ }
+
+ @Override
+ public <A extends Collection<? super Double>> A into(A target) {
+ spliterator().forEachRemaining((DoubleConsumer) target::add);
+ return target;
+ }
+ }
+ }
+}
diff --git a/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/TestFlagExpectedOp.java b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/TestFlagExpectedOp.java
new file mode 100644
index 0000000..aea0baf
--- /dev/null
+++ b/ojluni/src/test/java/util/stream/testlib/org/openjdk/testlib/java/util/stream/TestFlagExpectedOp.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012, 2013, 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.
+ *
+ * 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 org.openjdk.testlib.java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.EnumSet;
+import java.util.stream.*;
+
+class TestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
+
+ static class Builder<T> {
+ final int flags;
+ StreamShape shape = StreamShape.REFERENCE;
+
+ EnumSet<StreamOpFlag> known = EnumSet.noneOf(StreamOpFlag.class);
+ EnumSet<StreamOpFlag> preserve = EnumSet.noneOf(StreamOpFlag.class);
+ EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
+
+ Builder(int flags) {
+ this.flags = flags;
+ }
+
+ Builder<T> known(EnumSet<StreamOpFlag> known) {
+ this.known = known;
+ return this;
+ }
+
+ Builder<T> preserve(EnumSet<StreamOpFlag> preserve) {
+ this.preserve = preserve;
+ return this;
+ }
+
+ Builder<T> notKnown(EnumSet<StreamOpFlag> notKnown) {
+ this.notKnown = notKnown;
+ return this;
+ }
+
+ Builder<T> shape(StreamShape shape) {
+ this.shape = shape;
+ return this;
+ }
+
+ TestFlagExpectedOp<T> build() {
+ return new TestFlagExpectedOp<>(flags, known, preserve, notKnown, shape);
+ }
+ }
+
+ final EnumSet<StreamOpFlag> known;
+ final EnumSet<StreamOpFlag> preserve;
+ final EnumSet<StreamOpFlag> notKnown;
+ final StreamShape shape;
+
+ TestFlagExpectedOp(int flags,
+ EnumSet<StreamOpFlag> known,
+ EnumSet<StreamOpFlag> preserve,
+ EnumSet<StreamOpFlag> notKnown) {
+ this(flags, known, preserve, notKnown, StreamShape.REFERENCE);
+ }
+
+ TestFlagExpectedOp(int flags,
+ EnumSet<StreamOpFlag> known,
+ EnumSet<StreamOpFlag> preserve,
+ EnumSet<StreamOpFlag> notKnown,
+ StreamShape shape) {
+ super(flags);
+ this.known = known;
+ this.preserve = preserve;
+ this.notKnown = notKnown;
+ this.shape = shape;
+ }
+
+ @Override
+ public StreamShape outputShape() {
+ return shape;
+ }
+
+ @Override
+ public StreamShape inputShape() {
+ return shape;
+ }
+
+ @Override
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public Sink<T> opWrapSink(int flags, boolean parallel, Sink upstream) {
+ assertFlags(flags);
+ return upstream;
+ }
+
+ private void assertFlags(int flags) {
+ for (StreamOpFlag f : known) {
+ Assert.assertTrue(f.isKnown(flags),
+ String.format("Flag %s is not known, but should be known.", f.toString()));
+ }
+
+ for (StreamOpFlag f : preserve) {
+ Assert.assertTrue(f.isPreserved(flags),
+ String.format("Flag %s is not preserved, but should be preserved.", f.toString()));
+ }
+
+ for (StreamOpFlag f : notKnown) {
+ Assert.assertFalse(f.isKnown(flags),
+ String.format("Flag %s is known, but should be not known.", f.toString()));
+ }
+ }
+}
diff --git a/ojluni/src/test/test-output/emailable-report.html b/ojluni/src/test/test-output/emailable-report.html
deleted file mode 100644
index ea52d70..0000000
--- a/ojluni/src/test/test-output/emailable-report.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"><head><title>TestNG Report</title><style type="text/css">table {margin-bottom:10px;border-collapse:collapse;empty-cells:show}th,td {border:1px solid #009;padding:.25em .5em}th {vertical-align:bottom}td {vertical-align:top}table a {font-weight:bold}.stripe td {background-color: #E6EBF9}.num {text-align:right}.passedodd td {background-color: #3F3}.passedeven td {background-color: #0A0}.skippedodd td {background-color: #DDD}.skippedeven td {background-color: #CCC}.failedodd td,.attn {background-color: #F33}.failedeven td,.stripe .attn {background-color: #D00}.stacktrace {white-space:pre;font-family:monospace}.totop {font-size:85%;text-align:center;border-bottom:2px solid #000}</style></head><body><table><tr><th>Test</th><th># Passed</th><th># Skipped</th><th># Failed</th><th>Time (ms)</th><th>Included Groups</th><th>Excluded Groups</th></tr></table><table><thead><tr><th>Class</th><th>Method</th><th>Start</th><th>Time (ms)</th></tr></thead></table></body></html>
\ No newline at end of file
diff --git a/ojluni/src/test/test-output/old/index.html b/ojluni/src/test/test-output/old/index.html
deleted file mode 100644
index 981b559..0000000
--- a/ojluni/src/test/test-output/old/index.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-<head><title>Test results</title><link href="./testng.css" rel="stylesheet" type="text/css" />
-<link href="./my-testng.css" rel="stylesheet" type="text/css" />
-</head><body>
-<h2><p align='center'>Test results</p></h2>
-<table border='1' width='100%' class='main-page'><tr><th>Suite</th><th>Passed</th><th>Failed</th><th>Skipped</th><th>testng.xml</th></tr>
-<tr align='center' class='invocation-failed'><td><em>Total</em></td><td><em>0</em></td><td><em>0</em></td><td><em>0</em></td><td> </td></tr>
-</table></body></html>
diff --git a/ojluni/src/test/test-output/testng-results.xml b/ojluni/src/test/test-output/testng-results.xml
deleted file mode 100644
index 1c245d8..0000000
--- a/ojluni/src/test/test-output/testng-results.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<testng-results skipped="0" failed="0" total="0" passed="0">
- <reporter-output>
- </reporter-output>
-</testng-results>