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 2022/09/05 18:06:27 UTC
[groovy] 02/02: Further tweak for `clone` via `InvokerHelper`
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit e81e1f711849d32ff96c10ac7d0f6b94f7185a9c
Author: Daniel Sun <su...@apache.org>
AuthorDate: Tue Sep 6 02:04:52 2022 +0800
Further tweak for `clone` via `InvokerHelper`
(cherry picked from commit 38e45ceabbc9a597ac5c7d667036af1dc9af69ee)
---
src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java | 3 +--
src/test/groovy/bugs/Groovy9103.groovy | 2 ++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
index b4fcf192a4..a83fbbaced 100644
--- a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
@@ -44,7 +44,6 @@ import org.codehaus.groovy.runtime.wrappers.PojoWrapper;
import java.beans.Introspector;
import java.io.IOException;
import java.io.Writer;
-import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
@@ -587,7 +586,7 @@ public class InvokerHelper {
return metaClass.invokeStaticMethod(object, methodName, asArray(arguments));
}
- if ("clone".equals(methodName) && (null == arguments || arguments.getClass().isArray() && 0 == Array.getLength(arguments))) {
+ if ("clone".equals(methodName) && 0 == asArray(arguments).length) {
try {
return ObjectUtil.cloneObject(object);
} catch (Throwable t) {
diff --git a/src/test/groovy/bugs/Groovy9103.groovy b/src/test/groovy/bugs/Groovy9103.groovy
index f4f8117426..53c006e141 100644
--- a/src/test/groovy/bugs/Groovy9103.groovy
+++ b/src/test/groovy/bugs/Groovy9103.groovy
@@ -86,6 +86,7 @@ final class Groovy9103 {
class Dolly implements Cloneable {
String name
+ @Override
public ${typeName} clone() {
return super.clone()
}
@@ -118,6 +119,7 @@ final class Groovy9103 {
class Dolly implements Cloneable {
String name
+ @Override
public ${typeName} clone() {
return super.clone()
}