Skip to content

Commit 56a8c1a

Browse files
committed
Register proxy hint for meta-annotations with attribute override
Closes gh-28767
1 parent e0190c1 commit 56a8c1a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

spring-core/src/main/java/org/springframework/aot/hint/support/RuntimeHintsUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public static void registerAnnotation(RuntimeHints hints, Class<?> annotationTyp
6060
hints.reflection().registerType(annotationType, ANNOTATION_HINT);
6161
Set<Class<?>> allAnnotations = new LinkedHashSet<>();
6262
collectAliasedAnnotations(new HashSet<>(), allAnnotations, annotationType);
63-
allAnnotations.forEach(annotation -> hints.reflection().registerType(annotation, ANNOTATION_HINT));
63+
allAnnotations.forEach(annotation -> {
64+
hints.reflection().registerType(annotation, ANNOTATION_HINT);
65+
hints.proxies().registerJdkProxy(annotation, SynthesizedAnnotation.class);
66+
});
6467
if (!allAnnotations.isEmpty()) {
6568
hints.proxies().registerJdkProxy(annotationType, SynthesizedAnnotation.class);
6669
}

spring-core/src/test/java/org/springframework/aot/hint/support/RuntimeHintsUtilsTests.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ void registerAnnotationTypeWithLocalUseOfAliasForRegistersProxy() {
6060
}
6161

6262
@Test
63-
void registerAnnotationTypeProxyRegistersJdkProxy() {
63+
void registerAnnotationTypeProxyRegistersJdkProxies() {
6464
RuntimeHintsUtils.registerAnnotation(this.hints, RetryInvoker.class);
6565
assertThat(this.hints.reflection().typeHints())
6666
.anySatisfy(annotationHint(RetryInvoker.class))
6767
.anySatisfy(annotationHint(SampleInvoker.class));
68-
assertThat(this.hints.proxies().jdkProxies()).singleElement()
69-
.satisfies(annotationProxy(RetryInvoker.class));
68+
assertThat(this.hints.proxies().jdkProxies())
69+
.anySatisfy(annotationProxy(RetryInvoker.class))
70+
.anySatisfy(annotationProxy(SampleInvoker.class))
71+
.hasSize(2);
7072
}
7173

7274
@Test
@@ -78,8 +80,11 @@ void registerAnnotationTypeWhereUsedAsAMetaAnnotationRegistersHierarchy() {
7880
.anySatisfy(annotationHint(RetryInvoker.class))
7981
.anySatisfy(annotationHint(SampleInvoker.class))
8082
.hasSize(3);
81-
assertThat(this.hints.proxies().jdkProxies()).singleElement()
82-
.satisfies(annotationProxy(RetryWithEnabledFlagInvoker.class));
83+
assertThat(this.hints.proxies().jdkProxies())
84+
.anySatisfy(annotationProxy(RetryWithEnabledFlagInvoker.class))
85+
.anySatisfy(annotationProxy(RetryInvoker.class))
86+
.anySatisfy(annotationProxy(SampleInvoker.class))
87+
.hasSize(3);
8388
}
8489

8590
private Consumer<TypeHint> annotationHint(Class<?> type) {

0 commit comments

Comments
 (0)