Rationalize hints required for annotations

This commit updates RuntimeHintsUtils to focus on registering a JDK
proxy only as annotations of annotated elements that have at least
an introspection hints are visible out-of-the-box.

This commit also removes unnecessary hints and adapt `@Reflective` to
detect if a hint is required using the introduced
MergedAnnotation#isSynthesizable.

See gh-28967
This commit is contained in:
Stephane Nicoll
2022-08-16 14:15:02 +02:00
parent 32346b8382
commit 4f0c879778
17 changed files with 101 additions and 398 deletions

View File

@@ -35,8 +35,7 @@ public class MessagingAnnotationsRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
Stream.of(Controller.class, DestinationVariable.class, Header.class, Headers.class,
MessageExceptionHandler.class, MessageMapping.class, Payload.class, SendTo.class).forEach(
annotationType -> RuntimeHintsUtils.registerAnnotation(hints, annotationType));
Stream.of(Controller.class, Header.class, Headers.class, Payload.class).forEach(annotationType ->
RuntimeHintsUtils.registerSynthesizedAnnotation(hints, annotationType));
}
}

View File

@@ -16,8 +16,6 @@
package org.springframework.messaging.simp.annotation;
import java.util.stream.Stream;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.support.RuntimeHintsUtils;
@@ -33,7 +31,6 @@ public class SimpAnnotationsRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
Stream.of(SendToUser.class, SubscribeMapping.class).forEach(
annotationType -> RuntimeHintsUtils.registerAnnotation(hints, annotationType));
RuntimeHintsUtils.registerSynthesizedAnnotation(hints, SendToUser.class);
}
}