You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/04/25 12:53:34 UTC

[groovy] branch GROOVY-9526 updated (a9e4a2c -> a775ac1)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY-9526
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from a9e4a2c  Trivial refactoring
     new 7619f43  Revert changes to tweak the PR
     new a775ac1  Tweak GROOVY-9526 to handle more potential cases

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/groovy/util/GroovyScriptEngine.java     |  2 +-
 src/main/java/org/codehaus/groovy/ast/ClassNode.java  | 19 +------------------
 .../codehaus/groovy/control/ClassNodeResolver.java    |  9 ++++++++-
 3 files changed, 10 insertions(+), 20 deletions(-)


[groovy] 02/02: Tweak GROOVY-9526 to handle more potential cases

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-9526
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit a775ac1b8ccbab6087edd1831150cc4c4c9348db
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Apr 25 20:48:44 2020 +0800

    Tweak GROOVY-9526 to handle more potential cases
---
 src/main/java/org/codehaus/groovy/control/ClassNodeResolver.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ClassNodeResolver.java b/src/main/java/org/codehaus/groovy/control/ClassNodeResolver.java
index e5842a8..3f85533 100644
--- a/src/main/java/org/codehaus/groovy/control/ClassNodeResolver.java
+++ b/src/main/java/org/codehaus/groovy/control/ClassNodeResolver.java
@@ -26,6 +26,8 @@ import org.codehaus.groovy.ast.decompiled.AsmDecompiler;
 import org.codehaus.groovy.ast.decompiled.AsmReferenceResolver;
 import org.codehaus.groovy.ast.decompiled.DecompiledClassNode;
 import org.codehaus.groovy.classgen.Verifier;
+import org.codehaus.groovy.vmplugin.VMPlugin;
+import org.codehaus.groovy.vmplugin.VMPluginFactory;
 import org.objectweb.asm.Opcodes;
 
 import java.io.File;
@@ -55,6 +57,7 @@ import java.util.Map;
  * entry method is {@link ClassNodeResolver#resolveName(String, CompilationUnit)}
  */
 public class ClassNodeResolver {
+    private static final VMPlugin VM_PLUGIN = VMPluginFactory.getPlugin();
 
     /**
      * Helper class to return either a SourceUnit or ClassNode.
@@ -124,7 +127,11 @@ public class ClassNodeResolver {
         if (res!=null) return new LookupResult(null,res);
         LookupResult lr = findClassNode(name, compilationUnit);
         if (lr != null) {
-            if (lr.isClassNode()) cacheClass(name, lr.getClassNode());
+            if (lr.isClassNode()) {
+                ClassNode classNode = lr.getClassNode();
+                VM_PLUGIN.setAdditionalClassInformation(classNode);
+                cacheClass(name, classNode);
+            }
             return lr;
         } else {
             cacheClass(name, NO_CLASS);


[groovy] 01/02: Revert changes to tweak the PR

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-9526
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 7619f43d36bccf4fb6fe1cd0cf1e8f7e1383cc68
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Apr 25 20:37:46 2020 +0800

    Revert changes to tweak the PR
---
 src/main/java/groovy/util/GroovyScriptEngine.java    |  2 +-
 src/main/java/org/codehaus/groovy/ast/ClassNode.java | 19 +------------------
 2 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/src/main/java/groovy/util/GroovyScriptEngine.java b/src/main/java/groovy/util/GroovyScriptEngine.java
index 80477fb..7afd183 100644
--- a/src/main/java/groovy/util/GroovyScriptEngine.java
+++ b/src/main/java/groovy/util/GroovyScriptEngine.java
@@ -198,7 +198,7 @@ public class GroovyScriptEngine implements ResourceConnector {
                                 precompiledEntries.put(origName, path);
                             }
                             if (clazz != null) {
-                                ClassNode cn = new ClassNode(clazz, true);
+                                ClassNode cn = new ClassNode(clazz);
                                 return new LookupResult(null, cn);
                             }
                         } catch (ResourceException re) {
diff --git a/src/main/java/org/codehaus/groovy/ast/ClassNode.java b/src/main/java/org/codehaus/groovy/ast/ClassNode.java
index 87b0a48..15f6eb0 100644
--- a/src/main/java/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ClassNode.java
@@ -31,7 +31,6 @@ import org.codehaus.groovy.ast.tools.ParameterUtils;
 import org.codehaus.groovy.control.CompilePhase;
 import org.codehaus.groovy.transform.ASTTransformation;
 import org.codehaus.groovy.transform.GroovyASTTransformation;
-import org.codehaus.groovy.vmplugin.VMPlugin;
 import org.codehaus.groovy.vmplugin.VMPluginFactory;
 import org.objectweb.asm.Opcodes;
 
@@ -110,7 +109,6 @@ import static java.util.stream.Collectors.joining;
  * @see org.codehaus.groovy.ast.ClassHelper
  */
 public class ClassNode extends AnnotatedNode implements Opcodes {
-    private static final VMPlugin VM_PLUGIN = VMPluginFactory.getPlugin();
 
     private static class MapOfLists {
         Map<Object, List<MethodNode>> map;
@@ -261,21 +259,6 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
     }
 
     /**
-     * Creates a non-primary {@code ClassNode} from a real class and can include the additional class information, e.g. generics types
-     *
-     * @param c the real class
-     * @param includeAdditionalClassInformation whether to include the additional class information
-     * @since 3.0.4
-     */
-    public ClassNode(Class<?> c, boolean includeAdditionalClassInformation) {
-        this(c);
-
-        if (includeAdditionalClassInformation) {
-            VM_PLUGIN.setAdditionalClassInformation(this);
-        }
-    }
-
-    /**
      * The complete class structure will be initialized only when really needed
      * to avoid having too many objects during compilation.
      */
@@ -287,7 +270,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
                                          "A redirect() call is missing somewhere!");
             }
             if (lazyInitDone) return;
-            VM_PLUGIN.configureClassNode(compileUnit, this);
+            VMPluginFactory.getPlugin().configureClassNode(compileUnit, this);
             lazyInitDone = true;
         }
     }