You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/10/29 03:02:45 UTC

incubator-groovy git commit: GROOVY-7650: CLONE - collectEntries throws cryptic error when used with split(delimiter, limit) (closes #166)

Repository: incubator-groovy
Updated Branches:
  refs/heads/master 85958809f -> 7be5f9eb1


GROOVY-7650: CLONE - collectEntries throws cryptic error when used with split(delimiter, limit) (closes #166)


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

Branch: refs/heads/master
Commit: 7be5f9eb1b9cbe07188a96616bc5a3988765dab3
Parents: 8595880
Author: paulk <pa...@asert.com.au>
Authored: Thu Oct 29 10:47:11 2015 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Oct 29 10:47:11 2015 +1000

----------------------------------------------------------------------
 .../codehaus/groovy/runtime/ProxyGeneratorAdapter.java  | 12 ++++++------
 src/test/groovy/util/ProxyGeneratorAdapterTest.groovy   |  7 +++++--
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/7be5f9eb/src/main/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java b/src/main/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
index 864e7e2..dbbab01 100644
--- a/src/main/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
+++ b/src/main/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
@@ -74,7 +74,7 @@ import java.util.concurrent.atomic.AtomicLong;
  *
  * The generated proxy implements the {@link GroovyObject} interface.
  *
- * Additionaly, this proxy generator supports delegation to another object. In that case, if a method is defined
+ * Additionally, this proxy generator supports delegation to another object. In that case, if a method is defined
  * both in the closure map and the delegate, the version from the map is preferred. This allows overriding methods
  * from delegates with ease.
  *
@@ -525,7 +525,10 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes {
     }
 
     private String proxyName() {
-        String name = delegateClass!=null?delegateClass.getName():superClass.getName();
+        String name = delegateClass != null ? delegateClass.getName() : superClass.getName();
+        if (name.startsWith("[") && name.endsWith(";")) {
+            name = name.substring(1, name.length() - 1) + "_array";
+        }
         int index = name.lastIndexOf('.');
         if (index == -1) return name + pxyCounter.incrementAndGet() + "_groovyProxy";
         return name.substring(index + 1, name.length()) + pxyCounter.incrementAndGet() + "_groovyProxy";
@@ -541,10 +544,7 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes {
             }
         }
         Class parent = clazz.getSuperclass();
-        if (parent !=null) {
-            return isImplemented(parent, name, desc);
-        }
-        return false;
+        return parent != null && isImplemented(parent, name, desc);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/7be5f9eb/src/test/groovy/util/ProxyGeneratorAdapterTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/util/ProxyGeneratorAdapterTest.groovy b/src/test/groovy/util/ProxyGeneratorAdapterTest.groovy
index 7cd20b2..393dad4 100644
--- a/src/test/groovy/util/ProxyGeneratorAdapterTest.groovy
+++ b/src/test/groovy/util/ProxyGeneratorAdapterTest.groovy
@@ -29,6 +29,11 @@ class ProxyGeneratorAdapterTest extends GroovyTestCase {
         assert obj.toString() == 'HELLO'
     }
 
+    void testShouldCreateProxyWithArrayDelegate() {
+        def adapter = new ProxyGeneratorAdapter([:], Map$Entry, [Map$Entry] as Class[], null, false, String[])
+        assert adapter.proxyName() =~ /String_array\d+_groovyProxy/
+    }
+
     void testImplementSingleAbstractMethod() {
         def map = ['m': { 'HELLO' }]
         ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Foo, null, this.class.classLoader, false, null)
@@ -36,7 +41,6 @@ class ProxyGeneratorAdapterTest extends GroovyTestCase {
         assert obj instanceof GroovyObject
         assert obj instanceof Foo
         assert obj.m() == 'HELLO'
-
     }
     
     void testImplementSingleAbstractMethodReturningVoid() {
@@ -46,7 +50,6 @@ class ProxyGeneratorAdapterTest extends GroovyTestCase {
         assert obj instanceof GroovyObject
         assert obj instanceof Bar
         obj.bar()
-
     }
 
     void testImplementSingleAbstractMethodReturningVoidAndSharedVariable() {