groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 03/04: fix for NPE
Date Sat, 12 Oct 2019 13:03:08 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit c716595eb3a801b9a315003c04e38b06abc0ad0c
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Fri Oct 11 15:11:46 2019 -0500

    fix for NPE
    
    closes #810
    
    (cherry picked from commit 22a46a113e935745a699c7fac753c94e69ce053e)
---
 .../java/groovy/lang/MissingMethodException.java   | 28 +++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/main/java/groovy/lang/MissingMethodException.java b/src/main/java/groovy/lang/MissingMethodException.java
index 3dbaf86..6a9a857 100644
--- a/src/main/java/groovy/lang/MissingMethodException.java
+++ b/src/main/java/groovy/lang/MissingMethodException.java
@@ -29,41 +29,41 @@ import org.codehaus.groovy.runtime.MethodRankHelper;
  */
 public class MissingMethodException extends GroovyRuntimeException {
 
-    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
     private static final long serialVersionUID = -6676430495683939401L;
+
     private final String method;
-    private final Class type;
+    private final Class<?> type;
     private final boolean isStatic;
+    private final Object[] arguments;
 
-    public Object[] getArguments() {
-        return arguments;
-    }
-
-    private final Object arguments[];
-
-    public MissingMethodException(String method, Class type, Object[] arguments) {
+    public MissingMethodException(String method, Class<?> type, Object[] arguments)
{
         this(method, type, arguments, false);
     }
 
-    public MissingMethodException(String method, Class type, Object[] arguments, boolean
isStatic) {
+    public MissingMethodException(String method, Class<?> type, Object[] arguments,
boolean isStatic) {
         super();
         this.method = method;
         this.type = type;
         this.isStatic = isStatic;
-        this.arguments = arguments == null ? EMPTY_OBJECT_ARRAY : arguments;
+        this.arguments = arguments != null ? arguments : new Object[0];
+    }
+
+    public Object[] getArguments() {
+        return arguments;
     }
 
+    @Override
     public String getMessage() {
         return "No signature of method: "
                 + (isStatic ? "static " : "")
-                + type.getName()
+                + (type != null ? type.getName() : "<unknown>")
                 + "."
                 + method
                 + "() is applicable for argument types: ("
                 + InvokerHelper.toTypeString(arguments, 60)
                 + ") values: "
                 + InvokerHelper.toArrayString(arguments, 60, true)
-                + MethodRankHelper.getMethodSuggestionString(method, type, arguments);
+                + (type != null ? MethodRankHelper.getMethodSuggestionString(method, type,
arguments) : "");
     }
 
     /**
@@ -76,7 +76,7 @@ public class MissingMethodException extends GroovyRuntimeException {
     /**
      * @return The type on which the method was attempted to be called
      */
-    public Class getType() {
+    public Class<?> getType() {
         return type;
     }
 


Mime
View raw message