Skip to content

AnnotatedElementUtils.findMergedRepeatableAnnotations does not fetch results when other attributes exist in container annotation #29685

Closed
@ForteScarlet

Description

@ForteScarlet

Affects: v5.3.24, v6.0.2


I have the following code:

public class Main2 {

    @Retention(RetentionPolicy.RUNTIME)
    @Repeatable(Anno1Container.class)
    public @interface Anno1 {
        String value();
    }

    @Retention(RetentionPolicy.RUNTIME)
    public @interface Anno1Container {
        Anno1[] value();
    }

    @Retention(RetentionPolicy.RUNTIME)
    @Repeatable(Anno2Container.class)
    public @interface Anno2 {
        String value();
    }

    @Retention(RetentionPolicy.RUNTIME)
    public @interface Anno2Container {
        Anno2[] value();
        int number() default 2; // other attributes
    }

    public static void main(String[] args) throws NoSuchMethodException {
        Method method = Main2.class.getMethod("a");
        System.out.println(AnnotatedElementUtils.findMergedRepeatableAnnotations(method, Anno1.class));
        // [@example.Main2$Anno1("A1_1"), @example.Main2$Anno1("A1_2")]
        System.out.println(AnnotatedElementUtils.findMergedRepeatableAnnotations(method, Anno2.class));
        // []
    }


    @Anno1("A1_1")
    @Anno1("A1_2")
    @Anno2("A2_1")
    @Anno2("A2_2")
    public void a() {
    }
}

AnnotatedElementUtils.findMergedRepeatableAnnotations cannot get results when other attributes ( Anno2Container.number ) exist for the container annotation ( Anno2Container )

In v5.3.23, AnnotatedElementUtils.findMergedRepeatableAnnotations can successfully obtain the above two annotations

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions