groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Fix compilation error due to Java8's syntax
Date Tue, 23 Jan 2018 13:55:39 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X d1f987b43 -> ad266949e


Fix compilation error due to Java8's syntax

(cherry picked from commit 6efab2b)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ad266949
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ad266949
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ad266949

Branch: refs/heads/GROOVY_2_5_X
Commit: ad266949ea297fc36284ca44cbb7e69388561dfd
Parents: d1f987b
Author: sunlan <sunlan@apache.org>
Authored: Tue Jan 23 21:54:59 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Jan 23 21:55:34 2018 +0800

----------------------------------------------------------------------
 .../vmplugin/v8/PluginDefaultGroovyMethods.java | 58 +++++++++++++++++---
 1 file changed, 49 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ad266949/src/main/java/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
b/src/main/java/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
index 6c15626..ff6491f 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
@@ -18,12 +18,12 @@
  */
 package org.codehaus.groovy.vmplugin.v8;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
-import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 /**
@@ -88,7 +88,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Integer> stream(int[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Integer> list = new ArrayList<>(self.length);
+        for (int e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -99,7 +104,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Long> stream(long[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Long> list = new ArrayList<>(self.length);
+        for (long e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -110,7 +120,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Double> stream(double[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Double> list = new ArrayList<>(self.length);
+        for (double e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -121,7 +136,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Character> stream(char[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Character> list = new ArrayList<>(self.length);
+        for (char e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -132,7 +152,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Byte> stream(byte[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Byte> list = new ArrayList<>(self.length);
+        for (byte e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -143,7 +168,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Short> stream(short[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Short> list = new ArrayList<>(self.length);
+        for (short e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -154,7 +184,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Boolean> stream(boolean[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Boolean> list = new ArrayList<>(self.length);
+        for (boolean e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
     /**
@@ -165,7 +200,12 @@ public class PluginDefaultGroovyMethods {
      * @return a {@code Stream} for the array
      */
     public static Stream<Float> stream(float[] self) {
-        return IntStream.range(0, self.length).mapToObj(i -> self[i]);
+        List<Float> list = new ArrayList<>(self.length);
+        for (float e : self) {
+            list.add(e);
+        }
+
+        return list.stream();
     }
 
 }


Mime
View raw message