groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [24/50] [abbrv] groovy git commit: Minor refactoring
Date Wed, 10 May 2017 22:26:52 GMT
Minor refactoring


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

Branch: refs/heads/parrot
Commit: c26bf4666e30631dd118dbd145deda0f591274fd
Parents: bce50a3
Author: sunlan <sunlan@apache.org>
Authored: Mon May 8 00:34:08 2017 +0800
Committer: paulk <paulk@asert.com.au>
Committed: Thu May 11 08:11:03 2017 +1000

----------------------------------------------------------------------
 .../groovy/classgen/asm/WriterController.java   | 11 ++++------
 .../groovy/control/CompilerConfiguration.java   | 21 +++++++++++++++-----
 2 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c26bf466/src/main/org/codehaus/groovy/classgen/asm/WriterController.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/WriterController.java b/src/main/org/codehaus/groovy/classgen/asm/WriterController.java
index 4eec57e..a7fdc2a 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/WriterController.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/WriterController.java
@@ -18,11 +18,6 @@
  */
 package org.codehaus.groovy.classgen.asm;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import org.codehaus.groovy.GroovyBugError;
 import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
@@ -41,7 +36,9 @@ import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 
-import static org.codehaus.groovy.control.CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 public class WriterController {
 
@@ -140,7 +137,7 @@ public class WriterController {
 
             return Opcodes.V1_8;
         } else {
-            Integer bytecodeVersion = JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode);
+            Integer bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode);
 
             if (null != bytecodeVersion) {
                 return bytecodeVersion;

http://git-wip-us.apache.org/repos/asf/groovy/blob/c26bf466/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index 4278b55..a53f273 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -25,7 +25,18 @@ import org.objectweb.asm.Opcodes;
 
 import java.io.File;
 import java.io.PrintWriter;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
 
 /**
  * Compilation control flags and coordination stuff.
@@ -58,13 +69,10 @@ public class CompilerConfiguration {
     /** This (<code>"1.4"</code>) is the value for targetBytecode to compile
for a JDK 1.4 JVM. **/
     public static final String PRE_JDK5 = JDK4;
 
-    /** An array of the valid targetBytecode values **/
-    public static final String[] ALLOWED_JDKS = { JDK4, JDK5, JDK6, JDK7, JDK8 };
-
     /**
      * JDK version to bytecode version mapping
      */
-    public static final Map<String, Integer> JDK_TO_BYTECODE_VERSION_MAP = Collections.unmodifiableMap(new
HashMap<String, Integer>() {{
+    public static final Map<String, Integer> JDK_TO_BYTECODE_VERSION_MAP = Collections.unmodifiableMap(new
LinkedHashMap<String, Integer>() {{
         put(JDK4, Opcodes.V1_4);
         put(JDK5, Opcodes.V1_5);
         put(JDK6, Opcodes.V1_6);
@@ -72,6 +80,9 @@ public class CompilerConfiguration {
         put(JDK8, Opcodes.V1_8);
     }});
 
+    /** An array of the valid targetBytecode values **/
+    public static final String[] ALLOWED_JDKS = JDK_TO_BYTECODE_VERSION_MAP.keySet().toArray(new
String[0]);
+
     // Just call getVMVersion() once.
     public static final String currentJVMVersion = getVMVersion();
 


Mime
View raw message