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
spring-issuemaster opened this issue Mar 25, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

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 #16100 (i.e., set the searchClassHierarchy to true for all invocations of the internal process() method).
    • Search for #16221 in source code for TODOs.
  3. Introduce special handling for the known special cases determined in deliverable #1, in order to ensure proper backwards compatibility.

Affects: 4.0 GA

Issue Links:

  • #16100 Favor more locally declared composed annotations over inherited annotations in AnnotationUtils ("depends on")
  • #17261 @TestExecutionListeners is not fully supported as a meta-annotation ("is duplicated by")
  • #15466 @Conditional on superclass is ignored
  • #16136 Introduce a comprehensive programming model for meta-annotation support
  • #18321 ActiveProfiles not included when using a custom annotation.
  • #16219 Annotations on superclasses are detected by StandardAnnotationMetadata
  • #17335 AnnotatedElementUtils fails to find annotations on abstract, bridge, or interface methods
  • #17346 Favor more locally declared composed annotations over inherited annotations in the TestContext framework
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 25, 2014

Sam Brannen commented

This is related to #15466 and #16136.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 13, 2015

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
You can’t perform that action at this time.