Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
This commit is contained in:
@@ -269,12 +269,12 @@ public abstract class BeanUtils {
|
||||
int numMethodsFoundWithCurrentMinimumArgs = 0;
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)) {
|
||||
int numParams = method.getParameterTypes().length;
|
||||
if (targetMethod == null || numParams < targetMethod.getParameterTypes().length) {
|
||||
int numParams = method.getParameterCount();
|
||||
if (targetMethod == null || numParams < targetMethod.getParameterCount()) {
|
||||
targetMethod = method;
|
||||
numMethodsFoundWithCurrentMinimumArgs = 1;
|
||||
}
|
||||
else if (!method.isBridge() && targetMethod.getParameterTypes().length == numParams) {
|
||||
else if (!method.isBridge() && targetMethod.getParameterCount() == numParams) {
|
||||
if (targetMethod.isBridge()) {
|
||||
// Prefer regular method over bridge...
|
||||
targetMethod = method;
|
||||
|
||||
@@ -157,7 +157,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
|
||||
int nParams = method.getParameterTypes().length;
|
||||
int nParams = method.getParameterCount();
|
||||
String propertyName = propertyNameFor(method);
|
||||
Class<?> propertyType = method.getParameterTypes()[nParams - 1];
|
||||
PropertyDescriptor existingPd = findExistingPropertyDescriptor(propertyName, propertyType);
|
||||
|
||||
@@ -75,7 +75,7 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
// covariant return type whereas the setter is defined for the concrete property type.
|
||||
Method candidate = ClassUtils.getMethodIfAvailable(
|
||||
this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null);
|
||||
if (candidate != null && candidate.getParameterTypes().length == 1) {
|
||||
if (candidate != null && candidate.getParameterCount() == 1) {
|
||||
writeMethodToUse = candidate;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
for (Method method : beanClass.getMethods()) {
|
||||
if (method.getName().equals(writeMethodToUse.getName()) &&
|
||||
!method.equals(writeMethodToUse) && !method.isBridge() &&
|
||||
method.getParameterTypes().length == writeMethodToUse.getParameterTypes().length) {
|
||||
method.getParameterCount() == writeMethodToUse.getParameterCount()) {
|
||||
ambiguousCandidates.add(method);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
". Found constructor with 'required' Autowired annotation already: " +
|
||||
requiredConstructor);
|
||||
}
|
||||
if (candidate.getParameterTypes().length == 0) {
|
||||
if (candidate.getParameterCount() == 0) {
|
||||
throw new IllegalStateException(
|
||||
"Autowired annotation requires at least one argument: " + candidate);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
candidates.add(candidate);
|
||||
}
|
||||
else if (candidate.getParameterTypes().length == 0) {
|
||||
else if (candidate.getParameterCount() == 0) {
|
||||
defaultConstructor = candidate;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +327,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
candidateConstructors = candidates.toArray(new Constructor<?>[candidates.size()]);
|
||||
}
|
||||
else if (rawCandidates.length == 1 && rawCandidates[0].getParameterTypes().length > 0) {
|
||||
else if (rawCandidates.length == 1 && rawCandidates[0].getParameterCount() > 0) {
|
||||
candidateConstructors = new Constructor<?>[] {rawCandidates[0]};
|
||||
}
|
||||
else {
|
||||
@@ -444,7 +444,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (method.getParameterTypes().length == 0) {
|
||||
if (method.getParameterCount() == 0) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Autowired annotation should be used on methods with parameters: " + method);
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
private final String identifier;
|
||||
|
||||
public LifecycleElement(Method method) {
|
||||
if (method.getParameterTypes().length != 0) {
|
||||
if (method.getParameterCount() != 0) {
|
||||
throw new IllegalStateException("Lifecycle method annotation requires a no-arg method: " + method);
|
||||
}
|
||||
this.method = method;
|
||||
|
||||
@@ -684,7 +684,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
for (Method factoryMethod : candidates) {
|
||||
if (Modifier.isStatic(factoryMethod.getModifiers()) == isStatic &&
|
||||
factoryMethod.getName().equals(mbd.getFactoryMethodName()) &&
|
||||
factoryMethod.getParameterTypes().length >= minNrOfArgs) {
|
||||
factoryMethod.getParameterCount() >= minNrOfArgs) {
|
||||
// Declared type variables to inspect?
|
||||
if (factoryMethod.getTypeParameters().length > 0) {
|
||||
try {
|
||||
|
||||
@@ -516,7 +516,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
// otherwise we'll try constructor autowiring.
|
||||
Constructor<?>[] constructors = getBeanClass().getConstructors();
|
||||
for (Constructor<?> constructor : constructors) {
|
||||
if (constructor.getParameterTypes().length == 0) {
|
||||
if (constructor.getParameterCount() == 0) {
|
||||
return AUTOWIRE_BY_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ abstract class AutowireUtils {
|
||||
if (p1 != p2) {
|
||||
return (p1 ? -1 : 1);
|
||||
}
|
||||
int c1pl = c1.getParameterTypes().length;
|
||||
int c2pl = c2.getParameterTypes().length;
|
||||
int c1pl = c1.getParameterCount();
|
||||
int c2pl = c2.getParameterCount();
|
||||
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
|
||||
}
|
||||
});
|
||||
@@ -88,8 +88,8 @@ abstract class AutowireUtils {
|
||||
if (p1 != p2) {
|
||||
return (p1 ? -1 : 1);
|
||||
}
|
||||
int c1pl = fm1.getParameterTypes().length;
|
||||
int c2pl = fm2.getParameterTypes().length;
|
||||
int c1pl = fm1.getParameterCount();
|
||||
int c2pl = fm2.getParameterCount();
|
||||
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LookupOverride extends MethodOverride {
|
||||
}
|
||||
else {
|
||||
return (method.getName().equals(getMethodName()) && (!isOverloaded() ||
|
||||
Modifier.isAbstract(method.getModifiers()) || method.getParameterTypes().length == 0));
|
||||
Modifier.isAbstract(method.getModifiers()) || method.getParameterCount() == 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ReplaceOverride extends MethodOverride {
|
||||
return true;
|
||||
}
|
||||
// If we get here, we need to insist on precise argument matching...
|
||||
if (this.typeIdentifiers.size() != method.getParameterTypes().length) {
|
||||
if (this.typeIdentifiers.size() != method.getParameterCount()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.typeIdentifiers.size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user