提交 0d8b6ec9 编写于 作者: H henryjen

8022446: Fix serial warnings in java.util.stream

Reviewed-by: darcy
上级 40ea1ff2
......@@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicReference;
* @param <K> type of child and sibling tasks
* @since 1.8
*/
@SuppressWarnings("serial")
abstract class AbstractShortCircuitTask<P_IN, P_OUT, R,
K extends AbstractShortCircuitTask<P_IN, P_OUT, R, K>>
extends AbstractTask<P_IN, P_OUT, R, K> {
......
......@@ -73,6 +73,9 @@ import java.util.concurrent.ForkJoinPool;
* }
* }</pre>
*
* <p>Serialization is not supported as there is no intention to serialize
* tasks managed by stream ops.
*
* @param <P_IN> Type of elements input to the pipeline
* @param <P_OUT> Type of elements output from the pipeline
* @param <R> Type of intermediate result, which may be different from operation
......@@ -80,6 +83,7 @@ import java.util.concurrent.ForkJoinPool;
* @param <K> Type of parent, child and sibling tasks
* @since 1.8
*/
@SuppressWarnings("serial")
abstract class AbstractTask<P_IN, P_OUT, R,
K extends AbstractTask<P_IN, P_OUT, R, K>>
extends CountedCompleter<R> {
......
......@@ -246,6 +246,7 @@ final class FindOps {
* @param <P_OUT> Output element type from the stream pipeline
* @param <O> Result type from the find operation
*/
@SuppressWarnings("serial")
private static final class FindTask<P_IN, P_OUT, O>
extends AbstractShortCircuitTask<P_IN, P_OUT, O, FindTask<P_IN, P_OUT, O>> {
private final FindOp<P_OUT, O> op;
......
......@@ -249,6 +249,7 @@ final class ForEachOps {
}
/** A {@code ForkJoinTask} for performing a parallel for-each operation */
@SuppressWarnings("serial")
static final class ForEachTask<S, T> extends CountedCompleter<Void> {
private Spliterator<S> spliterator;
private final Sink<S> sink;
......@@ -314,6 +315,7 @@ final class ForEachOps {
* A {@code ForkJoinTask} for performing a parallel for-each operation
* which visits the elements in encounter order
*/
@SuppressWarnings("serial")
static final class ForEachOrderedTask<S, T> extends CountedCompleter<Void> {
private final PipelineHelper<T> helper;
private Spliterator<S> spliterator;
......
......@@ -274,6 +274,7 @@ final class MatchOps {
* @param <P_IN> the type of source elements for the pipeline
* @param <P_OUT> the type of output elements for the pipeline
*/
@SuppressWarnings("serial")
private static final class MatchTask<P_IN, P_OUT>
extends AbstractShortCircuitTask<P_IN, P_OUT, Boolean, MatchTask<P_IN, P_OUT>> {
private final MatchOp<P_OUT> op;
......
......@@ -1786,6 +1786,10 @@ final class Nodes {
}
}
/*
* This and subclasses are not intended to be serializable
*/
@SuppressWarnings("serial")
private static abstract class SizedCollectorTask<P_IN, P_OUT, T_SINK extends Sink<P_OUT>,
K extends SizedCollectorTask<P_IN, P_OUT, T_SINK, K>>
extends CountedCompleter<Void>
......@@ -1855,6 +1859,7 @@ final class Nodes {
fence = (int) offset + (int) length;
}
@SuppressWarnings("serial")
static final class OfRef<P_IN, P_OUT>
extends SizedCollectorTask<P_IN, P_OUT, Sink<P_OUT>, OfRef<P_IN, P_OUT>>
implements Sink<P_OUT> {
......@@ -1886,6 +1891,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
static final class OfInt<P_IN>
extends SizedCollectorTask<P_IN, Integer, Sink.OfInt, OfInt<P_IN>>
implements Sink.OfInt {
......@@ -1917,6 +1923,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
static final class OfLong<P_IN>
extends SizedCollectorTask<P_IN, Long, Sink.OfLong, OfLong<P_IN>>
implements Sink.OfLong {
......@@ -1948,6 +1955,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
static final class OfDouble<P_IN>
extends SizedCollectorTask<P_IN, Double, Sink.OfDouble, OfDouble<P_IN>>
implements Sink.OfDouble {
......@@ -1980,6 +1988,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static abstract class ToArrayTask<T, T_NODE extends Node<T>,
K extends ToArrayTask<T, T_NODE, K>>
extends CountedCompleter<Void> {
......@@ -2025,6 +2034,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfRef<T>
extends ToArrayTask<T, Node<T>, OfRef<T>> {
private final T[] array;
......@@ -2050,6 +2060,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static class OfPrimitive<T, T_CONS, T_ARR,
T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>,
T_NODE extends Node.OfPrimitive<T, T_CONS, T_ARR, T_SPLITR, T_NODE>>
......@@ -2077,6 +2088,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfInt
extends OfPrimitive<Integer, IntConsumer, int[], Spliterator.OfInt, Node.OfInt> {
private OfInt(Node.OfInt node, int[] array, int offset) {
......@@ -2084,6 +2096,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfLong
extends OfPrimitive<Long, LongConsumer, long[], Spliterator.OfLong, Node.OfLong> {
private OfLong(Node.OfLong node, long[] array, int offset) {
......@@ -2091,6 +2104,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfDouble
extends OfPrimitive<Double, DoubleConsumer, double[], Spliterator.OfDouble, Node.OfDouble> {
private OfDouble(Node.OfDouble node, double[] array, int offset) {
......@@ -2099,6 +2113,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static class CollectorTask<P_IN, P_OUT, T_NODE extends Node<P_OUT>, T_BUILDER extends Node.Builder<P_OUT>>
extends AbstractTask<P_IN, P_OUT, T_NODE, CollectorTask<P_IN, P_OUT, T_NODE, T_BUILDER>> {
protected final PipelineHelper<P_OUT> helper;
......@@ -2141,6 +2156,7 @@ final class Nodes {
super.onCompletion(caller);
}
@SuppressWarnings("serial")
private static final class OfRef<P_IN, P_OUT>
extends CollectorTask<P_IN, P_OUT, Node<P_OUT>, Node.Builder<P_OUT>> {
OfRef(PipelineHelper<P_OUT> helper,
......@@ -2150,6 +2166,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfInt<P_IN>
extends CollectorTask<P_IN, Integer, Node.OfInt, Node.Builder.OfInt> {
OfInt(PipelineHelper<Integer> helper, Spliterator<P_IN> spliterator) {
......@@ -2157,6 +2174,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfLong<P_IN>
extends CollectorTask<P_IN, Long, Node.OfLong, Node.Builder.OfLong> {
OfLong(PipelineHelper<Long> helper, Spliterator<P_IN> spliterator) {
......@@ -2164,6 +2182,7 @@ final class Nodes {
}
}
@SuppressWarnings("serial")
private static final class OfDouble<P_IN>
extends CollectorTask<P_IN, Double, Node.OfDouble, Node.Builder.OfDouble> {
OfDouble(PipelineHelper<Double> helper, Spliterator<P_IN> spliterator) {
......
......@@ -43,7 +43,7 @@ import java.util.function.ObjLongConsumer;
import java.util.function.Supplier;
/**
* Factory for the creating instances of {@code TerminalOp) that implement
* Factory for creating instances of {@code TerminalOp} that implement
* reductions.
*
* @since 1.8
......@@ -718,6 +718,7 @@ final class ReduceOps {
/**
* A {@code ForkJoinTask} for performing a parallel reduce operation.
*/
@SuppressWarnings("serial")
private static final class ReduceTask<P_IN, P_OUT, R,
S extends AccumulatingSink<P_OUT, R, S>>
extends AbstractTask<P_IN, P_OUT, S, ReduceTask<P_IN, P_OUT, R, S>> {
......
......@@ -550,6 +550,7 @@ final class SliceOps {
* @param <P_IN> Input element type to the stream pipeline
* @param <P_OUT> Output element type from the stream pipeline
*/
@SuppressWarnings("serial")
private static final class SliceTask<P_IN, P_OUT>
extends AbstractShortCircuitTask<P_IN, P_OUT, Node<P_OUT>, SliceTask<P_IN, P_OUT>> {
private final AbstractPipeline<P_OUT, P_OUT, ?> op;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册