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 09:48:28 UTC

[groovy] branch GROOVY-9526 updated (ab4147a -> 23db412)

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.


 discard ab4147a  GROOVY-9526: Failed to reload classes with generic parameters
     new 23db412  GROOVY-9526: Failed to reload classes with generic parameters

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (ab4147a)
            \
             N -- N -- N   refs/heads/GROOVY-9526 (23db412)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 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    | 17 +----------------
 src/main/java/org/codehaus/groovy/ast/ClassNode.java | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 16 deletions(-)


[groovy] 01/01: GROOVY-9526: Failed to reload classes with generic parameters

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 23db4129efa971eca67d02b63189a8506092fc33
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Apr 25 17:48:10 2020 +0800

    GROOVY-9526: Failed to reload classes with generic parameters
---
 src/main/java/groovy/util/GroovyScriptEngine.java    |  2 +-
 src/main/java/org/codehaus/groovy/ast/ClassNode.java | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/main/java/groovy/util/GroovyScriptEngine.java b/src/main/java/groovy/util/GroovyScriptEngine.java
index 7afd183..80477fb 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);
+                                ClassNode cn = new ClassNode(clazz, true);
                                 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 15f6eb0..106a0d7 100644
--- a/src/main/java/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ClassNode.java
@@ -31,6 +31,7 @@ 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;
 
@@ -109,6 +110,7 @@ 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;
@@ -259,6 +261,21 @@ 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.
      */