Stop using RuntimeHintsUtils
Due to gh-29053, we can stop using RuntimeHintsUtils to register SynthesizedAnnotation proxies. Closes gh-29059
This commit is contained in:
@@ -28,8 +28,6 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.aot.hint.ReflectionHints;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.support.RuntimeHintsUtils;
|
||||
import org.springframework.core.annotation.MergedAnnotation;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -62,20 +60,9 @@ public class ReflectiveRuntimeHintsRegistrar {
|
||||
entries.forEach(entry -> {
|
||||
AnnotatedElement element = entry.element();
|
||||
entry.processor().registerReflectionHints(runtimeHints.reflection(), element);
|
||||
registerAnnotationIfNecessary(runtimeHints, element);
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void registerAnnotationIfNecessary(RuntimeHints hints, AnnotatedElement element) {
|
||||
MergedAnnotation<Reflective> reflectiveAnnotation = MergedAnnotations.from(element)
|
||||
.get(Reflective.class);
|
||||
MergedAnnotation<?> metaSource = reflectiveAnnotation.getMetaSource();
|
||||
if (metaSource != null) {
|
||||
RuntimeHintsUtils.registerAnnotationIfNecessary(hints, metaSource);
|
||||
}
|
||||
}
|
||||
|
||||
private void processType(Set<Entry> entries, Class<?> typeToProcess) {
|
||||
if (isReflective(typeToProcess)) {
|
||||
entries.add(createEntry(typeToProcess));
|
||||
|
||||
@@ -86,23 +86,6 @@ class ReflectiveRuntimeHintsRegistrarTests {
|
||||
.satisfies(methodHint -> assertThat(methodHint.getName()).isEqualTo("managed")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotRegisterAnnotationProxyIfNotNeeded() {
|
||||
process(SampleMethodMetaAnnotatedBean.class);
|
||||
RuntimeHints runtimeHints = this.runtimeHints;
|
||||
assertThat(runtimeHints.proxies().jdkProxies()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void shouldRegisterAnnotationProxy() {
|
||||
process(SampleMethodMetaAnnotatedBeanWithAlias.class);
|
||||
RuntimeHints runtimeHints = this.runtimeHints;
|
||||
assertThat(RuntimeHintsPredicates.proxies()
|
||||
.forInterfaces(SampleInvoker.class, org.springframework.core.annotation.SynthesizedAnnotation.class))
|
||||
.accepts(runtimeHints);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldProcessAnnotationOnInterface() {
|
||||
process(SampleMethodAnnotatedBeanWithInterface.class);
|
||||
|
||||
Reference in New Issue
Block a user