groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [2/2] groovy git commit: Minor refactoring: extract constant `ASM_API_VERSION`
Date Sat, 17 Feb 2018 20:52:36 GMT
Minor refactoring: extract constant `ASM_API_VERSION`

(cherry picked from commit 6ab6759)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: bb9809d74a1d815de456b1324634e4821177ccb2
Parents: 70f825c
Author: danielsun1106 <realbluesun@hotmail.com>
Authored: Sun Feb 18 04:47:34 2018 +0800
Committer: danielsun1106 <realbluesun@hotmail.com>
Committed: Sun Feb 18 04:50:18 2018 +0800

----------------------------------------------------------------------
 .../java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java  | 5 +++--
 .../codehaus/groovy/ast/decompiled/FormalParameterParser.java   | 3 ++-
 .../org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java | 3 ++-
 .../codehaus/groovy/classgen/asm/util/LoggableClassVisitor.java | 3 ++-
 .../codehaus/groovy/classgen/asm/util/LoggableTextifier.java    | 3 ++-
 .../java/org/codehaus/groovy/control/CompilerConfiguration.java | 2 ++
 .../java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java | 2 +-
 src/test/gls/generics/GenericsTestBase.java                     | 3 ++-
 .../groovy/classgen/asm/AbstractBytecodeTestCase.groovy         | 2 +-
 9 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java b/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
index cc9c2f0..8a789fe 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
@@ -19,6 +19,7 @@
 package org.codehaus.groovy.ast.decompiled;
 
 import groovy.lang.GroovyRuntimeException;
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassVisitor;
@@ -94,7 +95,7 @@ public abstract class AsmDecompiler {
         private ClassStub result;
 
         public DecompilingVisitor() {
-            super(Opcodes.ASM6);
+            super(CompilerConfiguration.ASM_API_VERSION);
         }
 
         @Override
@@ -179,7 +180,7 @@ public abstract class AsmDecompiler {
 
     private abstract static class AnnotationReader extends AnnotationVisitor {
         public AnnotationReader() {
-            super(Opcodes.ASM6);
+            super(CompilerConfiguration.ASM_API_VERSION);
         }
 
         abstract void visitAttribute(String name, Object value);

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java b/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
index a5fc1b5..3ed8c3f 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
@@ -20,6 +20,7 @@ package org.codehaus.groovy.ast.decompiled;
 
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.GenericsType;
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.vmplugin.v5.Java5;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.signature.SignatureVisitor;
@@ -37,7 +38,7 @@ abstract class FormalParameterParser extends SignatureVisitor {
     private final List<GenericsType> typeParameters = new ArrayList<GenericsType>();
 
     public FormalParameterParser(AsmReferenceResolver resolver) {
-        super(Opcodes.ASM6);
+        super(CompilerConfiguration.ASM_API_VERSION);
         this.resolver = resolver;
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java b/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
index 718429e..ae5efb1 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
@@ -21,6 +21,7 @@ package org.codehaus.groovy.ast.decompiled;
 import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.GenericsType;
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.vmplugin.v5.Java5;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
@@ -36,7 +37,7 @@ abstract class TypeSignatureParser extends SignatureVisitor {
     private final AsmReferenceResolver resolver;
 
     public TypeSignatureParser(AsmReferenceResolver resolver) {
-        super(Opcodes.ASM6);
+        super(CompilerConfiguration.ASM_API_VERSION);
         this.resolver = resolver;
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableClassVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableClassVisitor.java
b/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableClassVisitor.java
index b794235..c102f69 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableClassVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableClassVisitor.java
@@ -18,6 +18,7 @@
  */
 package org.codehaus.groovy.classgen.asm.util;
 
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.util.TraceClassVisitor;
@@ -29,6 +30,6 @@ import org.objectweb.asm.util.TraceClassVisitor;
  */
 public class LoggableClassVisitor extends ClassVisitor {
     public LoggableClassVisitor(final ClassVisitor cv) {
-        super(Opcodes.ASM6, new TraceClassVisitor(cv, new LoggableTextifier(), null));
+        super(CompilerConfiguration.ASM_API_VERSION, new TraceClassVisitor(cv, new LoggableTextifier(),
null));
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableTextifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableTextifier.java b/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableTextifier.java
index e5b0dea..dce4417 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableTextifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/util/LoggableTextifier.java
@@ -18,6 +18,7 @@
  */
 package org.codehaus.groovy.classgen.asm.util;
 
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.objectweb.asm.Attribute;
 import org.objectweb.asm.Handle;
 import org.objectweb.asm.Label;
@@ -38,7 +39,7 @@ public class LoggableTextifier extends Textifier {
     private int loggedLineCnt = 0;
 
     public LoggableTextifier() {
-        super(Opcodes.ASM6);
+        super(CompilerConfiguration.ASM_API_VERSION);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
index 54c53c6..9a4dabc 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -207,6 +207,8 @@ public class CompilerConfiguration {
      */
     private ParserVersion parserVersion = ParserVersion.V_2;
 
+    public static final int ASM_API_VERSION = Opcodes.ASM6;
+
     /**
      * Sets the Flags to defaults.
      */

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
index dfec531..2d3ca8a 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
@@ -142,7 +142,7 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes
{
             final ClassLoader proxyLoader,
             final boolean emptyBody,
             final Class delegateClass) {
-        super(Opcodes.ASM6, new ClassWriter(0));
+        super(CompilerConfiguration.ASM_API_VERSION, new ClassWriter(0));
         this.loader = proxyLoader != null ? createInnerLoader(proxyLoader, interfaces) :
findClassLoader(superClass, interfaces);
         this.visitedMethods = new LinkedHashSet<Object>();
         this.delegatedClosures = closureMap.isEmpty() ? EMPTY_DELEGATECLOSURE_MAP : new HashMap<String,
Boolean>();

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/test/gls/generics/GenericsTestBase.java
----------------------------------------------------------------------
diff --git a/src/test/gls/generics/GenericsTestBase.java b/src/test/gls/generics/GenericsTestBase.java
index 9b0f220..f3f8fc6 100644
--- a/src/test/gls/generics/GenericsTestBase.java
+++ b/src/test/gls/generics/GenericsTestBase.java
@@ -24,6 +24,7 @@ import groovy.util.GroovyTestCase;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.control.CompilationFailedException;
 import org.codehaus.groovy.control.CompilationUnit;
+import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.control.SourceUnit;
 import org.objectweb.asm.*;
 
@@ -57,7 +58,7 @@ public abstract class GenericsTestBase extends GroovyTestCase {
     }
     private class GenericsTester extends ClassVisitor {
         public GenericsTester(ClassVisitor cv) {
-            super(Opcodes.ASM6,cv);
+            super(CompilerConfiguration.ASM_API_VERSION, cv);
         }
         public void visit(int version, int access, String name,
                 String signature, String superName, String[] interfaces) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/bb9809d7/src/test/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy b/src/test/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
index ca88074..39c0cc1 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/AbstractBytecodeTestCase.groovy
@@ -118,7 +118,7 @@ abstract class AbstractBytecodeTestCase extends GroovyTestCase {
         InstructionSequence sequence
         def output = new StringBuilderWriter()
         def tcf;
-        tcf = new TraceClassVisitor(new ClassVisitor(Opcodes.ASM6) {
+        tcf = new TraceClassVisitor(new ClassVisitor(CompilerConfiguration.ASM_API_VERSION)
{
             MethodVisitor visitMethod(int access, String name, String desc, String signature,
String... exceptions) {
                 if (options.method == name) {
                     tcf.p.text << '--BEGIN--'


Mime
View raw message