Skip to content
Permalink
Browse files

8242208: Use Method.getParameterCount where applicable

Reviewed-by: redestad, chegar
  • Loading branch information
dreis2211 authored and cl4es committed Apr 6, 2020
1 parent e9adf7b commit 08b90285b299e40c8d851099063e5af9b0244ffd
@@ -276,13 +276,13 @@ private static boolean isObjectMethod(Method m) {
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;
@@ -378,7 +378,7 @@ public int getParameterCount() {
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) {
@@ -121,7 +121,7 @@ private AnnotationType(final Class<? extends Annotation> annotationClass) {
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();

0 comments on commit 08b9028

Please sign in to comment.