26
26
import java .util .HashMap ;
27
27
import java .util .Map ;
28
28
29
+ import org .springframework .core .annotation .AnnotationUtils ;
29
30
import org .springframework .util .Assert ;
30
31
31
32
/**
36
37
* @author Juergen Hoeller
37
38
* @author Rob Harrop
38
39
* @author Andy Clement
40
+ * @author Sam Brannen
39
41
* @since 2.0
40
42
* @see GenericCollectionTypeResolver
41
43
*/
@@ -386,7 +388,7 @@ public Type getNestedGenericParameterType() {
386
388
* Return the annotations associated with the target method/constructor itself.
387
389
*/
388
390
public Annotation [] getMethodAnnotations () {
389
- return getAnnotatedElement ().getAnnotations ();
391
+ return AnnotationUtils . synthesizeAnnotationArray ( getAnnotatedElement ().getAnnotations (), getAnnotatedElement () );
390
392
}
391
393
392
394
/**
@@ -395,7 +397,8 @@ public Annotation[] getMethodAnnotations() {
395
397
* @return the annotation object, or {@code null} if not found
396
398
*/
397
399
public <T extends Annotation > T getMethodAnnotation (Class <T > annotationType ) {
398
- return getAnnotatedElement ().getAnnotation (annotationType );
400
+ AnnotatedElement element = getAnnotatedElement ();
401
+ return AnnotationUtils .synthesizeAnnotation (element .getAnnotation (annotationType ), element );
399
402
}
400
403
401
404
/**
@@ -406,7 +409,8 @@ public Annotation[] getParameterAnnotations() {
406
409
Annotation [][] annotationArray = (this .method != null ?
407
410
this .method .getParameterAnnotations () : this .constructor .getParameterAnnotations ());
408
411
if (this .parameterIndex >= 0 && this .parameterIndex < annotationArray .length ) {
409
- this .parameterAnnotations = annotationArray [this .parameterIndex ];
412
+ this .parameterAnnotations = AnnotationUtils .synthesizeAnnotationArray (
413
+ annotationArray [this .parameterIndex ], getAnnotatedElement ());
410
414
}
411
415
else {
412
416
this .parameterAnnotations = new Annotation [0 ];
0 commit comments