@@ -358,17 +358,20 @@ void setParameterType(Class<?> parameterType) {
358358 * @return the parameter type (never {@code null})
359359 */
360360 public Class <?> getParameterType () {
361- if (this .parameterType == null ) {
361+ Class <?> paramType = this .parameterType ;
362+ if (paramType == null ) {
362363 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 );
364366 }
365367 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 ]);
369371 }
372+ this .parameterType = paramType ;
370373 }
371- return this . parameterType ;
374+ return paramType ;
372375 }
373376
374377 /**
@@ -377,17 +380,20 @@ public Class<?> getParameterType() {
377380 * @since 3.0
378381 */
379382 public Type getGenericParameterType () {
380- if (this .genericParameterType == null ) {
383+ Type paramType = this .genericParameterType ;
384+ if (paramType == null ) {
381385 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 );
383388 }
384389 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 ]);
388393 }
394+ this .genericParameterType = paramType ;
389395 }
390- return this . genericParameterType ;
396+ return paramType ;
391397 }
392398
393399 /**
0 commit comments