Java 8 getParameterCount() instead of getParameterTypes().length

Issue: SPR-13188
This commit is contained in:
Juergen Hoeller 2016-07-07 01:04:24 +02:00
parent 39e3f2ebf6
commit a1f5fb53db
38 changed files with 68 additions and 68 deletions

View File

@ -260,7 +260,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
}
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...
Class<?> firstArgType = this.aspectJAdviceMethod.getParameterTypes()[0];
if (firstArgType == JoinPoint.class ||
@ -463,7 +463,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
private void bindExplicitArguments(int numArgumentsLeftToBind) {
this.argumentBindings = new HashMap<>();
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterTypes().length;
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterCount();
if (this.argumentNames.length != numExpectedArgumentNames) {
throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames +
" 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 {
Object[] actualArgs = args;
if (this.aspectJAdviceMethod.getParameterTypes().length == 0) {
if (this.aspectJAdviceMethod.getParameterCount() == 0) {
actualArgs = null;
}
try {

View File

@ -305,7 +305,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
@Override
public String[] getParameterNames(Method method) {
if (method.getParameterTypes().length == 0) {
if (method.getParameterCount() == 0) {
return new String[0];
}
AspectJAnnotation<?> annotation = findAspectJAnnotationOnMethod(method);

View File

@ -77,11 +77,11 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
Method[] methods = throwsAdvice.getClass().getMethods();
for (Method method : methods) {
if (method.getName().equals(AFTER_THROWING) &&
(method.getParameterTypes().length == 1 || method.getParameterTypes().length == 4) &&
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length - 1])
(method.getParameterCount() == 1 || method.getParameterCount() == 4) &&
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterCount() - 1])
) {
// 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()) {
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 {
Object[] handlerArgs;
if (method.getParameterTypes().length == 1) {
if (method.getParameterCount() == 1) {
handlerArgs = new Object[] { ex };
}
else {

View File

@ -168,7 +168,7 @@ public abstract class AopUtils {
*/
public static boolean isFinalizeMethod(Method method) {
return (method != null && method.getName().equals("finalize") &&
method.getParameterTypes().length == 0);
method.getParameterCount() == 0);
}
/**

View File

@ -99,7 +99,7 @@ public abstract class Pointcuts {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return (method.getName().startsWith("set") &&
method.getParameterTypes().length == 1 &&
method.getParameterCount() == 1 &&
method.getReturnType() == Void.TYPE);
}
@ -120,7 +120,7 @@ public abstract class Pointcuts {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return (method.getName().startsWith("get") &&
method.getParameterTypes().length == 0);
method.getParameterCount() == 0);
}
private Object readResolve() {

View File

@ -270,7 +270,7 @@ public class AspectJAdviceParameterNameDiscovererTests {
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",
m.getParameterTypes().length, parameterNames.length);
m.getParameterCount(), parameterNames.length);
AspectJAdviceParameterNameDiscoverer discoverer = new AspectJAdviceParameterNameDiscoverer(pointcut);
discoverer.setRaiseExceptions(true);

View File

@ -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;

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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));
}
});

View File

@ -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));
}
}

View File

@ -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++) {

View File

@ -139,7 +139,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
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);
result.add(detail);
}

View File

@ -396,7 +396,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
if (Modifier.isStatic(method.getModifiers())) {
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);
}
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
@ -406,7 +406,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
if (Modifier.isStatic(method.getModifiers())) {
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);
}
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);

View File

@ -284,7 +284,7 @@ class ConfigurationClassEnhancer {
@Override
public boolean isMatch(Method candidateMethod) {
return (candidateMethod.getName().equals("setBeanFactory") &&
candidateMethod.getParameterTypes().length == 1 &&
candidateMethod.getParameterCount() == 1 &&
BeanFactory.class == candidateMethod.getParameterTypes()[0] &&
BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass()));
}

View File

@ -161,7 +161,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
if (declaredEventType == null) {
return null;
}
if (this.method.getParameterTypes().length == 0) {
if (this.method.getParameterCount() == 0) {
return new Object[0];
}
if (!ApplicationEvent.class.isAssignableFrom(declaredEventType.getRawClass())
@ -347,7 +347,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
}
private List<ResolvableType> resolveDeclaredEventTypes() {
int count = this.method.getParameterTypes().length;
int count = this.method.getParameterCount();
if (count > 1) {
throw new IllegalStateException(
"Maximum one parameter is allowed for event listener method: " + this.method);

View File

@ -293,7 +293,7 @@ public class ScheduledAnnotationBeanPostProcessor implements DestructionAwareBea
protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
try {
Assert.isTrue(method.getParameterTypes().length == 0,
Assert.isTrue(method.getParameterCount() == 0,
"Only no-arg methods may be annotated with @Scheduled");
Method invocableMethod = AopUtils.selectInvocableMethod(method, bean.getClass());

View File

@ -231,7 +231,7 @@ class TraceAfterReturningAdvice implements AfterReturningAdvice {
new StaticMethodMatcherPointcut() {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return method.getParameterTypes().length == 1 &&
return method.getParameterCount() == 1 &&
method.getParameterTypes()[0].equals(Integer.class);
}
},

View File

@ -1217,7 +1217,7 @@ public abstract class AbstractAopProxyTests {
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
@Override
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) {
@Override
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);
}
});
@ -1314,7 +1314,7 @@ public abstract class AbstractAopProxyTests {
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getParameterTypes().length == 0;
return m.getParameterCount() == 0;
}
};
TestBean target = new TestBean();
@ -1395,7 +1395,7 @@ public abstract class AbstractAopProxyTests {
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
@Override
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();
@ -1694,7 +1694,7 @@ public abstract class AbstractAopProxyTests {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getName().startsWith("set") &&
m.getParameterTypes().length == 1 &&
m.getParameterCount() == 1 &&
m.getParameterTypes()[0].equals(String.class);
}
});

View File

@ -93,7 +93,7 @@ public abstract class BridgeMethodResolver {
private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
candidateMethod.getName().equals(bridgeMethod.getName()) &&
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
candidateMethod.getParameterCount() == bridgeMethod.getParameterCount());
}
/**

View File

@ -1682,7 +1682,7 @@ public abstract class AnnotationUtils {
* @since 4.2
*/
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
*/
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);
}
/**

View File

@ -88,7 +88,7 @@ final class IdToEntityConverter implements ConditionalGenericConverter {
}
for (Method method : methods) {
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))) {
return method;
}

View File

@ -384,7 +384,7 @@ public abstract class ReflectionUtils {
* @see java.lang.Object#hashCode()
*/
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()
*/
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);
}
/**

View File

@ -95,7 +95,7 @@ public class BridgeMethodResolverTests {
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod);
assertFalse(bridgedMethod.isBridge());
assertEquals("add", bridgedMethod.getName());
assertEquals(1, bridgedMethod.getParameterTypes().length);
assertEquals(1, bridgedMethod.getParameterCount());
assertEquals(Date.class, bridgedMethod.getParameterTypes()[0]);
}

View File

@ -96,9 +96,9 @@ public class FunctionReference extends SpelNodeImpl {
this.method = null;
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,
functionArgs.length, method.getParameterTypes().length);
functionArgs.length, method.getParameterCount());
}
// Only static methods can be called in this way
if (!Modifier.isStatic(method.getModifiers())) {

View File

@ -61,8 +61,8 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
Arrays.sort(ctors, new Comparator<Constructor<?>>() {
@Override
public int compare(Constructor<?> c1, Constructor<?> c2) {
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));
}
});

View File

@ -123,8 +123,8 @@ public class ReflectiveMethodResolver implements MethodResolver {
Collections.sort(methods, new Comparator<Method>() {
@Override
public int compare(Method m1, Method m2) {
int m1pl = m1.getParameterTypes().length;
int m2pl = m2.getParameterTypes().length;
int m1pl = m1.getParameterCount();
int m2pl = m2.getParameterCount();
// varargs methods go last
if (m1pl == m2pl) {
if (!m1.isVarArgs() && m2.isVarArgs()) {

View File

@ -374,7 +374,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
for (String methodSuffix : methodSuffixes) {
for (Method method : methods) {
if (method.getName().equals(prefix + methodSuffix) &&
method.getParameterTypes().length == numberOfParams &&
method.getParameterCount() == numberOfParams &&
(!mustBeStatic || Modifier.isStatic(method.getModifiers())) &&
(requiredReturnTypes.isEmpty() || requiredReturnTypes.contains(method.getReturnType()))) {
return method;

View File

@ -145,7 +145,7 @@ public class HandlerMethod {
private MethodParameter[] initMethodParameters() {
int count = this.bridgedMethod.getParameterTypes().length;
int count = this.bridgedMethod.getParameterCount();
MethodParameter[] result = new MethodParameter[count];
for (int i = 0; i < count; 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.
*/
public String getShortLogMessage() {
int args = this.method.getParameterTypes().length;
int args = this.method.getParameterCount();
return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]";
}

View File

@ -289,7 +289,7 @@ public class Reactor2TcpClient<P> implements TcpOperations<P> {
private static Method initEventLoopGroupMethod() {
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;
}
}

View File

@ -437,7 +437,7 @@ public class PersistenceAnnotationBeanPostProcessor
if (Modifier.isStatic(method.getModifiers())) {
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);
}
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);

View File

@ -146,7 +146,7 @@ public class HandlerMethod {
private MethodParameter[] initMethodParameters() {
int count = this.bridgedMethod.getParameterTypes().length;
int count = this.bridgedMethod.getParameterCount();
MethodParameter[] result = new MethodParameter[count];
for (int i = 0; i < count; i++) {
result[i] = new HandlerMethodParameter(i);
@ -262,7 +262,7 @@ public class HandlerMethod {
* @since 4.3
*/
public String getShortLogMessage() {
int args = this.method.getParameterTypes().length;
int args = this.method.getParameterCount();
return getBeanType().getName() + "#" + this.method.getName() + "[" + args + " args]";
}

View File

@ -439,7 +439,7 @@ public class MvcUriComponentsBuilder {
@Override
public boolean matches(Method method) {
String name = method.getName();
int argLength = method.getParameterTypes().length;
int argLength = method.getParameterCount();
return (name.equals(methodName) && argLength == args.length);
}
};
@ -465,7 +465,7 @@ public class MvcUriComponentsBuilder {
contributor = defaultUriComponentsContributor;
}
int paramCount = method.getParameterTypes().length;
int paramCount = method.getParameterCount();
int argCount = args.length;
if (paramCount != argCount) {
throw new IllegalArgumentException("Number of method parameters " + paramCount +
@ -760,7 +760,7 @@ public class MvcUriComponentsBuilder {
this.baseUrl = (baseUrl != null ? baseUrl : initBaseUrl());
this.controllerType = controllerType;
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++) {
this.argumentValues[i] = null;
}

View File

@ -80,7 +80,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
static {
try {
constructor = getEndpointConstructor();
int parameterCount = constructor.getParameterTypes().length;
int parameterCount = constructor.getParameterCount();
constructorWithBooleanArgument = (parameterCount == 10);
if (!constructorWithBooleanArgument && parameterCount != 9) {
throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments");