Skip to content

Commit

Permalink
Do not register SynthesizedAnnotation proxy for @AliasFor
Browse files Browse the repository at this point in the history
Closes gh-28953
  • Loading branch information
sbrannen committed Aug 11, 2022
1 parent 0207f3a commit 7631a09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Utility methods for runtime hints support code.
*
* @author Stephane Nicoll
* @author Sam Brannen
* @since 6.0
*/
public abstract class RuntimeHintsUtils {
Expand Down Expand Up @@ -88,7 +89,8 @@ private static void registerAnnotation(RuntimeHints hints, Class<?> annotationTy
}

private static void collectAliasedAnnotations(Set<Class<?>> seen, Set<Class<?>> types, Class<?> annotationType) {
if (seen.contains(annotationType) || Reflective.class.equals(annotationType)) {
if (seen.contains(annotationType) || AliasFor.class.equals(annotationType) ||
Reflective.class.equals(annotationType)) {
return;
}
seen.add(annotationType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Tests for {@link RuntimeHintsUtils}.
*
* @author Stephane Nicoll
* @author Sam Brannen
*/
class RuntimeHintsUtilsTests {

Expand Down Expand Up @@ -80,6 +81,14 @@ void registerAnnotationTypeProxyRegistersJdkProxies() {
.hasSize(2);
}

@Test // gh-28953
void registerAnnotationForAliasForShouldNotRegisterSynthesizedAnnotationProxy() {
RuntimeHintsUtils.registerAnnotation(this.hints, AliasFor.class);
assertThat(this.hints.reflection().typeHints()).singleElement()
.satisfies(annotationHint(AliasFor.class));
assertThat(this.hints.proxies().jdkProxies()).isEmpty();
}

@Test
void registerAnnotationTypeWhereUsedAsAMetaAnnotationRegistersHierarchy() {
RuntimeHintsUtils.registerAnnotation(this.hints, RetryWithEnabledFlagInvoker.class);
Expand Down

0 comments on commit 7631a09

Please sign in to comment.