Skip to content

Commit a1f5fb5

Browse files
committed
Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
1 parent 39e3f2e commit a1f5fb5

File tree

38 files changed

+68
-68
lines changed

38 files changed

+68
-68
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public void setArgumentNamesFromStringArray(String... args) {
260260
}
261261
}
262262
if (this.argumentNames != null) {
263-
if (this.aspectJAdviceMethod.getParameterTypes().length == this.argumentNames.length + 1) {
263+
if (this.aspectJAdviceMethod.getParameterCount() == this.argumentNames.length + 1) {
264264
// May need to add implicit join point arg name...
265265
Class<?> firstArgType = this.aspectJAdviceMethod.getParameterTypes()[0];
266266
if (firstArgType == JoinPoint.class ||
@@ -463,7 +463,7 @@ protected ParameterNameDiscoverer createParameterNameDiscoverer() {
463463
private void bindExplicitArguments(int numArgumentsLeftToBind) {
464464
this.argumentBindings = new HashMap<>();
465465

466-
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterTypes().length;
466+
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterCount();
467467
if (this.argumentNames.length != numExpectedArgumentNames) {
468468
throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames +
469469
" arguments to bind by name in advice, but actually found " +
@@ -620,7 +620,7 @@ protected Object invokeAdviceMethod(JoinPoint jp, JoinPointMatch jpMatch, Object
620620

621621
protected Object invokeAdviceMethodWithGivenArgs(Object[] args) throws Throwable {
622622
Object[] actualArgs = args;
623-
if (this.aspectJAdviceMethod.getParameterTypes().length == 0) {
623+
if (this.aspectJAdviceMethod.getParameterCount() == 0) {
624624
actualArgs = null;
625625
}
626626
try {

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private static class AspectJAnnotationParameterNameDiscoverer implements Paramet
305305

306306
@Override
307307
public String[] getParameterNames(Method method) {
308-
if (method.getParameterTypes().length == 0) {
308+
if (method.getParameterCount() == 0) {
309309
return new String[0];
310310
}
311311
AspectJAnnotation<?> annotation = findAspectJAnnotationOnMethod(method);

spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ public ThrowsAdviceInterceptor(Object throwsAdvice) {
7777
Method[] methods = throwsAdvice.getClass().getMethods();
7878
for (Method method : methods) {
7979
if (method.getName().equals(AFTER_THROWING) &&
80-
(method.getParameterTypes().length == 1 || method.getParameterTypes().length == 4) &&
81-
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length - 1])
80+
(method.getParameterCount() == 1 || method.getParameterCount() == 4) &&
81+
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterCount() - 1])
8282
) {
8383
// Have an exception handler
84-
this.exceptionHandlerMap.put(method.getParameterTypes()[method.getParameterTypes().length - 1], method);
84+
this.exceptionHandlerMap.put(method.getParameterTypes()[method.getParameterCount() - 1], method);
8585
if (logger.isDebugEnabled()) {
8686
logger.debug("Found exception handler method: " + method);
8787
}
@@ -135,7 +135,7 @@ public Object invoke(MethodInvocation mi) throws Throwable {
135135

136136
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
137137
Object[] handlerArgs;
138-
if (method.getParameterTypes().length == 1) {
138+
if (method.getParameterCount() == 1) {
139139
handlerArgs = new Object[] { ex };
140140
}
141141
else {

spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static boolean isToStringMethod(Method method) {
168168
*/
169169
public static boolean isFinalizeMethod(Method method) {
170170
return (method != null && method.getName().equals("finalize") &&
171-
method.getParameterTypes().length == 0);
171+
method.getParameterCount() == 0);
172172
}
173173

174174
/**

spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static class SetterPointcut extends StaticMethodMatcherPointcut implemen
9999
@Override
100100
public boolean matches(Method method, Class<?> targetClass) {
101101
return (method.getName().startsWith("set") &&
102-
method.getParameterTypes().length == 1 &&
102+
method.getParameterCount() == 1 &&
103103
method.getReturnType() == Void.TYPE);
104104
}
105105

@@ -120,7 +120,7 @@ private static class GetterPointcut extends StaticMethodMatcherPointcut implemen
120120
@Override
121121
public boolean matches(Method method, Class<?> targetClass) {
122122
return (method.getName().startsWith("get") &&
123-
method.getParameterTypes().length == 0);
123+
method.getParameterCount() == 0);
124124
}
125125

126126
private Object readResolve() {

spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ protected void assertParameterNames(Method m, String pointcut, String[] paramete
270270

271271
protected void assertParameterNames(Method m, String pointcut, String returning, String throwing, String[] parameterNames) {
272272
assertEquals("bad test specification, must have same number of parameter names as method arguments",
273-
m.getParameterTypes().length, parameterNames.length);
273+
m.getParameterCount(), parameterNames.length);
274274

275275
AspectJAdviceParameterNameDiscoverer discoverer = new AspectJAdviceParameterNameDiscoverer(pointcut);
276276
discoverer.setRaiseExceptions(true);

spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ public static Method findMethodWithMinimalParameters(Method[] methods, String me
269269
int numMethodsFoundWithCurrentMinimumArgs = 0;
270270
for (Method method : methods) {
271271
if (method.getName().equals(methodName)) {
272-
int numParams = method.getParameterTypes().length;
273-
if (targetMethod == null || numParams < targetMethod.getParameterTypes().length) {
272+
int numParams = method.getParameterCount();
273+
if (targetMethod == null || numParams < targetMethod.getParameterCount()) {
274274
targetMethod = method;
275275
numMethodsFoundWithCurrentMinimumArgs = 1;
276276
}
277-
else if (!method.isBridge() && targetMethod.getParameterTypes().length == numParams) {
277+
else if (!method.isBridge() && targetMethod.getParameterCount() == numParams) {
278278
if (targetMethod.isBridge()) {
279279
// Prefer regular method over bridge...
280280
targetMethod = method;

spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static boolean isCandidateWriteMethod(Method method) {
157157
}
158158

159159
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
160-
int nParams = method.getParameterTypes().length;
160+
int nParams = method.getParameterCount();
161161
String propertyName = propertyNameFor(method);
162162
Class<?> propertyType = method.getParameterTypes()[nParams - 1];
163163
PropertyDescriptor existingPd = findExistingPropertyDescriptor(propertyName, propertyType);

spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyNam
7575
// covariant return type whereas the setter is defined for the concrete property type.
7676
Method candidate = ClassUtils.getMethodIfAvailable(
7777
this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null);
78-
if (candidate != null && candidate.getParameterTypes().length == 1) {
78+
if (candidate != null && candidate.getParameterCount() == 1) {
7979
writeMethodToUse = candidate;
8080
}
8181
}
@@ -91,7 +91,7 @@ public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyNam
9191
for (Method method : beanClass.getMethods()) {
9292
if (method.getName().equals(writeMethodToUse.getName()) &&
9393
!method.equals(writeMethodToUse) && !method.isBridge() &&
94-
method.getParameterTypes().length == writeMethodToUse.getParameterTypes().length) {
94+
method.getParameterCount() == writeMethodToUse.getParameterCount()) {
9595
ambiguousCandidates.add(method);
9696
}
9797
}

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
292292
". Found constructor with 'required' Autowired annotation already: " +
293293
requiredConstructor);
294294
}
295-
if (candidate.getParameterTypes().length == 0) {
295+
if (candidate.getParameterCount() == 0) {
296296
throw new IllegalStateException(
297297
"Autowired annotation requires at least one argument: " + candidate);
298298
}
@@ -308,7 +308,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
308308
}
309309
candidates.add(candidate);
310310
}
311-
else if (candidate.getParameterTypes().length == 0) {
311+
else if (candidate.getParameterCount() == 0) {
312312
defaultConstructor = candidate;
313313
}
314314
}
@@ -327,7 +327,7 @@ else if (candidates.size() == 1 && logger.isWarnEnabled()) {
327327
}
328328
candidateConstructors = candidates.toArray(new Constructor<?>[candidates.size()]);
329329
}
330-
else if (rawCandidates.length == 1 && rawCandidates[0].getParameterTypes().length > 0) {
330+
else if (rawCandidates.length == 1 && rawCandidates[0].getParameterCount() > 0) {
331331
candidateConstructors = new Constructor<?>[] {rawCandidates[0]};
332332
}
333333
else {
@@ -444,7 +444,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
444444
}
445445
return;
446446
}
447-
if (method.getParameterTypes().length == 0) {
447+
if (method.getParameterCount() == 0) {
448448
if (logger.isWarnEnabled()) {
449449
logger.warn("Autowired annotation should be used on methods with parameters: " + method);
450450
}

spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private static class LifecycleElement {
344344
private final String identifier;
345345

346346
public LifecycleElement(Method method) {
347-
if (method.getParameterTypes().length != 0) {
347+
if (method.getParameterCount() != 0) {
348348
throw new IllegalStateException("Lifecycle method annotation requires a no-arg method: " + method);
349349
}
350350
this.method = method;

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m
684684
for (Method factoryMethod : candidates) {
685685
if (Modifier.isStatic(factoryMethod.getModifiers()) == isStatic &&
686686
factoryMethod.getName().equals(mbd.getFactoryMethodName()) &&
687-
factoryMethod.getParameterTypes().length >= minNrOfArgs) {
687+
factoryMethod.getParameterCount() >= minNrOfArgs) {
688688
// Declared type variables to inspect?
689689
if (factoryMethod.getTypeParameters().length > 0) {
690690
try {

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public int getResolvedAutowireMode() {
516516
// otherwise we'll try constructor autowiring.
517517
Constructor<?>[] constructors = getBeanClass().getConstructors();
518518
for (Constructor<?> constructor : constructors) {
519-
if (constructor.getParameterTypes().length == 0) {
519+
if (constructor.getParameterCount() == 0) {
520520
return AUTOWIRE_BY_TYPE;
521521
}
522522
}

spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public int compare(Constructor<?> c1, Constructor<?> c2) {
6565
if (p1 != p2) {
6666
return (p1 ? -1 : 1);
6767
}
68-
int c1pl = c1.getParameterTypes().length;
69-
int c2pl = c2.getParameterTypes().length;
68+
int c1pl = c1.getParameterCount();
69+
int c2pl = c2.getParameterCount();
7070
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
7171
}
7272
});
@@ -88,8 +88,8 @@ public int compare(Method fm1, Method fm2) {
8888
if (p1 != p2) {
8989
return (p1 ? -1 : 1);
9090
}
91-
int c1pl = fm1.getParameterTypes().length;
92-
int c2pl = fm2.getParameterTypes().length;
91+
int c1pl = fm1.getParameterCount();
92+
int c2pl = fm2.getParameterCount();
9393
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
9494
}
9595
});

spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public boolean matches(Method method) {
8383
}
8484
else {
8585
return (method.getName().equals(getMethodName()) && (!isOverloaded() ||
86-
Modifier.isAbstract(method.getModifiers()) || method.getParameterTypes().length == 0));
86+
Modifier.isAbstract(method.getModifiers()) || method.getParameterCount() == 0));
8787
}
8888
}
8989

spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public boolean matches(Method method) {
7979
return true;
8080
}
8181
// If we get here, we need to insist on precise argument matching...
82-
if (this.typeIdentifiers.size() != method.getParameterTypes().length) {
82+
if (this.typeIdentifiers.size() != method.getParameterCount()) {
8383
return false;
8484
}
8585
for (int i = 0; i < this.typeIdentifiers.size(); i++) {

spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected StringBuilder getOperationDescription() {
139139

140140
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
141141
List<CacheParameterDetail> result = new ArrayList<>();
142-
for (int i = 0; i < method.getParameterTypes().length; i++) {
142+
for (int i = 0; i < method.getParameterCount(); i++) {
143143
CacheParameterDetail detail = new CacheParameterDetail(method, i);
144144
result.add(detail);
145145
}

spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
396396
if (Modifier.isStatic(method.getModifiers())) {
397397
throw new IllegalStateException("@WebServiceRef annotation is not supported on static methods");
398398
}
399-
if (method.getParameterTypes().length != 1) {
399+
if (method.getParameterCount() != 1) {
400400
throw new IllegalStateException("@WebServiceRef annotation requires a single-arg method: " + method);
401401
}
402402
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
@@ -406,7 +406,7 @@ else if (ejbRefClass != null && bridgedMethod.isAnnotationPresent(ejbRefClass))
406406
if (Modifier.isStatic(method.getModifiers())) {
407407
throw new IllegalStateException("@EJB annotation is not supported on static methods");
408408
}
409-
if (method.getParameterTypes().length != 1) {
409+
if (method.getParameterCount() != 1) {
410410
throw new IllegalStateException("@EJB annotation requires a single-arg method: " + method);
411411
}
412412
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
284284
@Override
285285
public boolean isMatch(Method candidateMethod) {
286286
return (candidateMethod.getName().equals("setBeanFactory") &&
287-
candidateMethod.getParameterTypes().length == 1 &&
287+
candidateMethod.getParameterCount() == 1 &&
288288
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
289289
BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass()));
290290
}

spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected Object[] resolveArguments(ApplicationEvent event) {
161161
if (declaredEventType == null) {
162162
return null;
163163
}
164-
if (this.method.getParameterTypes().length == 0) {
164+
if (this.method.getParameterCount() == 0) {
165165
return new Object[0];
166166
}
167167
if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.getRawClass())
@@ -347,7 +347,7 @@ private ResolvableType getResolvableType(ApplicationEvent event) {
347347
}
348348

349349
private List<ResolvableType> resolveDeclaredEventTypes() {
350-
int count = this.method.getParameterTypes().length;
350+
int count = this.method.getParameterCount();
351351
if (count > 1) {
352352
throw new IllegalStateException(
353353
"Maximum one parameter is allowed for event listener method: " + this.method);

spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public Set<Scheduled> inspect(Method method) {
293293

294294
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
295295
try {
296-
Assert.isTrue(method.getParameterTypes().length == 0,
296+
Assert.isTrue(method.getParameterCount() == 0,
297297
"Only no-arg methods may be annotated with @Scheduled");
298298

299299
Method invocableMethod = AopUtils.selectInvocableMethod(method, bean.getClass());

spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static Advisor advisor() {
231231
new StaticMethodMatcherPointcut() {
232232
@Override
233233
public boolean matches(Method method, Class<?> targetClass) {
234-
return method.getParameterTypes().length == 1 &&
234+
return method.getParameterCount() == 1 &&
235235
method.getParameterTypes()[0].equals(Integer.class);
236236
}
237237
},

spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,15 +1217,15 @@ public void testOverloadedMethodsWithDifferentAdvice() throws Throwable {
12171217
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
12181218
@Override
12191219
public boolean matches(Method m, Class<?> targetClass) {
1220-
return m.getName().equals("overload") && m.getParameterTypes().length == 0;
1220+
return m.getName().equals("overload") && m.getParameterCount() == 0;
12211221
}
12221222
});
12231223

12241224
NopInterceptor overLoadInts = new NopInterceptor();
12251225
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadInts) {
12261226
@Override
12271227
public boolean matches(Method m, Class<?> targetClass) {
1228-
return m.getName().equals("overload") && m.getParameterTypes().length == 1 &&
1228+
return m.getName().equals("overload") && m.getParameterCount() == 1 &&
12291229
m.getParameterTypes()[0].equals(int.class);
12301230
}
12311231
});
@@ -1314,7 +1314,7 @@ public void testBeforeAdvisorIsInvoked() {
13141314
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
13151315
@Override
13161316
public boolean matches(Method m, Class<?> targetClass) {
1317-
return m.getParameterTypes().length == 0;
1317+
return m.getParameterCount() == 0;
13181318
}
13191319
};
13201320
TestBean target = new TestBean();
@@ -1395,7 +1395,7 @@ public void testMultiAdvice() throws Throwable {
13951395
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
13961396
@Override
13971397
public boolean matches(Method m, Class<?> targetClass) {
1398-
return m.getParameterTypes().length == 0 || "exceptional".equals(m.getName());
1398+
return m.getParameterCount() == 0 || "exceptional".equals(m.getName());
13991399
}
14001400
};
14011401
TestBean target = new TestBean();
@@ -1694,7 +1694,7 @@ public boolean matches(Method m, Class<?> targetClass, Object... args) {
16941694
@Override
16951695
public boolean matches(Method m, Class<?> targetClass) {
16961696
return m.getName().startsWith("set") &&
1697-
m.getParameterTypes().length == 1 &&
1697+
m.getParameterCount() == 1 &&
16981698
m.getParameterTypes()[0].equals(String.class);
16991699
}
17001700
});

spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static Method findBridgedMethod(Method bridgeMethod) {
9393
private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
9494
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
9595
candidateMethod.getName().equals(bridgeMethod.getName()) &&
96-
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
96+
candidateMethod.getParameterCount() == bridgeMethod.getParameterCount());
9797
}
9898

9999
/**

spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ static Annotation getAnnotation(AnnotatedElement element, String annotationName)
16821682
* @since 4.2
16831683
*/
16841684
static boolean isAttributeMethod(Method method) {
1685-
return (method != null && method.getParameterTypes().length == 0 && method.getReturnType() != void.class);
1685+
return (method != null && method.getParameterCount() == 0 && method.getReturnType() != void.class);
16861686
}
16871687

16881688
/**
@@ -1692,7 +1692,7 @@ static boolean isAttributeMethod(Method method) {
16921692
* @since 4.2
16931693
*/
16941694
static boolean isAnnotationTypeMethod(Method method) {
1695-
return (method != null && method.getName().equals("annotationType") && method.getParameterTypes().length == 0);
1695+
return (method != null && method.getName().equals("annotationType") && method.getParameterCount() == 0);
16961696
}
16971697

16981698
/**

spring-core/src/main/java/org/springframework/core/convert/support/IdToEntityConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private Method getFinder(Class<?> entityClass) {
8888
}
8989
for (Method method : methods) {
9090
if (Modifier.isStatic(method.getModifiers()) && method.getName().equals(finderMethod) &&
91-
method.getParameterTypes().length == 1 && method.getReturnType().equals(entityClass) &&
91+
method.getParameterCount() == 1 && method.getReturnType().equals(entityClass) &&
9292
(localOnlyFiltered || method.getDeclaringClass().equals(entityClass))) {
9393
return method;
9494
}

0 commit comments

Comments
 (0)