@@ -358,17 +358,20 @@ void setParameterType(Class<?> parameterType) {
358
358
* @return the parameter type (never {@code null})
359
359
*/
360
360
public Class <?> getParameterType () {
361
- if (this .parameterType == null ) {
361
+ Class <?> paramType = this .parameterType ;
362
+ if (paramType == null ) {
362
363
if (this .parameterIndex < 0 ) {
363
- this .parameterType = (this .method != null ? this .method .getReturnType () : null );
364
+ Method method = getMethod ();
365
+ paramType = (method != null ? method .getReturnType () : void .class );
364
366
}
365
367
else {
366
- this . parameterType = (this .method != null ?
367
- this .method .getParameterTypes ()[this .parameterIndex ] :
368
- this .constructor .getParameterTypes ()[this .parameterIndex ]);
368
+ paramType = (this .method != null ?
369
+ this .method .getParameterTypes ()[this .parameterIndex ] :
370
+ this .constructor .getParameterTypes ()[this .parameterIndex ]);
369
371
}
372
+ this .parameterType = paramType ;
370
373
}
371
- return this . parameterType ;
374
+ return paramType ;
372
375
}
373
376
374
377
/**
@@ -377,17 +380,20 @@ public Class<?> getParameterType() {
377
380
* @since 3.0
378
381
*/
379
382
public Type getGenericParameterType () {
380
- if (this .genericParameterType == null ) {
383
+ Type paramType = this .genericParameterType ;
384
+ if (paramType == null ) {
381
385
if (this .parameterIndex < 0 ) {
382
- this .genericParameterType = (this .method != null ? this .method .getGenericReturnType () : null );
386
+ Method method = getMethod ();
387
+ paramType = (method != null ? method .getGenericReturnType () : void .class );
383
388
}
384
389
else {
385
- this . genericParameterType = (this .method != null ?
386
- this .method .getGenericParameterTypes ()[this .parameterIndex ] :
387
- this .constructor .getGenericParameterTypes ()[this .parameterIndex ]);
390
+ paramType = (this .method != null ?
391
+ this .method .getGenericParameterTypes ()[this .parameterIndex ] :
392
+ this .constructor .getGenericParameterTypes ()[this .parameterIndex ]);
388
393
}
394
+ this .genericParameterType = paramType ;
389
395
}
390
- return this . genericParameterType ;
396
+ return paramType ;
391
397
}
392
398
393
399
/**
0 commit comments