diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java index 6e6122f894..f92d11fff8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/AotProcessor.java @@ -25,14 +25,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.function.Consumer; import org.springframework.aot.generate.ClassNameGenerator; import org.springframework.aot.generate.DefaultGenerationContext; import org.springframework.aot.generate.FileSystemGeneratedFiles; import org.springframework.aot.generate.GeneratedFiles.Kind; -import org.springframework.aot.hint.ExecutableHint; -import org.springframework.aot.hint.ExecutableMode; import org.springframework.aot.hint.ReflectionHints; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.TypeReference; @@ -58,9 +55,6 @@ import org.springframework.util.FileSystemUtils; */ public class AotProcessor { - private static final Consumer INVOKE_CONSTRUCTOR_HINT = (hint) -> hint - .setModes(ExecutableMode.INVOKE); - private final Class application; private final String[] applicationArgs; @@ -161,8 +155,8 @@ public class AotProcessor { ReflectionHints reflection = generationContext.getRuntimeHints().reflection(); reflection.registerType(applicationType, (hint) -> { }); - reflection.registerType(generatedType, (hint) -> hint.onReachableType(applicationType) - .withConstructor(Collections.emptyList(), INVOKE_CONSTRUCTOR_HINT)); + reflection.registerType(generatedType, + (hint) -> hint.onReachableType(applicationType).withConstructor(Collections.emptyList())); } private Path getRoot(Kind kind) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackRuntimeHints.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackRuntimeHints.java index 34b76f827d..35b58c87a6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackRuntimeHints.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackRuntimeHints.java @@ -22,7 +22,6 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.pattern.SyslogStartConverter; import ch.qos.logback.core.rolling.helper.DateTokenConverter; import ch.qos.logback.core.rolling.helper.IntegerTokenConverter; -import org.slf4j.bridge.SLF4JBridgeHandler; import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.ReflectionHints; @@ -55,9 +54,7 @@ class LogbackRuntimeHints implements RuntimeHintsRegistrar { private void registerHintsForLogbackLoggingSystemTypeChecks(ReflectionHints reflection, ClassLoader classLoader) { reflection.registerType(LoggerContext.class, DEFAULT_HINT); - if (ClassUtils.isPresent("org.slf4j.bridge.SLF4JBridgeHandler", classLoader)) { - reflection.registerType(SLF4JBridgeHandler.class, DEFAULT_HINT); - } + reflection.registerTypeIfPresent(classLoader, "org.slf4j.bridge.SLF4JBridgeHandler", DEFAULT_HINT); } private void registerHintsForBuiltInLogbackConverters(ReflectionHints reflection) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index 6a63e7f6b7..0d31c84999 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -36,7 +36,6 @@ import java.util.function.Supplier; import reactor.netty.http.client.HttpClientRequest; -import org.springframework.aot.hint.ExecutableMode; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; @@ -804,12 +803,9 @@ public class RestTemplateBuilder { ReflectionUtils.findField(AbstractClientHttpRequestFactoryWrapper.class, "requestFactory"))); ClientHttpRequestFactorySupplier.ClientHttpRequestFactorySupplierRuntimeHints.registerHints(hints, classLoader, (hint) -> { - hint.withMethod("setConnectTimeout", List.of(TypeReference.of(int.class)), - (method) -> method.withMode(ExecutableMode.INVOKE)); - hint.withMethod("setReadTimeout", List.of(TypeReference.of(int.class)), - (method) -> method.withMode(ExecutableMode.INVOKE)); - hint.withMethod("setBufferRequestBody", List.of(TypeReference.of(boolean.class)), - (method) -> method.withMode(ExecutableMode.INVOKE)); + hint.withMethod("setConnectTimeout", TypeReference.listOf(int.class)); + hint.withMethod("setReadTimeout", TypeReference.listOf(int.class)); + hint.withMethod("setBufferRequestBody", TypeReference.listOf(boolean.class)); }); }