Skip to content

Annotations on generic interface methods not found by AnnotationUtils [SPR-16060] #20609

Closed
@spring-projects-issues

Description

@spring-projects-issues

Christopher Rued opened SPR-16060 and commented

When scanning for annotations on a class that implements a generic interface where the generic
type is specified in the implementing class, annotation scanning would fail to identify annotations
from the interface since the parameter types do not match.

For example, given an interface:

public interface Foo<T> {
    @Order
    void foo(T t);
}

and a class:

public class StringFoo implements Foo<String> {
    public void foo(String s) { ... }
}

when scanning StringFoo.foo for annotations, no annotations were identified.

This commit changes annotation scanning so that when scanning for annotations, the parameters are
compared for assignability (using Class.isAssignableFrom()) rather than requiring exact matches.

Original Issue: SEC-3081


Issue Links:

Referenced from: pull request #1553, and commits 23d4862, b72594d

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions