d6768ccc1852f4720781d490e13529e0283d9d63 seems to have introduced a regression when resolving merged annotation values.
The tests below pass for 6.0.0-M4
but fail with recent snapshot
build.
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.ANNOTATION_TYPE })
@interface RootAnnotation {
String value() default "";
boolean boolVal() default false;
}
@RootAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.ANNOTATION_TYPE })
@interface CustomMetaAnnotation {
@AliasFor(annotation = RootAnnotation.class, attribute = "boolVal")
boolean enabled() default true;
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
@CustomMetaAnnotation
@interface CustomAnnotationWith2TimesMeta {
}
class DomainType {
@CustomMetaAnnotation
Object metaAnnotated;
@CustomAnnotationWith2TimesMeta
Object meta2timesAnnotated;
}
@Test
public void reproducer() {
java.lang.reflect.Field metaAnnotated = ReflectionUtils.findField(DomainType.class, "metaAnnotated");
RootAnnotation mergedAnnotation1 = AnnotatedElementUtils.findMergedAnnotation(metaAnnotated, RootAnnotation.class);
assertThat(mergedAnnotation1.boolVal()).isTrue();
java.lang.reflect.Field meta2timesAnnotated = ReflectionUtils.findField(DomainType.class, "meta2timesAnnotated");
RootAnnotation mergedAnnotation2 = AnnotatedElementUtils.findMergedAnnotation(meta2timesAnnotated, RootAnnotation.class);
assertThat(mergedAnnotation2.boolVal()).isTrue();
}
Comment From: sbrannen
Thanks for raising the issue!
This regression has been fixed in 5.3.x
and main
(and hopefully does not inadvertently introduce another regression).
Please let us know if you experience any issues with the upcoming snapshots.
Comment From: izeye
It's a regression that's not shipped yet, so considering that release notes are generated based on labels, this might be better to be tagged as type: task
. IIRC I saw a similar situation that's been handled that way in the Spring Boot repo.
Comment From: sbrannen
Good catch, @izeye!
I'll change the label. 👍