Skip to content

Commit 9cfe791

Browse files
committed
Stop using RuntimeHintsUtils
Due to spring-projectsgh-29053, we can stop using RuntimeHintsUtils to register SynthesizedAnnotation proxies. Closes spring-projectsgh-29059
1 parent 1e80171 commit 9cfe791

File tree

12 files changed

+1
-212
lines changed

12 files changed

+1
-212
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationsRuntimeHints.java

-37
This file was deleted.

spring-beans/src/main/resources/META-INF/spring/aot.factories

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2-
org.springframework.beans.factory.annotation.BeanFactoryAnnotationsRuntimeHints,\
32
org.springframework.beans.factory.annotation.JakartaAnnotationsRuntimeHints
43

54
org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor=\

spring-core/src/main/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrar.java

-13
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
import org.springframework.aot.hint.ReflectionHints;
3030
import org.springframework.aot.hint.RuntimeHints;
31-
import org.springframework.aot.hint.support.RuntimeHintsUtils;
32-
import org.springframework.core.annotation.MergedAnnotation;
3331
import org.springframework.core.annotation.MergedAnnotations;
3432
import org.springframework.util.ClassUtils;
3533
import org.springframework.util.ReflectionUtils;
@@ -62,20 +60,9 @@ public void registerRuntimeHints(RuntimeHints runtimeHints, Class<?>... types) {
6260
entries.forEach(entry -> {
6361
AnnotatedElement element = entry.element();
6462
entry.processor().registerReflectionHints(runtimeHints.reflection(), element);
65-
registerAnnotationIfNecessary(runtimeHints, element);
6663
});
6764
}
6865

69-
@SuppressWarnings("deprecation")
70-
private void registerAnnotationIfNecessary(RuntimeHints hints, AnnotatedElement element) {
71-
MergedAnnotation<Reflective> reflectiveAnnotation = MergedAnnotations.from(element)
72-
.get(Reflective.class);
73-
MergedAnnotation<?> metaSource = reflectiveAnnotation.getMetaSource();
74-
if (metaSource != null) {
75-
RuntimeHintsUtils.registerAnnotationIfNecessary(hints, metaSource);
76-
}
77-
}
78-
7966
private void processType(Set<Entry> entries, Class<?> typeToProcess) {
8067
if (isReflective(typeToProcess)) {
8168
entries.add(createEntry(typeToProcess));

spring-core/src/test/java/org/springframework/aot/hint/annotation/ReflectiveRuntimeHintsRegistrarTests.java

-17
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,6 @@ void shouldProcessAnnotationOnMethod() {
8686
.satisfies(methodHint -> assertThat(methodHint.getName()).isEqualTo("managed")));
8787
}
8888

89-
@Test
90-
void shouldNotRegisterAnnotationProxyIfNotNeeded() {
91-
process(SampleMethodMetaAnnotatedBean.class);
92-
RuntimeHints runtimeHints = this.runtimeHints;
93-
assertThat(runtimeHints.proxies().jdkProxies()).isEmpty();
94-
}
95-
96-
@Test
97-
@SuppressWarnings("deprecation")
98-
void shouldRegisterAnnotationProxy() {
99-
process(SampleMethodMetaAnnotatedBeanWithAlias.class);
100-
RuntimeHints runtimeHints = this.runtimeHints;
101-
assertThat(RuntimeHintsPredicates.proxies()
102-
.forInterfaces(SampleInvoker.class, org.springframework.core.annotation.SynthesizedAnnotation.class))
103-
.accepts(runtimeHints);
104-
}
105-
10689
@Test
10790
void shouldProcessAnnotationOnInterface() {
10891
process(SampleMethodAnnotatedBeanWithInterface.class);

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessagingAnnotationsRuntimeHints.java

-43
This file was deleted.

spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/SimpAnnotationsRuntimeHints.java

-38
This file was deleted.

spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java

-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.context.ApplicationContext;
2828
import org.springframework.context.ApplicationContextAware;
2929
import org.springframework.context.annotation.Bean;
30-
import org.springframework.context.annotation.ImportRuntimeHints;
3130
import org.springframework.context.event.SmartApplicationListener;
3231
import org.springframework.core.task.TaskExecutor;
3332
import org.springframework.lang.Nullable;
@@ -41,12 +40,10 @@
4140
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
4241
import org.springframework.messaging.converter.MessageConverter;
4342
import org.springframework.messaging.converter.StringMessageConverter;
44-
import org.springframework.messaging.handler.annotation.MessagingAnnotationsRuntimeHints;
4543
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
4644
import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler;
4745
import org.springframework.messaging.simp.SimpLogging;
4846
import org.springframework.messaging.simp.SimpMessagingTemplate;
49-
import org.springframework.messaging.simp.annotation.SimpAnnotationsRuntimeHints;
5047
import org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler;
5148
import org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler;
5249
import org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler;
@@ -98,7 +95,6 @@
9895
* @author Sebastien Deleuze
9996
* @since 4.0
10097
*/
101-
@ImportRuntimeHints({ MessagingAnnotationsRuntimeHints.class, SimpAnnotationsRuntimeHints.class })
10298
public abstract class AbstractMessageBrokerConfiguration implements ApplicationContextAware {
10399

104100
private static final String MVC_VALIDATOR_NAME = "mvcValidator";

spring-test/src/test/java/org/springframework/test/context/aot/TestAotProcessorTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ void process(@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path tempDir) throws Exc
7070

7171
assertThat(findFiles(resourceOutput)).contains(
7272
"META-INF/native-image/org.example/app-tests/reflect-config.json",
73-
"META-INF/native-image/org.example/app-tests/resource-config.json",
74-
"META-INF/native-image/org.example/app-tests/proxy-config.json");
73+
"META-INF/native-image/org.example/app-tests/resource-config.json");
7574
}
7675

7776
private void copy(Class<?> testClass, Path destination) {

spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionRuntimeHints.java

-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2222
import org.springframework.aot.hint.TypeHint;
2323
import org.springframework.aot.hint.TypeReference;
24-
import org.springframework.aot.hint.support.RuntimeHintsUtils;
2524
import org.springframework.transaction.TransactionDefinition;
2625

2726
/**
@@ -35,9 +34,7 @@
3534
class TransactionRuntimeHints implements RuntimeHintsRegistrar {
3635

3736
@Override
38-
@SuppressWarnings("deprecation")
3937
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
40-
RuntimeHintsUtils.registerSynthesizedAnnotation(hints, Transactional.class);
4138
hints.reflection().registerTypes(TypeReference.listOf(
4239
Isolation.class, Propagation.class, TransactionDefinition.class),
4340
TypeHint.builtWith(MemberCategory.DECLARED_FIELDS));

spring-web/src/main/java/org/springframework/web/bind/annotation/WebAnnotationsRuntimeHintsRegistrar.java

-48
This file was deleted.

spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurationSupport.java

-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.context.ApplicationContext;
2828
import org.springframework.context.ApplicationContextAware;
2929
import org.springframework.context.annotation.Bean;
30-
import org.springframework.context.annotation.ImportRuntimeHints;
3130
import org.springframework.core.ReactiveAdapterRegistry;
3231
import org.springframework.core.annotation.Order;
3332
import org.springframework.core.convert.converter.Converter;
@@ -46,7 +45,6 @@
4645
import org.springframework.validation.Validator;
4746
import org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean;
4847
import org.springframework.web.bind.WebDataBinder;
49-
import org.springframework.web.bind.annotation.WebAnnotationsRuntimeHintsRegistrar;
5048
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
5149
import org.springframework.web.cors.CorsConfiguration;
5250
import org.springframework.web.reactive.DispatcherHandler;
@@ -85,7 +83,6 @@
8583
* @author Brian Clozel
8684
* @since 5.0
8785
*/
88-
@ImportRuntimeHints(WebAnnotationsRuntimeHintsRegistrar.class)
8986
public class WebFluxConfigurationSupport implements ApplicationContextAware {
9087

9188
@Nullable

spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java

-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.springframework.context.ApplicationContextAware;
3333
import org.springframework.context.annotation.Bean;
3434
import org.springframework.context.annotation.Configuration;
35-
import org.springframework.context.annotation.ImportRuntimeHints;
3635
import org.springframework.context.annotation.Lazy;
3736
import org.springframework.core.SpringProperties;
3837
import org.springframework.core.convert.converter.Converter;
@@ -71,7 +70,6 @@
7170
import org.springframework.web.HttpRequestHandler;
7271
import org.springframework.web.accept.ContentNegotiationManager;
7372
import org.springframework.web.bind.WebDataBinder;
74-
import org.springframework.web.bind.annotation.WebAnnotationsRuntimeHintsRegistrar;
7573
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
7674
import org.springframework.web.context.ServletContextAware;
7775
import org.springframework.web.cors.CorsConfiguration;
@@ -190,7 +188,6 @@
190188
* @see EnableWebMvc
191189
* @see WebMvcConfigurer
192190
*/
193-
@ImportRuntimeHints(WebAnnotationsRuntimeHintsRegistrar.class)
194191
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
195192

196193
/**

0 commit comments

Comments
 (0)