felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1763127 - in /felix/trunk/gogo/runtime: ./ src/main/java/org/apache/felix/gogo/api/ src/main/java/org/apache/felix/gogo/runtime/ src/main/java/org/apache/felix/service/command/ src/test/java/org/apache/felix/gogo/runtime/
Date Mon, 03 Oct 2016 08:23:18 GMT
Author: gnodet
Date: Mon Oct  3 08:23:18 2016
New Revision: 1763127

URL: http://svn.apache.org/viewvc?rev=1763127&view=rev
Log:
[gogo-runtime] Downgrade the requirement to java 7 for wider adoption
(we can always revert this commit later on)

Modified:
    felix/trunk/gogo/runtime/pom.xml
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/service/command/CommandSession.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java
    felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java

Modified: felix/trunk/gogo/runtime/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/pom.xml?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/pom.xml (original)
+++ felix/trunk/gogo/runtime/pom.xml Mon Oct  3 08:23:18 2016
@@ -90,8 +90,8 @@
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
+                    <source>1.7</source>
+                    <target>1.7</target>
                 </configuration>
             </plugin>
         </plugins>

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java Mon Oct  3 08:23:18
2016
@@ -25,18 +25,18 @@ import org.apache.felix.service.command.
 public interface Job
 {
 
-    /**
-     * Get the job running in the current thread or null.
-     */
-    static Job current()
-    {
-        Process p = Process.current();
-        Job j = p != null ? p.job() : null;
-        while (j != null && j.parent() != null)
-        {
-            j = j.parent();
+    class Utils {
+        /**
+         * Get the job running in the current thread or null.
+         */
+        public static Job current() {
+            Process p = Process.Utils.current();
+            Job j = p != null ? p.job() : null;
+            while (j != null && j.parent() != null) {
+                j = j.parent();
+            }
+            return j;
         }
-        return j;
     }
 
     enum Status

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java Mon Oct
 3 08:23:18 2016
@@ -26,9 +26,10 @@ import org.apache.felix.gogo.runtime.Pip
 public interface Process
 {
 
-    static Process current()
-    {
-        return Pipe.getCurrentPipe();
+    class Utils {
+        public static Process current() {
+            return Pipe.getCurrentPipe();
+        }
     }
 
     InputStream in();

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
Mon Oct  3 08:23:18 2016
@@ -249,7 +249,7 @@ public class CommandProcessorImpl implem
         Map<Object, Integer> cmdMap = commands.get(key);
         if (cmdMap == null)
         {
-            commands.putIfAbsent(key, new LinkedHashMap<>());
+            commands.putIfAbsent(key, new LinkedHashMap<Object, Integer>());
             cmdMap = commands.get(key);
         }
         cmdMap.put(target, ranking);

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
Mon Oct  3 08:23:18 2016
@@ -49,7 +49,6 @@ import java.util.concurrent.ExecutionExc
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-import java.util.stream.Collectors;
 
 import org.apache.felix.gogo.api.Job;
 import org.apache.felix.gogo.api.Job.Status;
@@ -498,13 +497,13 @@ public class CommandSessionImpl implemen
     {
         synchronized (jobs)
         {
-            return Collections.unmodifiableList(jobs);
+            return Collections.<Job>unmodifiableList(jobs);
         }
     }
 
     public static JobImpl currentJob()
     {
-        return (JobImpl) Job.current();
+        return (JobImpl) Job.Utils.current();
     }
 
     @Override
@@ -515,10 +514,12 @@ public class CommandSessionImpl implemen
         {
             jobs = new ArrayList<>(this.jobs);
         }
-        return jobs.stream()
-                    .filter(j -> j.parent == null && j.status() == Status.Foreground)
-                    .findFirst()
-                    .orElse(null);
+        for (JobImpl j : jobs) {
+            if (j.parent == null && j.status() == Status.Foreground) {
+                return j;
+            }
+        }
+        return null;
     }
 
     @Override
@@ -740,7 +741,13 @@ public class CommandSessionImpl implemen
                     foreground();
                     break;
             }
-            future = executor.submit(this::call);
+            future = executor.submit(new Callable<Void>() {
+                @Override
+                public Void call() throws Exception {
+                    JobImpl.this.call();
+                    return null;
+                }
+            });
             while (this.status == Status.Foreground)
             {
                 JobImpl.this.wait();
@@ -750,7 +757,7 @@ public class CommandSessionImpl implemen
 
         public List<Process> processes()
         {
-            return Collections.unmodifiableList(pipes);
+            return Collections.<Process>unmodifiableList(pipes);
         }
 
         @Override
@@ -767,7 +774,7 @@ public class CommandSessionImpl implemen
             {
                 thread.setName("job controller " + id);
 
-                List<Callable<Result>> wrapped = pipes.stream().collect(Collectors.toList());
+                List<Callable<Result>> wrapped = new ArrayList<Callable<Result>>(pipes);
                 List<Future<Result>> results = executor.invokeAll(wrapped);
 
                 // Get pipe exceptions

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java Mon
Oct  3 08:23:18 2016
@@ -35,18 +35,22 @@ import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.function.BiFunction;
-import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 @SuppressWarnings("fallthrough")
 public class Expander extends BaseTokenizer
 {
 
+    private interface Function<T, R> {
+        R apply(T t);
+    }
+    private interface BiFunction<T, U, R> {
+        R apply(T t, U u);
+    }
+
+
     /**
      * expand variables, quotes and escapes in word.
      */
@@ -119,14 +123,21 @@ public class Expander extends BaseTokeni
         {
             return expanded;
         }
-        Stream<Object> stream = expanded instanceof Collection
-                ? asCollection(expanded).stream()
-                : Stream.of(expanded);
-        List<Object> args = stream
-                .flatMap(uncheck(o -> o instanceof CharSequence ? expandBraces((CharSequence)
o).stream() : Stream.of(o)))
-                .flatMap(uncheck(o -> generateFileNames && o instanceof CharSequence
? generateFileNames((CharSequence) o).stream() : Stream.of(o)))
-                .map(o -> unquote && o instanceof CharSequence ? unquote((CharSequence)
o) : o)
-                .collect(Collectors.toList());
+        List<Object> args = new ArrayList<>();
+        for (Object o1 : toCollection(expanded)) {
+            for (Object o2 : o1 instanceof CharSequence
+                                ? expandBraces((CharSequence) o1)
+                                : Collections.singleton(o1)) {
+                for (Object o3 : generateFileNames && o2 instanceof CharSequence
+                                    ? generateFileNames(((CharSequence) o2))
+                                    : Collections.singleton(o2)) {
+                    if (unquote && o3 instanceof CharSequence) {
+                        o3 = unquote((CharSequence) o3);
+                    }
+                    args.add(o3);
+                }
+            }
+        }
         if (args.size() == 1)
         {
             return args.get(0);
@@ -444,16 +455,19 @@ public class Expander extends BaseTokeni
                 {
                     generators.add(part.subSequence(start, part.length() - 1));
                 }
-                generators = generators.stream()
-                        .map(uncheck(cs -> expand(cs, false, false, false)))
-                        .flatMap(o -> o instanceof Collection ? asCollection(o).stream()
: Stream.of(o))
-                        .map(String::valueOf)
-                        .collect(Collectors.toList());
+                List<CharSequence> l = new ArrayList<>();
+                for (CharSequence cs : generators) {
+                    Object o1 = expand(cs, false, false, false);
+                    for (Object o2 : toCollection(o1)) {
+                        l.add(String.valueOf(o2));
+                    }
+                }
+                generators = l;
 
                 // If there's no splitting comma, expand with the braces
                 if (generators.size() < 2)
                 {
-                    generators = Collections.singletonList(part.toString());
+                    generators = Collections.<CharSequence>singletonList(part.toString());
                 }
             }
             else
@@ -467,39 +481,17 @@ public class Expander extends BaseTokeni
             else
             {
                 List<CharSequence> prevGenerated = generated;
-                generated = generators.stream()
-                        .flatMap(s -> prevGenerated.stream().map(cs -> String.valueOf(cs)
+ s))
-                        .collect(Collectors.toList());
+                generated = new ArrayList<>();
+                for (CharSequence s : generators) {
+                    for (Object cs : prevGenerated) {
+                        generated.add(String.valueOf(cs) + s);
+                    }
+                }
             }
         }
         return generated;
     }
 
-    public interface FunctionExc<T, R>
-    {
-        R apply(T t) throws Exception;
-    }
-
-    public static <T, R> Function<T, R> uncheck(FunctionExc<T, R> func)
-    {
-        return t -> {
-            try
-            {
-                return func.apply(t);
-            }
-            catch (Exception e)
-            {
-                return sneakyThrow(e);
-            }
-        };
-    }
-
-    @SuppressWarnings("unchecked")
-    private static <E extends Throwable, T> T sneakyThrow(Throwable t) throws E
-    {
-        throw (E) t;
-    }
-
     protected List<? extends CharSequence> generateFileNames(CharSequence arg) throws
IOException
     {
         // Disable if currentDir is not set
@@ -586,9 +578,9 @@ public class Expander extends BaseTokeni
         }
 
         String org = buf.toString();
-        List<String> expanded = new ArrayList<>();
-        Path dir;
-        String prefix;
+        final List<String> expanded = new ArrayList<>();
+        final Path dir;
+        final String prefix;
         if (pfx.indexOf('/') >= 0)
         {
             pfx = pfx.substring(0, pfx.lastIndexOf('/'));
@@ -601,7 +593,7 @@ public class Expander extends BaseTokeni
             dir = currentDir;
             prefix = "";
         }
-        PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:" + arg);
+        final PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:" + arg);
         Files.walkFileTree(dir,
                 EnumSet.of(FileVisitOption.FOLLOW_LINKS),
                 Integer.MAX_VALUE,
@@ -738,13 +730,26 @@ public class Expander extends BaseTokeni
                     {
                         if (expand instanceof ArgList)
                         {
-                            return new ArgList((ArgList) expand).stream()
-                                    .map(String::valueOf)
-                                    .map(s -> "\"" + s + "\"").collect(Collectors.toList());
+                            List<String> l = new ArrayList<>();
+                            for (Object o : (ArgList) expand) {
+                                l.add("\"" + String.valueOf(o) + "\"");
+                            }
+                            return l;
                         }
                         else if (expand instanceof Collection)
                         {
-                            return asCollection(expand).stream().map(String::valueOf).collect(Collectors.joining("
", "\"", "\""));
+                            StringBuilder sb = new StringBuilder();
+                            sb.append("\"");
+                            boolean first = true;
+                            for (Object o : asCollection(expand)) {
+                                if (first) {
+                                    first = false;
+                                } else {
+                                    sb.append(" ");
+                                }
+                                sb.append(String.valueOf(o));
+                            }
+                            return sb.append("\"").toString();
                         }
                         else if (expand != null)
                         {
@@ -1207,32 +1212,42 @@ public class Expander extends BaseTokeni
             }
 
             // Map to List conversion
-            boolean _flagk = flagk;
-            boolean _flagv = flagv;
-            Function<Object, Object> toCollection = v -> v instanceof Map
-                    ? toList(asMap(v), _flagk, _flagv)
-                    : v != null && v.getClass().isArray()
-                        ? Arrays.asList((Object[]) v)
-                        : v;
+            final boolean _flagk = flagk;
+            final boolean _flagv = flagv;
+            final Function<Object, Object> toCollection = new Function<Object, Object>()
{
+                @Override
+                public Object apply(Object v) {
+                    return v instanceof Map
+                            ? toList(asMap(v), _flagk, _flagv)
+                            : v != null && v.getClass().isArray()
+                            ? Arrays.asList((Object[]) v)
+                            : v;
+                }
+            };
 
             //
             // String transformations
             //
-            BiFunction<Function<String, String>, Object, Object> stringApplyer
= (func, v) -> {
-                v = toCollection.apply(v);
-                if (v instanceof Collection)
-                {
-                    return asCollection(v).stream()
-                            .map(String::valueOf)
-                            .map(func)
-                            .collect(Collectors.toList());
-                }
-                else if (v != null)
-                {
-                    return func.apply(v.toString());
+            final BiFunction<Function<String, String>, Object, Object> stringApplyer
= new BiFunction<Function<String,String>, Object, Object>() {
+                @Override
+                public Object apply(Function<String, String> func, Object v) {
+                    v = toCollection.apply(v);
+                    if (v instanceof Collection)
+                    {
+                        List<String> l = new ArrayList<String>();
+                        for (Object i : asCollection(v)) {
+                            l.add(func.apply(String.valueOf(i)));
+                        }
+                        return l;
+                    }
+                    else if (v != null)
+                    {
+                        return func.apply(v.toString());
+                    }
+                    else {
+                        return null;
+                    }
                 }
-                else
-                    return null;
             };
 
             if (ch == '+')
@@ -1527,9 +1542,14 @@ public class Expander extends BaseTokeni
                 if (val instanceof Collection)
                 {
                     String j = flagj != null ? flagj : " ";
-                    val = asCollection(val).stream()
-                            .map(String::valueOf)
-                            .collect(Collectors.joining(j));
+                    StringBuilder sb = new StringBuilder();
+                    for (Object i : asCollection(val)) {
+                        if (sb.length() > 0) {
+                            sb.append(j);
+                        }
+                        sb.append(String.valueOf(i));
+                    }
+                    val = sb.toString();
                     joined = true;
                 }
             }
@@ -1537,7 +1557,12 @@ public class Expander extends BaseTokeni
             // Character evaluation
             if (flagSharp)
             {
-                val = stringApplyer.apply(this::sharp, val);
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return sharp(s);
+                    }
+                }, val);
             }
 
             // Length
@@ -1568,9 +1593,14 @@ public class Expander extends BaseTokeni
                 if (val instanceof Collection)
                 {
                     String j = flagj != null ? flagj : " ";
-                    val = asCollection(val).stream()
-                            .map(String::valueOf)
-                            .collect(Collectors.joining(j));
+                    StringBuilder sb = new StringBuilder();
+                    for (Object i : asCollection(val)) {
+                        if (sb.length() > 0) {
+                            sb.append(j);
+                        }
+                        sb.append(String.valueOf(i));
+                    }
+                    val = sb.toString();
                 }
             }
 
@@ -1583,41 +1613,72 @@ public class Expander extends BaseTokeni
                 {
                     val = Collections.singletonList(val);
                 }
-                val = asCollection(val).stream()
-                        .map(String::valueOf)
-                        .flatMap(s -> Arrays.stream(s.split(_flags)))
-                        .collect(Collectors.toList());
+                List<String> l = new ArrayList<>();
+                for (Object i : asCollection(val)) {
+                    Collections.addAll(l, String.valueOf(i).split(_flags));
+                }
+                val = l;
             }
 
             // Case modification
             if (flagC)
             {
-                val = stringApplyer.apply(this::toCamelCase, val);
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return toCamelCase(s);
+                    }
+                }, val);
             }
             else if (flagL)
             {
-                val = stringApplyer.apply(String::toLowerCase, val);
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return s.toLowerCase();
+                    }
+                }, val);
             }
             else if (flagU)
             {
-                val = stringApplyer.apply(String::toUpperCase, val);
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return s.toUpperCase();
+                    }
+                }, val);
             }
 
             // Visibility enhancement
             if (flagV)
             {
-                val = stringApplyer.apply(this::visible, val);
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return visible(s);
+                    }
+                }, val);
             }
 
             // Quote
             if (flagq != 0)
             {
-                int _flagq = flagq;
-                val = stringApplyer.apply(s -> quote(s, _flagq), val);
+                final int _flagq = flagq;
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return quote(s, _flagq);
+                    }
+                }, val);
                 inQuote = true;
             }
             else if (flagQ) {
-                val = stringApplyer.apply(this::unquote, val);
+                val = stringApplyer.apply(new Function<String, String>() {
+                    @Override
+                    public String apply(String s) {
+                        return unquote(s);
+                    }
+                }, val);
             }
 
             // Uniqueness
@@ -1639,11 +1700,18 @@ public class Expander extends BaseTokeni
                     List<Object> list;
                     if (flagn)
                     {
-                        boolean _flagi = flagi;
-                        list = asCollection(val).stream()
-                                .map(String::valueOf)
-                                .sorted((s1, s2) -> numericCompare(s1, s2, _flagi))
-                                .collect(Collectors.toList());
+                        final boolean _flagi = flagi;
+                        List<String> l = new ArrayList<>();
+                        for (Object i : asCollection(val)) {
+                            l.add(String.valueOf(i));
+                        }
+                        Collections.sort(l, new Comparator<String>() {
+                            @Override
+                            public int compare(String s1, String s2) {
+                                return numericCompare(s1, s2, _flagi);
+                            }
+                        });
+                        list = (List) l;
                     }
                     else if (flaga)
                     {
@@ -1651,11 +1719,18 @@ public class Expander extends BaseTokeni
                     }
                     else
                     {
-                        Comparator<String> comparator = flagi ? String.CASE_INSENSITIVE_ORDER
: Comparator.naturalOrder();
-                        list = asCollection(val).stream()
-                                .map(String::valueOf)
-                                .sorted(comparator)
-                                .collect(Collectors.toList());
+                        Comparator<String> comparator = flagi ? String.CASE_INSENSITIVE_ORDER
: new Comparator<String>() {
+                            @Override
+                            public int compare(String o1, String o2) {
+                                return o1.compareTo(o2);
+                            }
+                        };
+                        List<String> l = new ArrayList<>();
+                        for (Object i : asCollection(val)) {
+                            l.add(String.valueOf(i));
+                        }
+                        Collections.sort(l, comparator);
+                        list = (List) l;
                     }
                     if (flagO)
                     {
@@ -1671,27 +1746,36 @@ public class Expander extends BaseTokeni
                 val = toCollection.apply(val);
                 if (val instanceof Collection)
                 {
-                    val = asCollection(val).stream()
-                            .map(String::valueOf)
-                            .collect(Collectors.joining(" "));
+                    StringBuilder sb = new StringBuilder();
+                    for (Object i : asCollection(val)) {
+                        if (sb.length() > 0) {
+                            sb.append(" ");
+                        }
+                        sb.append(String.valueOf(i));
+                    }
+                    val = sb.toString();
                 }
             }
 
             // Empty argument removal
             if (val instanceof Collection)
             {
-                val = asCollection(val).stream()
-                        .filter(o -> !(o instanceof CharSequence) || ((CharSequence) o).length()
> 0)
-                        .collect(Collectors.toList());
+                List<Object> l = new ArrayList<>();
+                for (Object o : asCollection(val)) {
+                    if (!(o instanceof CharSequence) || ((CharSequence) o).length() >
0) {
+                        l.add(o);
+                    }
+                }
+                val = l;
             }
 
             if (asPattern && !inQuote && !flagPattern)
             {
                 val = toCollection.apply(val);
-                Stream<Object> stream = val instanceof Collection ? asCollection(val).stream()
: Stream.of(val);
-                List<String> patterns = stream.map(String::valueOf)
-                        .map(s -> quote(s, 2))
-                        .collect(Collectors.toList());
+                List<String> patterns = new ArrayList<>();
+                for (Object o : toCollection(val)) {
+                    patterns.add(quote(String.valueOf(o), 2));
+                }
                 val = patterns.size() == 1 ? patterns.get(0) : patterns;
             }
 
@@ -2042,6 +2126,12 @@ public class Expander extends BaseTokeni
         return (Collection) val;
     }
 
+    private Collection<Object> toCollection(Object val) {
+        return val instanceof Collection
+                ? asCollection(val)
+                : Collections.singleton(val);
+    }
+
     @SuppressWarnings("unchecked")
     private Map<Object, Object> asMap(Object val)
     {

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java Mon
Oct  3 08:23:18 2016
@@ -36,7 +36,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Stack;
-import java.util.stream.Collectors;
 
 /**
  * Enhanced to provide assignment operators and variables from a map, comparison operators,
string operations and more.
@@ -336,9 +335,10 @@ public class Expression {
         }
 
         public BigDecimal eval(Map<String, Object> variables, List<Object> parameters)
{
-            List<BigDecimal> numericParameters = parameters.stream()
-                    .map(o -> toBigDecimal(variables, o))
-                    .collect(Collectors.toList());
+            List<BigDecimal> numericParameters = new ArrayList<>();
+            for (Object o : parameters) {
+                numericParameters.add(toBigDecimal(variables, o));
+            }
             return eval(numericParameters);
         }
 
@@ -1145,7 +1145,7 @@ public class Expression {
      * @return The result of the expression.
      */
     public Object eval() {
-        return eval(new HashMap<>());
+        return eval(new HashMap<String, Object>());
     }
 
     /**

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java Mon Oct
 3 08:23:18 2016
@@ -18,12 +18,7 @@
  */
 package org.apache.felix.gogo.runtime;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Pattern;
 
 
@@ -187,7 +182,12 @@ public class Parser
     }
 
     public List<Statement> statements() {
-        Collections.sort(statements, (o1, o2) -> Integer.compare(o1.start, o2.start));
+        Collections.sort(statements, new Comparator<Statement>() {
+                    @Override
+                    public int compare(Statement o1, Statement o2) {
+                        return Integer.compare(o1.start, o2.start);
+                    }
+                });
         return Collections.unmodifiableList(statements);
     }
 

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java Mon Oct
 3 08:23:18 2016
@@ -340,8 +340,8 @@ public class Pipe implements Callable<Re
                 }
                 else if ((m = Pattern.compile("<<-?").matcher(t)).matches())
                 {
-                    Token hereDoc = tokens.get(++i);
-                    boolean stripLeadingTabs = t.charAt(t.length() - 1) == '-';
+                    final Token hereDoc = tokens.get(++i);
+                    final boolean stripLeadingTabs = t.charAt(t.length() - 1) == '-';
                     InputStream doc = new InputStream()
                     {
                         final byte[] bytes = hereDoc.toString().getBytes();

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/service/command/CommandSession.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/service/command/CommandSession.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/service/command/CommandSession.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/service/command/CommandSession.java
Mon Oct  3 08:23:18 2016
@@ -126,9 +126,11 @@ public interface CommandSession extends
      * Return the current session.
      * Available inside from a command call.
      */
-    static CommandSession current() {
-        Job j = Job.current();
-        return j != null ? j.session() : null;
+    class Utils {
+        public static CommandSession current() {
+            Job j = Job.Utils.current();
+            return j != null ? j.session() : null;
+        }
     }
 
 }

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java
(original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java
Mon Oct  3 08:23:18 2016
@@ -36,11 +36,11 @@ public class ReflectiveTest {
 
     @Test
     public void testArrayInvocation() throws Exception {
-        assertEquals(new Object[] { 1, "ab" }, invoke("test1", Arrays.asList(1, "ab")));
-        assertEquals(new String[] { "1", "ab" }, invoke("test2", Arrays.asList(1, "ab")));
+        assertEquals(new Object[] { 1, "ab" }, invoke("test1", Arrays.<Object>asList(1,
"ab")));
+        assertEquals(new String[] { "1", "ab" }, invoke("test2", Arrays.<Object>asList(1,
"ab")));
 
         assertEquals(new Object[] { Arrays.asList(1, 2), "ab" }, invoke("test1", Arrays.asList(Arrays.asList(1,
2), "ab")));
-        assertEquals(new Object[] { new Object[] { 1, 2 }, "ab" }, invoke("test1", Arrays.asList(new
Object[] { 1, 2 }, "ab")));
+        assertEquals(new Object[] { new Object[] { 1, 2 }, "ab" }, invoke("test1", Arrays.<Object>asList(new
Object[] { 1, 2 }, "ab")));
     }
 
     static class Target {

Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java?rev=1763127&r1=1763126&r2=1763127&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java Mon
Oct  3 08:23:18 2016
@@ -468,7 +468,7 @@ public class TestParser extends Abstract
 
     public boolean istty(CommandSession session, int fd)
     {
-        return Process.current().isTty(fd);
+        return Process.Utils.current().isTty(fd);
     }
 
     void each(CommandSession session, Collection<Object> list, Function closure)



Mime
View raw message