From a8380199351856363db812f391322ff70ec41c16 Mon Sep 17 00:00:00 2001 From: John Flores Date: Wed, 18 Dec 2013 09:41:04 -0500 Subject: [PATCH] Update MvcUriComponentsBuilder.java Method with following signature "public static UriComponentsBuilder fromMethodName(Class controllerType,String methodName, Object... argumentValues)" makes use of the getParameterCount() method found in the java.lang.reflect.Method class. This is specific to Java 8 and will cause projects using prior versions of Java to throw an exception (java.lang.NoSuchMethodError: java.lang.reflect.Method.getParameterCount()). My proposed modification is to change it to getParameterTypes().length to get the total number of parameters. --- .../servlet/mvc/method/annotation/MvcUriComponentsBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index 26a940a87cdf..29b31741f222 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -118,7 +118,7 @@ public static UriComponentsBuilder fromMethodName(Class controllerType, Method match = null; for (Method method : controllerType.getDeclaredMethods()) { - if ((method.getParameterCount() == argumentValues.length) && method.getName().equals(methodName)) { + if ((method.getParameterTypes().length == argumentValues.length) && method.getName().equals(methodName)) { if (match != null) { throw new IllegalStateException("Found two methods named '" + methodName + "' having " + argumentValues + " arguments, controller "