Skip to content

Allow a single element to override an array attribute in a meta-annotation [SPR-13972] #18544

Closed
@spring-projects-issues

Description

@spring-projects-issues

Juergen Hoeller opened SPR-13972 and commented

Overview

In 4.2, aliased annotation attribute types must match exactly. However, it is rather common in Java for single element values to be specified for an array attribute: Reflecting this in custom annotation design, it would be nice for a custom annotation to be able to declare a single element only, aliasing a meta-annotation attribute which was originally declared as an array, e.g. in a custom @PropertySource variant with a single String value.

Deliverables

  1. Allow for a single element overriding an array attribute in a meta-annotation by convention.
    • See findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaConvention() in AnnotatedElementUtilsTests.
  2. Allow for a single element overriding an array attribute in a meta-annotation using @AliasFor.
    • See findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaAliasFor() in AnnotatedElementUtilsTests.
  3. Ensure that the aforementioned overrides are supported in AnnotationAttributes (which is assumed to already be the case but should be verified).
    • See singleElementToSingleElementArrayConversionSupport() in AnnotationAttributesTests.
  4. Ensure that the aforementioned overrides are supported in synthesized annotations.
    • See various getMergedAnnotation*WithSingleElementOverridingAnArrayVia*() and findMergedAnnotationWithSingleElementOverridingAnArrayVia*() methods in AnnotatedElementUtilsTests.

Affects: 4.2.4

Issue Links:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions