Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
This commit is contained in:
parent
39e3f2ebf6
commit
a1f5fb53db
|
@ -260,7 +260,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.argumentNames != null) {
|
if (this.argumentNames != null) {
|
||||||
if (this.aspectJAdviceMethod.getParameterTypes().length == this.argumentNames.length + 1) {
|
if (this.aspectJAdviceMethod.getParameterCount() == this.argumentNames.length + 1) {
|
||||||
// May need to add implicit join point arg name...
|
// May need to add implicit join point arg name...
|
||||||
Class<?> firstArgType = this.aspectJAdviceMethod.getParameterTypes()[0];
|
Class<?> firstArgType = this.aspectJAdviceMethod.getParameterTypes()[0];
|
||||||
if (firstArgType == JoinPoint.class ||
|
if (firstArgType == JoinPoint.class ||
|
||||||
|
@ -463,7 +463,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
private void bindExplicitArguments(int numArgumentsLeftToBind) {
|
private void bindExplicitArguments(int numArgumentsLeftToBind) {
|
||||||
this.argumentBindings = new HashMap<>();
|
this.argumentBindings = new HashMap<>();
|
||||||
|
|
||||||
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterTypes().length;
|
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterCount();
|
||||||
if (this.argumentNames.length != numExpectedArgumentNames) {
|
if (this.argumentNames.length != numExpectedArgumentNames) {
|
||||||
throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames +
|
throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames +
|
||||||
" arguments to bind by name in advice, but actually found " +
|
" arguments to bind by name in advice, but actually found " +
|
||||||
|
@ -620,7 +620,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
|
|
||||||
protected Object invokeAdviceMethodWithGivenArgs(Object[] args) throws Throwable {
|
protected Object invokeAdviceMethodWithGivenArgs(Object[] args) throws Throwable {
|
||||||
Object[] actualArgs = args;
|
Object[] actualArgs = args;
|
||||||
if (this.aspectJAdviceMethod.getParameterTypes().length == 0) {
|
if (this.aspectJAdviceMethod.getParameterCount() == 0) {
|
||||||
actualArgs = null;
|
actualArgs = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -305,7 +305,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getParameterNames(Method method) {
|
public String[] getParameterNames(Method method) {
|
||||||
if (method.getParameterTypes().length == 0) {
|
if (method.getParameterCount() == 0) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
AspectJAnnotation<?> annotation = findAspectJAnnotationOnMethod(method);
|
AspectJAnnotation<?> annotation = findAspectJAnnotationOnMethod(method);
|
||||||
|
|
|
@ -77,11 +77,11 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
Method[] methods = throwsAdvice.getClass().getMethods();
|
Method[] methods = throwsAdvice.getClass().getMethods();
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
if (method.getName().equals(AFTER_THROWING) &&
|
if (method.getName().equals(AFTER_THROWING) &&
|
||||||
(method.getParameterTypes().length == 1 || method.getParameterTypes().length == 4) &&
|
(method.getParameterCount() == 1 || method.getParameterCount() == 4) &&
|
||||||
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length - 1])
|
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterCount() - 1])
|
||||||
) {
|
) {
|
||||||
// Have an exception handler
|
// Have an exception handler
|
||||||
this.exceptionHandlerMap.put(method.getParameterTypes()[method.getParameterTypes().length - 1], method);
|
this.exceptionHandlerMap.put(method.getParameterTypes()[method.getParameterCount() - 1], method);
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Found exception handler method: " + method);
|
logger.debug("Found exception handler method: " + method);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
|
|
||||||
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
|
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
|
||||||
Object[] handlerArgs;
|
Object[] handlerArgs;
|
||||||
if (method.getParameterTypes().length == 1) {
|
if (method.getParameterCount() == 1) {
|
||||||
handlerArgs = new Object[] { ex };
|
handlerArgs = new Object[] { ex };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -168,7 +168,7 @@ public abstract class AopUtils {
|
||||||
*/
|
*/
|
||||||
public static boolean isFinalizeMethod(Method method) {
|
public static boolean isFinalizeMethod(Method method) {
|
||||||
return (method != null && method.getName().equals("finalize") &&
|
return (method != null && method.getName().equals("finalize") &&
|
||||||
method.getParameterTypes().length == 0);
|
method.getParameterCount() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -99,7 +99,7 @@ public abstract class Pointcuts {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class<?> targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return (method.getName().startsWith("set") &&
|
return (method.getName().startsWith("set") &&
|
||||||
method.getParameterTypes().length == 1 &&
|
method.getParameterCount() == 1 &&
|
||||||
method.getReturnType() == Void.TYPE);
|
method.getReturnType() == Void.TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public abstract class Pointcuts {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class<?> targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return (method.getName().startsWith("get") &&
|
return (method.getName().startsWith("get") &&
|
||||||
method.getParameterTypes().length == 0);
|
method.getParameterCount() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object readResolve() {
|
private Object readResolve() {
|
||||||
|
|
|
@ -270,7 +270,7 @@ public class AspectJAdviceParameterNameDiscovererTests {
|
||||||
|
|
||||||
protected void assertParameterNames(Method m, String pointcut, String returning, String throwing, String[] parameterNames) {
|
protected void assertParameterNames(Method m, String pointcut, String returning, String throwing, String[] parameterNames) {
|
||||||
assertEquals("bad test specification, must have same number of parameter names as method arguments",
|
assertEquals("bad test specification, must have same number of parameter names as method arguments",
|
||||||
m.getParameterTypes().length, parameterNames.length);
|
m.getParameterCount(), parameterNames.length);
|
||||||
|
|
||||||
AspectJAdviceParameterNameDiscoverer discoverer = new AspectJAdviceParameterNameDiscoverer(pointcut);
|
AspectJAdviceParameterNameDiscoverer discoverer = new AspectJAdviceParameterNameDiscoverer(pointcut);
|
||||||
discoverer.setRaiseExceptions(true);
|
discoverer.setRaiseExceptions(true);
|
||||||
|
|
|
@ -269,12 +269,12 @@ public abstract class BeanUtils {
|
||||||
int numMethodsFoundWithCurrentMinimumArgs = 0;
|
int numMethodsFoundWithCurrentMinimumArgs = 0;
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
if (method.getName().equals(methodName)) {
|
if (method.getName().equals(methodName)) {
|
||||||
int numParams = method.getParameterTypes().length;
|
int numParams = method.getParameterCount();
|
||||||
if (targetMethod == null || numParams < targetMethod.getParameterTypes().length) {
|
if (targetMethod == null || numParams < targetMethod.getParameterCount()) {
|
||||||
targetMethod = method;
|
targetMethod = method;
|
||||||
numMethodsFoundWithCurrentMinimumArgs = 1;
|
numMethodsFoundWithCurrentMinimumArgs = 1;
|
||||||
}
|
}
|
||||||
else if (!method.isBridge() && targetMethod.getParameterTypes().length == numParams) {
|
else if (!method.isBridge() && targetMethod.getParameterCount() == numParams) {
|
||||||
if (targetMethod.isBridge()) {
|
if (targetMethod.isBridge()) {
|
||||||
// Prefer regular method over bridge...
|
// Prefer regular method over bridge...
|
||||||
targetMethod = method;
|
targetMethod = method;
|
||||||
|
|
|
@ -157,7 +157,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
|
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
|
||||||
int nParams = method.getParameterTypes().length;
|
int nParams = method.getParameterCount();
|
||||||
String propertyName = propertyNameFor(method);
|
String propertyName = propertyNameFor(method);
|
||||||
Class<?> propertyType = method.getParameterTypes()[nParams - 1];
|
Class<?> propertyType = method.getParameterTypes()[nParams - 1];
|
||||||
PropertyDescriptor existingPd = findExistingPropertyDescriptor(propertyName, propertyType);
|
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.
|
// covariant return type whereas the setter is defined for the concrete property type.
|
||||||
Method candidate = ClassUtils.getMethodIfAvailable(
|
Method candidate = ClassUtils.getMethodIfAvailable(
|
||||||
this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null);
|
this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null);
|
||||||
if (candidate != null && candidate.getParameterTypes().length == 1) {
|
if (candidate != null && candidate.getParameterCount() == 1) {
|
||||||
writeMethodToUse = candidate;
|
writeMethodToUse = candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||||
for (Method method : beanClass.getMethods()) {
|
for (Method method : beanClass.getMethods()) {
|
||||||
if (method.getName().equals(writeMethodToUse.getName()) &&
|
if (method.getName().equals(writeMethodToUse.getName()) &&
|
||||||
!method.equals(writeMethodToUse) && !method.isBridge() &&
|
!method.equals(writeMethodToUse) && !method.isBridge() &&
|
||||||
method.getParameterTypes().length == writeMethodToUse.getParameterTypes().length) {
|
method.getParameterCount() == writeMethodToUse.getParameterCount()) {
|
||||||
ambiguousCandidates.add(method);
|
ambiguousCandidates.add(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
". Found constructor with 'required' Autowired annotation already: " +
|
". Found constructor with 'required' Autowired annotation already: " +
|
||||||
requiredConstructor);
|
requiredConstructor);
|
||||||
}
|
}
|
||||||
if (candidate.getParameterTypes().length == 0) {
|
if (candidate.getParameterCount() == 0) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Autowired annotation requires at least one argument: " + candidate);
|
"Autowired annotation requires at least one argument: " + candidate);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
}
|
}
|
||||||
candidates.add(candidate);
|
candidates.add(candidate);
|
||||||
}
|
}
|
||||||
else if (candidate.getParameterTypes().length == 0) {
|
else if (candidate.getParameterCount() == 0) {
|
||||||
defaultConstructor = candidate;
|
defaultConstructor = candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
}
|
}
|
||||||
candidateConstructors = candidates.toArray(new Constructor<?>[candidates.size()]);
|
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]};
|
candidateConstructors = new Constructor<?>[] {rawCandidates[0]};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -444,7 +444,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (method.getParameterTypes().length == 0) {
|
if (method.getParameterCount() == 0) {
|
||||||
if (logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn("Autowired annotation should be used on methods with parameters: " + method);
|
logger.warn("Autowired annotation should be used on methods with parameters: " + method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||||
private final String identifier;
|
private final String identifier;
|
||||||
|
|
||||||
public LifecycleElement(Method method) {
|
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);
|
throw new IllegalStateException("Lifecycle method annotation requires a no-arg method: " + method);
|
||||||
}
|
}
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
|
|
@ -684,7 +684,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||||
for (Method factoryMethod : candidates) {
|
for (Method factoryMethod : candidates) {
|
||||||
if (Modifier.isStatic(factoryMethod.getModifiers()) == isStatic &&
|
if (Modifier.isStatic(factoryMethod.getModifiers()) == isStatic &&
|
||||||
factoryMethod.getName().equals(mbd.getFactoryMethodName()) &&
|
factoryMethod.getName().equals(mbd.getFactoryMethodName()) &&
|
||||||
factoryMethod.getParameterTypes().length >= minNrOfArgs) {
|
factoryMethod.getParameterCount() >= minNrOfArgs) {
|
||||||
// Declared type variables to inspect?
|
// Declared type variables to inspect?
|
||||||
if (factoryMethod.getTypeParameters().length > 0) {
|
if (factoryMethod.getTypeParameters().length > 0) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -516,7 +516,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||||
// otherwise we'll try constructor autowiring.
|
// otherwise we'll try constructor autowiring.
|
||||||
Constructor<?>[] constructors = getBeanClass().getConstructors();
|
Constructor<?>[] constructors = getBeanClass().getConstructors();
|
||||||
for (Constructor<?> constructor : constructors) {
|
for (Constructor<?> constructor : constructors) {
|
||||||
if (constructor.getParameterTypes().length == 0) {
|
if (constructor.getParameterCount() == 0) {
|
||||||
return AUTOWIRE_BY_TYPE;
|
return AUTOWIRE_BY_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ abstract class AutowireUtils {
|
||||||
if (p1 != p2) {
|
if (p1 != p2) {
|
||||||
return (p1 ? -1 : 1);
|
return (p1 ? -1 : 1);
|
||||||
}
|
}
|
||||||
int c1pl = c1.getParameterTypes().length;
|
int c1pl = c1.getParameterCount();
|
||||||
int c2pl = c2.getParameterTypes().length;
|
int c2pl = c2.getParameterCount();
|
||||||
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
|
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -88,8 +88,8 @@ abstract class AutowireUtils {
|
||||||
if (p1 != p2) {
|
if (p1 != p2) {
|
||||||
return (p1 ? -1 : 1);
|
return (p1 ? -1 : 1);
|
||||||
}
|
}
|
||||||
int c1pl = fm1.getParameterTypes().length;
|
int c1pl = fm1.getParameterCount();
|
||||||
int c2pl = fm2.getParameterTypes().length;
|
int c2pl = fm2.getParameterCount();
|
||||||
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
|
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class LookupOverride extends MethodOverride {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (method.getName().equals(getMethodName()) && (!isOverloaded() ||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
// If we get here, we need to insist on precise argument matching...
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < this.typeIdentifiers.size(); i++) {
|
for (int i = 0; i < this.typeIdentifiers.size(); i++) {
|
||||||
|
|
|
@ -139,7 +139,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||||
|
|
||||||
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
|
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
|
||||||
List<CacheParameterDetail> result = new ArrayList<>();
|
List<CacheParameterDetail> result = new ArrayList<>();
|
||||||
for (int i = 0; i < method.getParameterTypes().length; i++) {
|
for (int i = 0; i < method.getParameterCount(); i++) {
|
||||||
CacheParameterDetail detail = new CacheParameterDetail(method, i);
|
CacheParameterDetail detail = new CacheParameterDetail(method, i);
|
||||||
result.add(detail);
|
result.add(detail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,7 +396,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
if (Modifier.isStatic(method.getModifiers())) {
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
throw new IllegalStateException("@WebServiceRef annotation is not supported on static methods");
|
throw new IllegalStateException("@WebServiceRef annotation is not supported on static methods");
|
||||||
}
|
}
|
||||||
if (method.getParameterTypes().length != 1) {
|
if (method.getParameterCount() != 1) {
|
||||||
throw new IllegalStateException("@WebServiceRef annotation requires a single-arg method: " + method);
|
throw new IllegalStateException("@WebServiceRef annotation requires a single-arg method: " + method);
|
||||||
}
|
}
|
||||||
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
|
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
|
||||||
|
@ -406,7 +406,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
if (Modifier.isStatic(method.getModifiers())) {
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
throw new IllegalStateException("@EJB annotation is not supported on static methods");
|
throw new IllegalStateException("@EJB annotation is not supported on static methods");
|
||||||
}
|
}
|
||||||
if (method.getParameterTypes().length != 1) {
|
if (method.getParameterCount() != 1) {
|
||||||
throw new IllegalStateException("@EJB annotation requires a single-arg method: " + method);
|
throw new IllegalStateException("@EJB annotation requires a single-arg method: " + method);
|
||||||
}
|
}
|
||||||
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
|
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
|
||||||
|
|
|
@ -284,7 +284,7 @@ class ConfigurationClassEnhancer {
|
||||||
@Override
|
@Override
|
||||||
public boolean isMatch(Method candidateMethod) {
|
public boolean isMatch(Method candidateMethod) {
|
||||||
return (candidateMethod.getName().equals("setBeanFactory") &&
|
return (candidateMethod.getName().equals("setBeanFactory") &&
|
||||||
candidateMethod.getParameterTypes().length == 1 &&
|
candidateMethod.getParameterCount() == 1 &&
|
||||||
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
|
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
|
||||||
BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass()));
|
BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||||
if (declaredEventType == null) {
|
if (declaredEventType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (this.method.getParameterTypes().length == 0) {
|
if (this.method.getParameterCount() == 0) {
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
}
|
}
|
||||||
if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.getRawClass())
|
if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.getRawClass())
|
||||||
|
@ -347,7 +347,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResolvableType> resolveDeclaredEventTypes() {
|
private List<ResolvableType> resolveDeclaredEventTypes() {
|
||||||
int count = this.method.getParameterTypes().length;
|
int count = this.method.getParameterCount();
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Maximum one parameter is allowed for event listener method: " + this.method);
|
"Maximum one parameter is allowed for event listener method: " + this.method);
|
||||||
|
|
|
@ -293,7 +293,7 @@ public class ScheduledAnnotationBeanPostProcessor implements DestructionAwareBea
|
||||||
|
|
||||||
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
|
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
|
||||||
try {
|
try {
|
||||||
Assert.isTrue(method.getParameterTypes().length == 0,
|
Assert.isTrue(method.getParameterCount() == 0,
|
||||||
"Only no-arg methods may be annotated with @Scheduled");
|
"Only no-arg methods may be annotated with @Scheduled");
|
||||||
|
|
||||||
Method invocableMethod = AopUtils.selectInvocableMethod(method, bean.getClass());
|
Method invocableMethod = AopUtils.selectInvocableMethod(method, bean.getClass());
|
||||||
|
|
|
@ -231,7 +231,7 @@ class TraceAfterReturningAdvice implements AfterReturningAdvice {
|
||||||
new StaticMethodMatcherPointcut() {
|
new StaticMethodMatcherPointcut() {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class<?> targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return method.getParameterTypes().length == 1 &&
|
return method.getParameterCount() == 1 &&
|
||||||
method.getParameterTypes()[0].equals(Integer.class);
|
method.getParameterTypes()[0].equals(Integer.class);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1217,7 +1217,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
|
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method m, Class<?> targetClass) {
|
public boolean matches(Method m, Class<?> targetClass) {
|
||||||
return m.getName().equals("overload") && m.getParameterTypes().length == 0;
|
return m.getName().equals("overload") && m.getParameterCount() == 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadInts) {
|
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadInts) {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method m, Class<?> targetClass) {
|
public boolean matches(Method m, Class<?> targetClass) {
|
||||||
return m.getName().equals("overload") && m.getParameterTypes().length == 1 &&
|
return m.getName().equals("overload") && m.getParameterCount() == 1 &&
|
||||||
m.getParameterTypes()[0].equals(int.class);
|
m.getParameterTypes()[0].equals(int.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1314,7 +1314,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
|
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method m, Class<?> targetClass) {
|
public boolean matches(Method m, Class<?> targetClass) {
|
||||||
return m.getParameterTypes().length == 0;
|
return m.getParameterCount() == 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
@ -1395,7 +1395,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
|
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method m, Class<?> targetClass) {
|
public boolean matches(Method m, Class<?> targetClass) {
|
||||||
return m.getParameterTypes().length == 0 || "exceptional".equals(m.getName());
|
return m.getParameterCount() == 0 || "exceptional".equals(m.getName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
@ -1694,7 +1694,7 @@ public abstract class AbstractAopProxyTests {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method m, Class<?> targetClass) {
|
public boolean matches(Method m, Class<?> targetClass) {
|
||||||
return m.getName().startsWith("set") &&
|
return m.getName().startsWith("set") &&
|
||||||
m.getParameterTypes().length == 1 &&
|
m.getParameterCount() == 1 &&
|
||||||
m.getParameterTypes()[0].equals(String.class);
|
m.getParameterTypes()[0].equals(String.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -93,7 +93,7 @@ public abstract class BridgeMethodResolver {
|
||||||
private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
|
private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
|
||||||
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
|
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
|
||||||
candidateMethod.getName().equals(bridgeMethod.getName()) &&
|
candidateMethod.getName().equals(bridgeMethod.getName()) &&
|
||||||
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
|
candidateMethod.getParameterCount() == bridgeMethod.getParameterCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1682,7 +1682,7 @@ public abstract class AnnotationUtils {
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
static boolean isAttributeMethod(Method method) {
|
static boolean isAttributeMethod(Method method) {
|
||||||
return (method != null && method.getParameterTypes().length == 0 && method.getReturnType() != void.class);
|
return (method != null && method.getParameterCount() == 0 && method.getReturnType() != void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1692,7 +1692,7 @@ public abstract class AnnotationUtils {
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
static boolean isAnnotationTypeMethod(Method method) {
|
static boolean isAnnotationTypeMethod(Method method) {
|
||||||
return (method != null && method.getName().equals("annotationType") && method.getParameterTypes().length == 0);
|
return (method != null && method.getName().equals("annotationType") && method.getParameterCount() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,7 +88,7 @@ final class IdToEntityConverter implements ConditionalGenericConverter {
|
||||||
}
|
}
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
if (Modifier.isStatic(method.getModifiers()) && method.getName().equals(finderMethod) &&
|
if (Modifier.isStatic(method.getModifiers()) && method.getName().equals(finderMethod) &&
|
||||||
method.getParameterTypes().length == 1 && method.getReturnType().equals(entityClass) &&
|
method.getParameterCount() == 1 && method.getReturnType().equals(entityClass) &&
|
||||||
(localOnlyFiltered || method.getDeclaringClass().equals(entityClass))) {
|
(localOnlyFiltered || method.getDeclaringClass().equals(entityClass))) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,7 +384,7 @@ public abstract class ReflectionUtils {
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
public static boolean isHashCodeMethod(Method method) {
|
public static boolean isHashCodeMethod(Method method) {
|
||||||
return (method != null && method.getName().equals("hashCode") && method.getParameterTypes().length == 0);
|
return (method != null && method.getName().equals("hashCode") && method.getParameterCount() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,7 +392,7 @@ public abstract class ReflectionUtils {
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
public static boolean isToStringMethod(Method method) {
|
public static boolean isToStringMethod(Method method) {
|
||||||
return (method != null && method.getName().equals("toString") && method.getParameterTypes().length == 0);
|
return (method != null && method.getName().equals("toString") && method.getParameterCount() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class BridgeMethodResolverTests {
|
||||||
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod);
|
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod);
|
||||||
assertFalse(bridgedMethod.isBridge());
|
assertFalse(bridgedMethod.isBridge());
|
||||||
assertEquals("add", bridgedMethod.getName());
|
assertEquals("add", bridgedMethod.getName());
|
||||||
assertEquals(1, bridgedMethod.getParameterTypes().length);
|
assertEquals(1, bridgedMethod.getParameterCount());
|
||||||
assertEquals(Date.class, bridgedMethod.getParameterTypes()[0]);
|
assertEquals(Date.class, bridgedMethod.getParameterTypes()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,9 +96,9 @@ public class FunctionReference extends SpelNodeImpl {
|
||||||
this.method = null;
|
this.method = null;
|
||||||
Object[] functionArgs = getArguments(state);
|
Object[] functionArgs = getArguments(state);
|
||||||
|
|
||||||
if (!method.isVarArgs() && method.getParameterTypes().length != functionArgs.length) {
|
if (!method.isVarArgs() && method.getParameterCount() != functionArgs.length) {
|
||||||
throw new SpelEvaluationException(SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION,
|
throw new SpelEvaluationException(SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION,
|
||||||
functionArgs.length, method.getParameterTypes().length);
|
functionArgs.length, method.getParameterCount());
|
||||||
}
|
}
|
||||||
// Only static methods can be called in this way
|
// Only static methods can be called in this way
|
||||||
if (!Modifier.isStatic(method.getModifiers())) {
|
if (!Modifier.isStatic(method.getModifiers())) {
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
|
||||||
Arrays.sort(ctors, new Comparator<Constructor<?>>() {
|
Arrays.sort(ctors, new Comparator<Constructor<?>>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Constructor<?> c1, Constructor<?> c2) {
|
public int compare(Constructor<?> c1, Constructor<?> c2) {
|
||||||
int c1pl = c1.getParameterTypes().length;
|
int c1pl = c1.getParameterCount();
|
||||||
int c2pl = c2.getParameterTypes().length;
|
int c2pl = c2.getParameterCount();
|
||||||
return (c1pl < c2pl ? -1 : (c1pl > c2pl ? 1 : 0));
|
return (c1pl < c2pl ? -1 : (c1pl > c2pl ? 1 : 0));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -123,8 +123,8 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||||
Collections.sort(methods, new Comparator<Method>() {
|
Collections.sort(methods, new Comparator<Method>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Method m1, Method m2) {
|
public int compare(Method m1, Method m2) {
|
||||||
int m1pl = m1.getParameterTypes().length;
|
int m1pl = m1.getParameterCount();
|
||||||
int m2pl = m2.getParameterTypes().length;
|
int m2pl = m2.getParameterCount();
|
||||||
// varargs methods go last
|
// varargs methods go last
|
||||||
if (m1pl == m2pl) {
|
if (m1pl == m2pl) {
|
||||||
if (!m1.isVarArgs() && m2.isVarArgs()) {
|
if (!m1.isVarArgs() && m2.isVarArgs()) {
|
||||||
|
|
|
@ -374,7 +374,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||||
for (String methodSuffix : methodSuffixes) {
|
for (String methodSuffix : methodSuffixes) {
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
if (method.getName().equals(prefix + methodSuffix) &&
|
if (method.getName().equals(prefix + methodSuffix) &&
|
||||||
method.getParameterTypes().length == numberOfParams &&
|
method.getParameterCount() == numberOfParams &&
|
||||||
(!mustBeStatic || Modifier.isStatic(method.getModifiers())) &&
|
(!mustBeStatic || Modifier.isStatic(method.getModifiers())) &&
|
||||||
(requiredReturnTypes.isEmpty() || requiredReturnTypes.contains(method.getReturnType()))) {
|
(requiredReturnTypes.isEmpty() || requiredReturnTypes.contains(method.getReturnType()))) {
|
||||||
return method;
|
return method;
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class HandlerMethod {
|
||||||
|
|
||||||
|
|
||||||
private MethodParameter[] initMethodParameters() {
|
private MethodParameter[] initMethodParameters() {
|
||||||
int count = this.bridgedMethod.getParameterTypes().length;
|
int count = this.bridgedMethod.getParameterCount();
|
||||||
MethodParameter[] result = new MethodParameter[count];
|
MethodParameter[] result = new MethodParameter[count];
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
result[i] = new HandlerMethodParameter(i);
|
result[i] = new HandlerMethodParameter(i);
|
||||||
|
@ -261,7 +261,7 @@ public class HandlerMethod {
|
||||||
* Return a short representation of this handler method for log message purposes.
|
* Return a short representation of this handler method for log message purposes.
|
||||||
*/
|
*/
|
||||||
public String getShortLogMessage() {
|
public String getShortLogMessage() {
|
||||||
int args = this.method.getParameterTypes().length;
|
int args = this.method.getParameterCount();
|
||||||
return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]";
|
return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class Reactor2TcpClient<P> implements TcpOperations<P> {
|
||||||
|
|
||||||
private static Method initEventLoopGroupMethod() {
|
private static Method initEventLoopGroupMethod() {
|
||||||
for (Method method : NettyClientSocketOptions.class.getMethods()) {
|
for (Method method : NettyClientSocketOptions.class.getMethods()) {
|
||||||
if (method.getName().equals("eventLoopGroup") && method.getParameterTypes().length == 1) {
|
if (method.getName().equals("eventLoopGroup") && method.getParameterCount() == 1) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,7 +437,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
||||||
if (Modifier.isStatic(method.getModifiers())) {
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
throw new IllegalStateException("Persistence annotations are not supported on static methods");
|
throw new IllegalStateException("Persistence annotations are not supported on static methods");
|
||||||
}
|
}
|
||||||
if (method.getParameterTypes().length != 1) {
|
if (method.getParameterCount() != 1) {
|
||||||
throw new IllegalStateException("Persistence annotation requires a single-arg method: " + method);
|
throw new IllegalStateException("Persistence annotation requires a single-arg method: " + method);
|
||||||
}
|
}
|
||||||
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
|
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class HandlerMethod {
|
||||||
|
|
||||||
|
|
||||||
private MethodParameter[] initMethodParameters() {
|
private MethodParameter[] initMethodParameters() {
|
||||||
int count = this.bridgedMethod.getParameterTypes().length;
|
int count = this.bridgedMethod.getParameterCount();
|
||||||
MethodParameter[] result = new MethodParameter[count];
|
MethodParameter[] result = new MethodParameter[count];
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
result[i] = new HandlerMethodParameter(i);
|
result[i] = new HandlerMethodParameter(i);
|
||||||
|
@ -262,7 +262,7 @@ public class HandlerMethod {
|
||||||
* @since 4.3
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public String getShortLogMessage() {
|
public String getShortLogMessage() {
|
||||||
int args = this.method.getParameterTypes().length;
|
int args = this.method.getParameterCount();
|
||||||
return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]";
|
return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,7 @@ public class MvcUriComponentsBuilder {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method) {
|
public boolean matches(Method method) {
|
||||||
String name = method.getName();
|
String name = method.getName();
|
||||||
int argLength = method.getParameterTypes().length;
|
int argLength = method.getParameterCount();
|
||||||
return (name.equals(methodName) && argLength == args.length);
|
return (name.equals(methodName) && argLength == args.length);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -465,7 +465,7 @@ public class MvcUriComponentsBuilder {
|
||||||
contributor = defaultUriComponentsContributor;
|
contributor = defaultUriComponentsContributor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int paramCount = method.getParameterTypes().length;
|
int paramCount = method.getParameterCount();
|
||||||
int argCount = args.length;
|
int argCount = args.length;
|
||||||
if (paramCount != argCount) {
|
if (paramCount != argCount) {
|
||||||
throw new IllegalArgumentException("Number of method parameters " + paramCount +
|
throw new IllegalArgumentException("Number of method parameters " + paramCount +
|
||||||
|
@ -760,7 +760,7 @@ public class MvcUriComponentsBuilder {
|
||||||
this.baseUrl = (baseUrl != null ? baseUrl : initBaseUrl());
|
this.baseUrl = (baseUrl != null ? baseUrl : initBaseUrl());
|
||||||
this.controllerType = controllerType;
|
this.controllerType = controllerType;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.argumentValues = new Object[method.getParameterTypes().length];
|
this.argumentValues = new Object[method.getParameterCount()];
|
||||||
for (int i = 0; i < this.argumentValues.length; i++) {
|
for (int i = 0; i < this.argumentValues.length; i++) {
|
||||||
this.argumentValues[i] = null;
|
this.argumentValues[i] = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
constructor = getEndpointConstructor();
|
constructor = getEndpointConstructor();
|
||||||
int parameterCount = constructor.getParameterTypes().length;
|
int parameterCount = constructor.getParameterCount();
|
||||||
constructorWithBooleanArgument = (parameterCount == 10);
|
constructorWithBooleanArgument = (parameterCount == 10);
|
||||||
if (!constructorWithBooleanArgument && parameterCount != 9) {
|
if (!constructorWithBooleanArgument && parameterCount != 9) {
|
||||||
throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments");
|
throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments");
|
||||||
|
|
Loading…
Reference in New Issue