Skip to content

Provide a mechanism for composed annotations to signal that they want to override attributes [SPR-13448] #18028

Closed
@spring-projects-issues

Description

@spring-projects-issues

Dave Syer opened SPR-13448 and commented

AnnotatedElementUtils is now available for processing merged (overridden) attributes from meta-annotated custom annotations, but Spring doesn't use it uniformly (because of performance concerns). The one that bit me was an ImportBeanDefinitionRegistrar where the annotation was a custom one and the AnnotationMetadata that is passed in does not contain the overridden/inherited values.

The reason, it turns out, is that StandardAnnotationMetadata, while it uses AnnotatedElementUtils, explicitly chooses not to get the overridden attributes by invoking getAllAnnotationAttributes() instead of getMergedAnnotationAttributes() (and this is all that is directly available to the ImportBeanDefinitionRegistrar).

Maybe there's a way to address the performance concerns and use the deeper AnnotatedElementUtils.getMergedAnnotationAttributes() utility method(s) only if the user signals that the annotation needs to be processed this way -- for example, by introducing an annotation such as @Mergeable (or an explicit @AliasFor on the attribute).

See also: #18020


Affects: 4.2 GA

Issue Links:

0 votes, 6 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions