-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regressionA bug that is also a regression
Milestone
Description
Related to #22586.
Merged annotations used as meta annotations seems to no longer resolve attributes.
Simplified test below passes for 5.1.5.RELEASE and fails for current 5.2.0.BUILD-SNAPSHOT.
Result for 5.1.5: BaseAnnotation(name=custom-name, val1=true)
Result for 5.2.0: BaseAnnotation(name=base-name, val1=false)
@Test
public void resolveWithCustomAnnotationUsingComposedAnnotationAsMeta() {
java.lang.reflect.Field field = ReflectionUtils.findField(Sample.class,
it -> it.getName().equals("value"));
BaseAnnotation annotation = AnnotatedElementUtils.findMergedAnnotation(field, BaseAnnotation.class);
assertThat(annotation.name()).isEqualTo("custom-name");
assertThat(annotation.val1()).isTrue();
}
static class Sample {
@CustomAnnotationWithComposedMeta
String value;
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.ANNOTATION_TYPE, ElementType.FIELD })
@interface BaseAnnotation {
String name() default "base-name";
boolean val1() default false;
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.ANNOTATION_TYPE, ElementType.FIELD })
@BaseAnnotation
@interface ComposedAnnotation {
@AliasFor(annotation = BaseAnnotation.class, attribute = "name")
String customName() default "composed-name";
@AliasFor(annotation = BaseAnnotation.class, attribute = "val1")
boolean foo() default false;
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
@ComposedAnnotation(customName = "custom-name", foo = true)
@interface CustomAnnotationWithComposedMeta {}Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regressionA bug that is also a regression