Skip to content

Commit

Permalink
Register proxy hint for meta-annotations with attribute override
Browse files Browse the repository at this point in the history
Closes gh-28767
  • Loading branch information
snicoll committed Jul 29, 2022
1 parent e0190c1 commit 56a8c1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public static void registerAnnotation(RuntimeHints hints, Class<?> annotationTyp
hints.reflection().registerType(annotationType, ANNOTATION_HINT);
Set<Class<?>> allAnnotations = new LinkedHashSet<>();
collectAliasedAnnotations(new HashSet<>(), allAnnotations, annotationType);
allAnnotations.forEach(annotation -> hints.reflection().registerType(annotation, ANNOTATION_HINT));
allAnnotations.forEach(annotation -> {
hints.reflection().registerType(annotation, ANNOTATION_HINT);
hints.proxies().registerJdkProxy(annotation, SynthesizedAnnotation.class);
});
if (!allAnnotations.isEmpty()) {
hints.proxies().registerJdkProxy(annotationType, SynthesizedAnnotation.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ void registerAnnotationTypeWithLocalUseOfAliasForRegistersProxy() {
}

@Test
void registerAnnotationTypeProxyRegistersJdkProxy() {
void registerAnnotationTypeProxyRegistersJdkProxies() {
RuntimeHintsUtils.registerAnnotation(this.hints, RetryInvoker.class);
assertThat(this.hints.reflection().typeHints())
.anySatisfy(annotationHint(RetryInvoker.class))
.anySatisfy(annotationHint(SampleInvoker.class));
assertThat(this.hints.proxies().jdkProxies()).singleElement()
.satisfies(annotationProxy(RetryInvoker.class));
assertThat(this.hints.proxies().jdkProxies())
.anySatisfy(annotationProxy(RetryInvoker.class))
.anySatisfy(annotationProxy(SampleInvoker.class))
.hasSize(2);
}

@Test
Expand All @@ -78,8 +80,11 @@ void registerAnnotationTypeWhereUsedAsAMetaAnnotationRegistersHierarchy() {
.anySatisfy(annotationHint(RetryInvoker.class))
.anySatisfy(annotationHint(SampleInvoker.class))
.hasSize(3);
assertThat(this.hints.proxies().jdkProxies()).singleElement()
.satisfies(annotationProxy(RetryWithEnabledFlagInvoker.class));
assertThat(this.hints.proxies().jdkProxies())
.anySatisfy(annotationProxy(RetryWithEnabledFlagInvoker.class))
.anySatisfy(annotationProxy(RetryInvoker.class))
.anySatisfy(annotationProxy(SampleInvoker.class))
.hasSize(3);
}

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

0 comments on commit 56a8c1a

Please sign in to comment.