groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring
Date Fri, 18 Aug 2017 03:32:40 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 30b94cd42 -> f26ad84bb


Minor refactoring

(cherry picked from commit 4869ffa)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: f26ad84bbb0e4a70d4e124fc9c6c551e6577dc30
Parents: 30b94cd
Author: sunlan <sunlan@apache.org>
Authored: Fri Aug 18 11:31:18 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Fri Aug 18 11:32:35 2017 +0800

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/ast/ClassNode.java           | 10 +++++++++-
 .../java/org/apache/groovy/parser/antlr4/AstBuilder.java  | 10 +---------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/f26ad84b/src/main/org/codehaus/groovy/ast/ClassNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java
index 702a0a8..283e86f 100644
--- a/src/main/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/org/codehaus/groovy/ast/ClassNode.java
@@ -19,7 +19,10 @@
 package org.codehaus.groovy.ast;
 
 import org.codehaus.groovy.GroovyBugError;
-import org.codehaus.groovy.ast.expr.*;
+import org.codehaus.groovy.ast.expr.BinaryExpression;
+import org.codehaus.groovy.ast.expr.Expression;
+import org.codehaus.groovy.ast.expr.FieldExpression;
+import org.codehaus.groovy.ast.expr.TupleExpression;
 import org.codehaus.groovy.ast.stmt.BlockStatement;
 import org.codehaus.groovy.ast.stmt.ExpressionStatement;
 import org.codehaus.groovy.ast.stmt.Statement;
@@ -389,6 +392,11 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         return redirect().mixins;
     }
 
+
+    public void setMixins(MixinNode[] mixins) {
+        redirect().mixins = mixins;
+    }
+
     /**
      * @return the list of methods associated with this ClassNode
      */

http://git-wip-us.apache.org/repos/asf/groovy/blob/f26ad84b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 766e998..70de057 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -122,7 +122,6 @@ import org.objectweb.asm.Opcodes;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.lang.reflect.Field;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -4202,14 +4201,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 
     // the mixins of interface and annotation should be null
     private void hackMixins(ClassNode classNode) {
-        try {
-            // FIXME Hack with visibility.
-            Field field = ClassNode.class.getDeclaredField("mixins");
-            field.setAccessible(true);
-            field.set(classNode, null);
-        } catch (IllegalAccessException | NoSuchFieldException e) {
-            throw new GroovyBugError("Failed to access mixins field", e);
-        }
+        classNode.setMixins(null);
     }
 
     private static final Map<ClassNode, Object> TYPE_DEFAULT_VALUE_MAP = Maps.<ClassNode,
Object>of(


Mime
View raw message