changeset 58685:14f909934eb2

8242208: Use Method.getParameterCount where applicable Reviewed-by: redestad, chegar Contributed-by: christoph.dreis@freenet.de
author redestad
date Mon, 06 Apr 2020 13:46:09 +0200
parents eadb0e565c56
children 0c8345a2ad50
files src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java src/java.base/share/classes/java/lang/reflect/Executable.java src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java
diffstat 3 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java	Mon Apr 06 13:44:54 2020 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java	Mon Apr 06 13:46:09 2020 +0200
@@ -276,13 +276,13 @@
         switch (m.getName()) {
         case "toString":
             return (m.getReturnType() == String.class
-                    && m.getParameterTypes().length == 0);
+                    && m.getParameterCount() == 0);
         case "hashCode":
             return (m.getReturnType() == int.class
-                    && m.getParameterTypes().length == 0);
+                    && m.getParameterCount() == 0);
         case "equals":
             return (m.getReturnType() == boolean.class
-                    && m.getParameterTypes().length == 1
+                    && m.getParameterCount() == 1
                     && m.getParameterTypes()[0] == Object.class);
         }
         return false;
--- a/src/java.base/share/classes/java/lang/reflect/Executable.java	Mon Apr 06 13:44:54 2020 +0200
+++ b/src/java.base/share/classes/java/lang/reflect/Executable.java	Mon Apr 06 13:46:09 2020 +0200
@@ -378,7 +378,7 @@
     private void verifyParameters(final Parameter[] parameters) {
         final int mask = Modifier.FINAL | Modifier.SYNTHETIC | Modifier.MANDATED;
 
-        if (getParameterTypes().length != parameters.length)
+        if (getParameterCount() != parameters.length)
             throw new MalformedParametersException("Wrong number of parameters in MethodParameters attribute");
 
         for (Parameter parameter : parameters) {
--- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java	Mon Apr 06 13:44:54 2020 +0200
+++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java	Mon Apr 06 13:46:09 2020 +0200
@@ -121,7 +121,7 @@
             if (Modifier.isPublic(method.getModifiers()) &&
                 Modifier.isAbstract(method.getModifiers()) &&
                 !method.isSynthetic()) {
-                if (method.getParameterTypes().length != 0) {
+                if (method.getParameterCount() != 0) {
                     throw new IllegalArgumentException(method + " has params");
                 }
                 String name = method.getName();