8156226: DiagnosticCommandImpl::invoke throws not very comprehensive message in case if method exists but signature or parameters are wrong
authorkzhaldyb
Wed, 15 Jun 2016 20:43:53 +0300
changeset 39327 aaf17117b16c
parent 39326 7493098fd9cd
child 39328 ba6d354b8dd8
child 39466 838ae1e90961
8156226: DiagnosticCommandImpl::invoke throws not very comprehensive message in case if method exists but signature or parameters are wrong Reviewed-by: mchung, dholmes, dfuchs
jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java
--- a/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java	Wed Jun 15 11:24:12 2016 +0300
+++ b/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java	Wed Jun 15 20:43:53 2016 +0300
@@ -259,9 +259,20 @@
                     && signature[0] != null
                     && signature[0].compareTo(strArrayClassName) == 0)) {
                 return w.execute((String[]) params[0]);
+            } else {
+                throw new ReflectionException(
+                    new NoSuchMethodException(actionName
+                    + ": mismatched signature "
+                    + (signature != null ? Arrays.toString(signature) : "[]")
+                    + " or parameters"));
             }
+        } else {
+            throw new ReflectionException(
+                new NoSuchMethodException("Method " + actionName
+                + " with signature "
+                + (signature != null ? Arrays.toString(signature) : "[]")
+                + " not found"));
         }
-        throw new ReflectionException(new NoSuchMethodException(actionName));
     }
 
     private static String transform(String name) {