SPR-16060 - Enhance AnnotationUtils to find annotations on generic interfaces#1553
Conversation
|
@christor Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@christor Thank you for signing the Contributor License Agreement! |
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.
Issue: SEC-3081
Correct formatting
1221870 to
b121c50
Compare
|
Hi @christor, Since your proposed change is in the core Spring Framework and not in Spring Security, please create a JIRA issue for the Cheers, Sam |
|
Done, @sbrannen - https://jira.spring.io/browse/SPR-16060 Is there anything more that needs to be done? |
|
Just following up to see if there's anything more needed. |
|
Thanks for raising the JIRA issue! AFAIK, @jhoeller is going to look into this. |
|
Just checking in again, since it's been a couple of months. Does this change look reasonable, @jhoeller? |
|
Looks like some other commit has caused a conflict. If/when you want to merge this I can help resolve those. |
|
SPR-16060 is scheduled for 5.1 RC1. So that means it's on the radar, but I'll let @jhoeller comment on an ETA in 5.1 snapshots. |
|
Finally resolved in master now, and scheduled for a backport to 5.0.8. The implementation is somewhat different since it goes through generics resolution for the type variable instead of an assignability check. Thanks for the pull request, in any case! |
|
Great news, thanks! I guess this is the relevant change? d78e27f#diff-44945edabd4176dfd3966252ff4a589e |
|
It's a follow-up to that which is actually pushed to master now: 23d4862 |
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:
and a class:
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.
Issue: SEC-3081