Skip to content

Search for annotations on enclosing classes with MergedAnnotations API #23378

Closed
@sbrannen

Description

@sbrannen

Overview

The MergedAnnotations API currently supports four search strategies via the SearchStrategy enum; however, none of those support searches on enclosing classes.

In a typical Spring application, it is not necessary to search for an annotation on an enclosing class; however, in order to provide first-class support for Spring configuration in @Nested test class hierarchies in JUnit Jupiter, we need a mechanism for searching on enclosing classes as well (see gh-19930). There may be other use cases as well.

Proposal

Introduce a new SearchStrategy for the MergedAnnotations API that supports searching for annotations on "enclosing classes". This would likely be in addition to the semantics currently associated with the EXHAUSTIVE enum.

In one way, this would be EXHAUSTIVE++, but I don't know that we want to change the current semantics of EXHAUSTIVE. So, perhaps something like EXHAUSTIVE_PLUS_ENCLOSING_CLASSES would be more suitable.

Providing such support in MergedAnnotations could alleviate some of the challenges of providing custom workarounds as can be seen in the current work for gh-19930.

Metadata

Metadata

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions