Adapt to recent changes in RuntimeHints API

See gh-https://github.com/spring-projects/spring-framework/issues/29011
pull/32180/head
Stephane Nicoll 2 years ago
parent 1db2ad08fa
commit bb7829791a

@ -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<ExecutableHint.Builder> 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) {

@ -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) {

@ -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));
});
}

Loading…
Cancel
Save