Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favor more locally declared composed annotations over inherited annotations [SPR-11598] #16221

Closed
1 of 3 tasks
spring-projects-issues opened this issue Mar 25, 2014 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 25, 2014

Sam Brannen opened SPR-11598 and commented

Background

This issue picks up where #16100 left off.


Status Quo

The implementations of AnnotatedElementUtils and (potentially) Spring's ASM-based annotation processing currently favor inherited annotations and inherited composed annotations over composed annotations that are declared closer to the starting class passed to getAnnotationAttributes(), getAllAnnotationAttributes(), isAnnotated(), etc.

See the examples and related discussion in #16100 for details.


Deliverables

  1. Determine which use cases require special treatment with regard to annotation inheritance.
    • Known cases: @Profile and @Conditional
  2. Reinstate the changes originally introduced in AnnotatedElementUtils for Favor more locally declared composed annotations over inherited annotations in AnnotationUtils [SPR-11475] #16100 (i.e., set the searchClassHierarchy to true for all invocations of the internal process() method).
  3. Introduce special handling for the known special cases determined in deliverable Spring core JMS pom.xml #1, in order to ensure proper backwards compatibility.

Affects: 4.0 GA

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 25, 2014

Sam Brannen commented

This is related to #15466 and #16136.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 13, 2015

Sam Brannen commented

Much of the functionality originally intended to be implemented in conjunction with this JIRA issue has been superseded by the recent introduction of the AnnotatedElementUtils.findAnnotationAttributes() methods.

See comments in #17335 for details.

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Resolved as described in GitHub commit ebed52c:

Favor local, composed annotations in AnnotatedElementUtils

This commit updates the "get semantics" search algorithm used in AnnotatedElementUtils so that locally declared composed annotations are favored over inherited annotations.

Specifically, the internal searchWithGetSemantics() method now searches locally declared annotations before searching inherited annotations.

All TODOs in AnnotatedElementUtilsTests have been completed, and all ignored tests have been reinstated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants