changeset 8288:6e7e8ae1494b

Fix IntStream's compilation error
author tyan
date Mon, 22 Apr 2013 22:12:25 +0800
parents d01bdf1b0f50
children 70ed67c54fa6
files test/java/nio/Files/FilesLambdaTest.java test/java/util/stream/Stream/IntStreamTest.java
diffstat 2 files changed, 57 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/nio/Files/FilesLambdaTest.java	Sun Apr 21 20:22:10 2013 -0400
+++ b/test/java/nio/Files/FilesLambdaTest.java	Mon Apr 22 22:12:25 2013 +0800
@@ -264,7 +264,6 @@
                 = Files.find(walkFolder, maxDepth, (p,bfa) -> Files.isSymbolicLink(p));
         stream.forEach(p -> {
             assertTrue(Files.isSymbolicLink(p));
-            assertFalse(Files.isExecutable(p));
             assertFalse(Files.isDirectory(p));
             assertFalse(Files.isRegularFile(p, LinkOption.NOFOLLOW_LINKS));
             String parentName = p.getParent().toFile().getName();
--- a/test/java/util/stream/Stream/IntStreamTest.java	Sun Apr 21 20:22:10 2013 -0400
+++ b/test/java/util/stream/Stream/IntStreamTest.java	Mon Apr 22 22:12:25 2013 +0800
@@ -124,7 +124,7 @@
             int[] array = generateData(ARRAY_SIZE);
             int limit = rand.nextInt();
             boolean isUP = rand.nextBoolean();
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             assertEquals(stream1.allMatch(LambdaUtilities.randomIntPredicate(isUP, limit)),
@@ -132,7 +132,7 @@
 
             int startIndex = rand.nextInt(array.length);
             int endIndex = startIndex + rand.nextInt(array.length - startIndex + 1);
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array, startIndex, endIndex)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array, startIndex, endIndex).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array, startIndex, endIndex).sequential() :
                     Arrays.stream(array, startIndex, endIndex);
             assertEquals(stream2.allMatch(LambdaUtilities.randomIntPredicate(isUP, limit)),
@@ -148,7 +148,7 @@
             int[] array = generateData(ARRAY_SIZE);
             int limit = rand.nextInt();
             boolean isUP = rand.nextBoolean();
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             assertEquals(stream1.anyMatch(LambdaUtilities.randomIntPredicate(isUP, limit)),
@@ -156,7 +156,7 @@
 
             int startIndex = rand.nextInt(array.length);
             int endIndex = startIndex + rand.nextInt(array.length - startIndex + 1);
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array, startIndex, endIndex)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array, startIndex, endIndex).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array, startIndex, endIndex).sequential() :
                     Arrays.stream(array, startIndex, endIndex);
             assertEquals(stream2.anyMatch(LambdaUtilities.randomIntPredicate(isUP, limit)),
@@ -170,10 +170,10 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream sumStream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream sumStream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
-            IntStream avgStream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream avgStream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             double total1 = 0;
@@ -187,10 +187,10 @@
 
             int startIndex = rand.nextInt(array.length);
             int endIndex = startIndex + rand.nextInt(array.length - startIndex + 1);
-            IntStream sumStream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array, startIndex, endIndex)
+            IntStream sumStream2 = (p == ParallelType.Parallel) ? Arrays.stream(array, startIndex, endIndex).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array, startIndex, endIndex).sequential() :
                     Arrays.stream(array, startIndex, endIndex);
-            IntStream avgStream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array, startIndex, endIndex)
+            IntStream avgStream2 = (p == ParallelType.Parallel) ? Arrays.stream(array, startIndex, endIndex).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array, startIndex, endIndex).sequential() :
                     Arrays.stream(array, startIndex, endIndex);
             if(endIndex == startIndex){
@@ -216,7 +216,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             Object[] boxedArr1 = stream1.boxed().toArray();
@@ -226,7 +226,7 @@
 
             int startIndex = rand.nextInt(array.length);
             int endIndex = startIndex + rand.nextInt(array.length - startIndex + 1);
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array, startIndex, endIndex)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array, startIndex, endIndex).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array, startIndex, endIndex).sequential() :
                     Arrays.stream(array, startIndex, endIndex);
             Object[] boxedArr2 = stream2.boxed().toArray();
@@ -242,7 +242,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int limit1 = rand.nextInt();
@@ -251,13 +251,13 @@
             int[] filtered =stream1.filter(p1).toArray();
             assertTrue(verifyMatch(filtered, limit1, isUP1, true , 0, filtered.length));
 
-            stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int[] filteredNegate =stream1.filter(p1.negate()).toArray();
             assertTrue(verifyMatch(filteredNegate, limit1, !isUP1, true , 0, filteredNegate.length));
 
-            stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int limit2 = rand.nextInt();
@@ -266,7 +266,7 @@
             assertTrue(verifyMatch(stream1.filter(p1.and(p2)).toArray(), limit1, isUP1,
                     limit2, isUP2, true, true));
 
-            stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int limit3 = rand.nextInt();
@@ -283,10 +283,10 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             OptionalInt opAny = stream1.findAny();
@@ -297,10 +297,10 @@
                 assertEquals(opAny, opFirst);
 
             int[] emptyArray = new int[0];
-            IntStream emptyStream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(emptyArray)
+            IntStream emptyStream1 = (p == ParallelType.Parallel) ? Arrays.stream(emptyArray).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(emptyArray).sequential() :
                     Arrays.stream(emptyArray);
-            IntStream emptyStream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(emptyArray)
+            IntStream emptyStream2 = (p == ParallelType.Parallel) ? Arrays.stream(emptyArray).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(emptyArray).sequential() :
                     Arrays.stream(emptyArray);
             assertFalse(emptyStream1.findAny().isPresent());
@@ -314,14 +314,14 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             final int[] array = generateData(ARRAY_SIZE);
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             Arrays.parallelSort(array);
             stream.forEach(t -> { assertTrue(Arrays.binarySearch(array, t) >= 0); });
 
             int[] emptyArray = new int[0];
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(emptyArray)
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(emptyArray).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(emptyArray).sequential() :
                     Arrays.stream(emptyArray);
             ArrayList<Integer> touch = new ArrayList<>();
@@ -340,10 +340,10 @@
             for(int i = 0; i < ARRAY_SIZE; i++) {
                 array[i] = i + 1;
             }
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int limit = rand.nextInt(ARRAY_SIZE * (ARRAY_SIZE - 1));
@@ -365,7 +365,7 @@
             int[] array = new int[END];
             for(int i = 0; i < array.length; i++)
                 array[i] = i + 1;
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int selected = rand.nextInt(5);
@@ -380,7 +380,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int randOps = rand.nextInt();
@@ -388,10 +388,10 @@
             LambdaUtilities.IntOp op = LambdaUtilities.IntOp.values()[selected];
             int[] opArray1 = stream1.map(LambdaUtilities.opIntUnaryOperator(op, randOps)).toArray();
             verifyAfterOps(array, opArray1, op, randOps);
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
-            IntStream stream3 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream3 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             Object[] objArray1 = stream2.map(LambdaUtilities.opIntUnaryOperator(op, randOps)).boxed().toArray();
@@ -409,7 +409,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             final int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             OptionalInt max = stream1.max();
@@ -417,7 +417,7 @@
             assertEquals(max.getAsInt(), getMax2(array));
             assertEquals(max.getAsInt(), getMax3(array));
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             assertFalse(emptyStream.max().isPresent());
@@ -430,7 +430,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             final int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             OptionalInt min = stream1.min();
@@ -438,7 +438,7 @@
             assertEquals(min.getAsInt(), getMin2(array));
             assertEquals(min.getAsInt(), getMin3(array));
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             //We should consider it as bug, it should throw Exception, will make
@@ -455,13 +455,13 @@
             final int[] array = generateData(ARRAY_SIZE);
             int limit = rand.nextInt();
             boolean isUP = rand.nextBoolean();
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             assertEquals(stream.noneMatch(LambdaUtilities.randomIntPredicate(isUP, limit)),
                     verifyMatch(array, limit, !isUP, true , 0, array.length));
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             //We should consider it as bug, it should throw Exception, will make
@@ -476,7 +476,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             final int[] array = generateData(ARRAY_SIZE);
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int[] calArr = StreamSupport.intStream(stream.spliterator()).toArray();
@@ -494,7 +494,7 @@
                 continue;
             final int[] array = generateData(ARRAY_SIZE);
             int base = rand.nextInt();
-            IntStream streamPlus = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream streamPlus = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int oiPlus = streamPlus.reduce(base, LambdaUtilities.addIntBinaryOperator());
@@ -503,7 +503,7 @@
                 total += array[index];
             assertEquals(oiPlus, total + base);
 
-            IntStream streamSubtract = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream streamSubtract = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int oiSubtract = streamSubtract.reduce(base, LambdaUtilities.subIntBinaryOperator());
@@ -512,7 +512,7 @@
                 subTotal -= array[index];
             assertEquals(oiSubtract, subTotal);
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             int emptyByBase = emptyStream.reduce(base, rand.nextBoolean() ?
@@ -528,7 +528,7 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             final int[] array = generateData(ARRAY_SIZE);
-            IntStream streamPlus = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream streamPlus = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             OptionalInt oiPlus = streamPlus.reduce(LambdaUtilities.addIntBinaryOperator());
@@ -543,7 +543,7 @@
             if(p == ParallelType.Parallel)
                 continue;
 
-            IntStream streamSubtract = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream streamSubtract = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             OptionalInt oiSubtract = streamSubtract.reduce(LambdaUtilities.subIntBinaryOperator());
@@ -553,7 +553,7 @@
                 subTotal -= array[index];
             assertEquals(oiSubtract.getAsInt(), subTotal);
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             OptionalInt emptyOp = emptyStream.reduce(rand.nextBoolean() ?
@@ -575,24 +575,24 @@
             int limit = rand.nextBoolean() ?
                     bf.apply(0, ARRAY_SIZE - skip) :
                     rand.nextInt(Integer.MAX_VALUE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int[] toArray = stream1.substream(skip, skip + limit).toArray();
             verifySlice(array, toArray, skip, limit);
 
-            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream2 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             assertEquals(stream2.substream(skip, skip).toArray().length, 0);
 
-            IntStream stream3 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream3 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int skipExceeded = bf.apply(ARRAY_SIZE, Integer.MAX_VALUE);
             assertEquals(stream3.substream(skipExceeded, skipExceeded + 1).toArray().length, 0);
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             //We should consider it as bug, it should throw Exception, will make
@@ -607,12 +607,12 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             final int[] array = generateData(ARRAY_SIZE);
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             checkSorted(stream.sorted().toArray());
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0])
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             //We should consider it as bug, it should throw Exception, will make
@@ -627,14 +627,14 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream1 = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             AtomicInteger ai1 = new AtomicInteger(0);
             int sum = stream1.peek(LambdaUtilities.addIntConsumer(ai1)).sum();
             assertEquals(ai1.get(), sum);
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0]):
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel():
                     (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             assertFalse(emptyStream.peek(LambdaUtilities.addIntConsumer(ai1)).iterator().hasNext());
@@ -648,13 +648,13 @@
         while(it.hasNext()) {
             ParallelType p = it.next();
             int[] array = generateData(ARRAY_SIZE);
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array)
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
                     : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
                     Arrays.stream(array);
             int[] toArray = stream.toArray();
             assertEquals(toArray, array);
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0]):
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel():
                     (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             assertEquals(emptyStream.toArray().length, 0);
@@ -669,15 +669,15 @@
             //Sometimes we can find duplicate value in array generated by
             //generateData, this could be a Random's bug, need track it in other
             //test
-            int[] array1 = Arrays.stream(generateData(ARRAY_SIZE)).distinct().toArray();
-            IntStream stream = (p == ParallelType.Parallel) ? Arrays.parallelStream(array1)
-                    : (p == ParallelType.Sequential) ? Arrays.stream(array1).sequential() :
-                    Arrays.stream(array1);
+            int[] array = Arrays.stream(generateData(ARRAY_SIZE)).distinct().toArray();
+            IntStream stream = (p == ParallelType.Parallel) ? Arrays.stream(array).parallel()
+                    : (p == ParallelType.Sequential) ? Arrays.stream(array).sequential() :
+                    Arrays.stream(array);
             int[] toArray1 = stream.flatMap(genIntFlatMapper(4)).distinct().toArray();
-            assertEquals(toArray1, array1);
+            assertEquals(toArray1, array);
 
-            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.parallelStream(new int[0]):
-                    (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
+            IntStream emptyStream = (p == ParallelType.Parallel) ? Arrays.stream(new int[0]).parallel()
+                    : (p == ParallelType.Sequential) ? Arrays.stream(new int[0]).sequential() :
                     Arrays.stream(new int[0]);
             assertEquals(emptyStream.flatMap(genIntFlatMapper(4)).distinct().toArray().length, 0);
         }
@@ -824,4 +824,4 @@
                 return e -> IntStream.range(0, 1 << 6).map(i -> e);
         }
     }
-}
+}
\ No newline at end of file