changeset 7817:e303c228bf31

8022446: Fix serial warnings in java.util.stream Reviewed-by: darcy
author henryjen
date Tue, 06 Aug 2013 17:42:47 -0700
parents 7ab5f19a9a31
children 1d21ff5c2b3f
files src/share/classes/java/util/stream/AbstractShortCircuitTask.java src/share/classes/java/util/stream/AbstractTask.java src/share/classes/java/util/stream/FindOps.java src/share/classes/java/util/stream/ForEachOps.java src/share/classes/java/util/stream/MatchOps.java src/share/classes/java/util/stream/Nodes.java src/share/classes/java/util/stream/ReduceOps.java src/share/classes/java/util/stream/SliceOps.java
diffstat 8 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/AbstractShortCircuitTask.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/AbstractTask.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/FindOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/ForEachOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/MatchOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/Nodes.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/ReduceOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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/src/share/classes/java/util/stream/SliceOps.java	Tue Aug 06 17:13:07 2013 -0700
+++ b/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;