8022446: Fix serial warnings in java.util.stream
authorhenryjen
Tue, 06 Aug 2013 17:42:47 -0700
changeset 19218 8e7212b90b81
parent 19217 e1b733e060c6
child 19219 0d4231d25a29
8022446: Fix serial warnings in java.util.stream Reviewed-by: darcy
jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java
jdk/src/share/classes/java/util/stream/AbstractTask.java
jdk/src/share/classes/java/util/stream/FindOps.java
jdk/src/share/classes/java/util/stream/ForEachOps.java
jdk/src/share/classes/java/util/stream/MatchOps.java
jdk/src/share/classes/java/util/stream/Nodes.java
jdk/src/share/classes/java/util/stream/ReduceOps.java
jdk/src/share/classes/java/util/stream/SliceOps.java
--- a/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/AbstractShortCircuitTask.java	Tue Aug 06 17:42:47 2013 -0700
@@ -39,6 +39,7 @@
  * @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> {
--- a/jdk/src/share/classes/java/util/stream/AbstractTask.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/AbstractTask.java	Tue Aug 06 17:42:47 2013 -0700
@@ -73,6 +73,9 @@
  *     }
  * }</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 @@
  * @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> {
--- a/jdk/src/share/classes/java/util/stream/FindOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/FindOps.java	Tue Aug 06 17:42:47 2013 -0700
@@ -246,6 +246,7 @@
      * @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;
--- a/jdk/src/share/classes/java/util/stream/ForEachOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/ForEachOps.java	Tue Aug 06 17:42:47 2013 -0700
@@ -249,6 +249,7 @@
     }
 
     /** 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 @@
      * 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;
--- a/jdk/src/share/classes/java/util/stream/MatchOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/MatchOps.java	Tue Aug 06 17:42:47 2013 -0700
@@ -274,6 +274,7 @@
      * @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;
--- a/jdk/src/share/classes/java/util/stream/Nodes.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/Nodes.java	Tue Aug 06 17:42:47 2013 -0700
@@ -1786,6 +1786,10 @@
         }
     }
 
+    /*
+     * 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 @@
             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 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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 @@
         }
     }
 
+    @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 @@
             }
         }
 
+        @SuppressWarnings("serial")
         private static final class OfRef<T>
                 extends ToArrayTask<T, Node<T>, OfRef<T>> {
             private final T[] array;
@@ -2050,6 +2060,7 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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 @@
         }
     }
 
+    @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 @@
             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 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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 @@
             }
         }
 
+        @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) {
--- a/jdk/src/share/classes/java/util/stream/ReduceOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/ReduceOps.java	Tue Aug 06 17:42:47 2013 -0700
@@ -43,7 +43,7 @@
 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 @@
     /**
      * 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>> {
--- a/jdk/src/share/classes/java/util/stream/SliceOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/jdk/src/share/classes/java/util/stream/SliceOps.java	Tue Aug 06 17:42:47 2013 -0700
@@ -550,6 +550,7 @@
      * @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;