Skip to content

Commit 5e5e95a

Browse files
committed
Polish RuntimeHintsUtils
1 parent 897e47d commit 5e5e95a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

spring-context/src/main/java/org/springframework/context/aot/ReflectiveProcessorBeanRegistrationAotProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
/**
4747
* AOT {@code BeanRegistrationAotProcessor} that detects the presence of
48-
* {@link Reflective @Reflective} on annotated elements and invoke the
48+
* {@link Reflective @Reflective} on annotated elements and invokes the
4949
* underlying {@link ReflectiveProcessor} implementations.
5050
*
5151
* @author Stephane Nicoll

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.aot.hint.TypeHint.Builder;
3030
import org.springframework.aot.hint.annotation.Reflective;
3131
import org.springframework.core.annotation.AliasFor;
32-
import org.springframework.core.annotation.MergedAnnotations;
3332
import org.springframework.core.annotation.SynthesizedAnnotation;
3433

3534
/**
@@ -49,10 +48,11 @@ public abstract class RuntimeHintsUtils {
4948

5049
/**
5150
* Register the necessary hints so that the specified annotation is visible
52-
* at runtime. If an annotation attributes aliases an attribute of another
53-
* annotation, it is registered as well and a JDK proxy hints is defined
51+
* at runtime.
52+
* <p>If an annotation attribute aliases an attribute of another annotation,
53+
* the other annotation is registered as well and a JDK proxy hint is defined
5454
* so that the synthesized annotation can be resolved.
55-
* @param hints the {@link RuntimeHints} instance ot use
55+
* @param hints the {@link RuntimeHints} instance to use
5656
* @param annotationType the annotation type
5757
* @see SynthesizedAnnotation
5858
*/
@@ -61,7 +61,7 @@ public static void registerAnnotation(RuntimeHints hints, Class<?> annotationTyp
6161
Set<Class<?>> allAnnotations = new LinkedHashSet<>();
6262
collectAliasedAnnotations(new HashSet<>(), allAnnotations, annotationType);
6363
allAnnotations.forEach(annotation -> hints.reflection().registerType(annotation, ANNOTATION_HINT));
64-
if (allAnnotations.size() > 0) {
64+
if (!allAnnotations.isEmpty()) {
6565
hints.proxies().registerJdkProxy(annotationType, SynthesizedAnnotation.class);
6666
}
6767
}
@@ -72,9 +72,9 @@ private static void collectAliasedAnnotations(Set<Class<?>> seen, Set<Class<?>>
7272
}
7373
seen.add(annotationType);
7474
for (Method method : annotationType.getDeclaredMethods()) {
75-
MergedAnnotations methodAnnotations = MergedAnnotations.from(method);
76-
if (methodAnnotations.isPresent(AliasFor.class)) {
77-
Class<?> annotationAttribute = methodAnnotations.get(AliasFor.class).getClass("annotation");
75+
AliasFor aliasFor = method.getAnnotation(AliasFor.class);
76+
if (aliasFor != null) {
77+
Class<?> annotationAttribute = aliasFor.annotation();
7878
Class<?> targetAnnotation = (annotationAttribute != Annotation.class
7979
? annotationAttribute : annotationType);
8080
if (!types.contains(targetAnnotation)) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,14 @@ private Consumer<JdkProxyHint> annotationProxy(Class<?> type) {
104104

105105
@SampleInvoker
106106
static class SampleInvokerClass {
107-
108107
}
109108

110109
@RetryInvoker
111110
static class RetryInvokerClass {
112-
113111
}
114112

115113
@RetryWithEnabledFlagInvoker
116114
static class RetryWithEnabledFlagInvokerClass {
117-
118115
}
119116

120117
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })

0 commit comments

Comments
 (0)