Affected version: Spring core 5.3.23


@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {

}

public class Parent<T> {
    void set(T t) {
    }
}
public class Child extends Parent<String> {

    @Override
    @MyAnnotation
    void set(String str) {
    }


}
  MergedAnnotation<MyAnnotation> annotation =
                MergedAnnotations.from(methods[0], MergedAnnotations.SearchStrategy.DIRECT).get(MyAnnotation.class);
        System.out.println(annotation.isPresent());
        System.out.println(annotation.getSource());

print:

false
null

Comment From: JianByte

The above example will eventually execute the following method, which always returns null in this case, is this correct?

org.springframework.core.annotation.AnnotationsScanner

    @Nullable
private static  R processMethodAnnotations(C context, int aggregateIndex, Method source,
      AnnotationsProcessor processor) {
   Annotation[] annotations = getDeclaredAnnotations(source, false);

   R result = processor.doWithAnnotations(context, aggregateIndex, source, annotations);
   if (result != null) {
      return result;
   }
  
   Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(source);
   if (bridgedMethod != source) {
      Annotation[] bridgedAnnotations = getDeclaredAnnotations(bridgedMethod, true);
      for (int i = 0; i < bridgedAnnotations.length; i++) {
         if (ObjectUtils.containsElement(annotations, bridgedAnnotations[i])) {
            bridgedAnnotations[i] = null;
         }
      }
      return processor.doWithAnnotations(context, aggregateIndex, source, bridgedAnnotations);
   }
   return null;
}

Comment From: sbrannen

MergedAnnotation<MyAnnotation> annotation =
                MergedAnnotations.from(methods[0], MergedAnnotations.SearchStrategy.DIRECT).get(MyAnnotation.class);

Please provide a full code listing showing how you retrieved methods[0].

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: JianByte

Sorry, this is my mistake, I mistakenly used another annotation with the same name.