Quantcast

groovy git commit: Minor refactoring

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

groovy git commit: Minor refactoring

sunlan
Repository: groovy
Updated Branches:
  refs/heads/master 285cb1fd1 -> 868045794


Minor refactoring


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

Branch: refs/heads/master
Commit: 86804579453cd7fce564056af605205b58cb4d13
Parents: 285cb1f
Author: sunlan <[hidden email]>
Authored: Mon May 8 00:34:08 2017 +0800
Committer: sunlan <[hidden email]>
Committed: Mon May 8 00:34:08 2017 +0800

----------------------------------------------------------------------
 .../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/86804579/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/86804579/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 4bf8ce9..763d4e5 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();
 

Loading...