fixed support for -1 parameterIndex to access the method return type

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@922 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Andy Clement 2009-04-03 23:37:59 +00:00
parent c95d13a316
commit 8a4772028c
1 changed files with 6 additions and 1 deletions

View File

@ -37,6 +37,7 @@ import org.springframework.util.Assert;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Rob Harrop * @author Rob Harrop
* @author Andy Clement
* @since 2.0 * @since 2.0
* @see GenericCollectionTypeResolver * @see GenericCollectionTypeResolver
*/ */
@ -176,9 +177,13 @@ public class MethodParameter {
*/ */
public Class getParameterType() { public Class getParameterType() {
if (this.parameterType == null) { if (this.parameterType == null) {
this.parameterType = (this.method != null ? if (parameterIndex < 0) {
this.parameterType = (this.method !=null ? this.method.getReturnType():null);
} else {
this.parameterType = (this.method != null ?
this.method.getParameterTypes()[this.parameterIndex] : this.method.getParameterTypes()[this.parameterIndex] :
this.constructor.getParameterTypes()[this.parameterIndex]); this.constructor.getParameterTypes()[this.parameterIndex]);
}
} }
return this.parameterType; return this.parameterType;
} }