diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationProperties.java index 994e9381e0..34848c7769 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationProperties.java @@ -20,6 +20,7 @@ import java.util.LinkedHashSet; import java.util.Set; import org.springframework.boot.Banner.Mode; +import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar; import org.springframework.boot.logging.LoggingSystemProperty; import org.springframework.core.env.Environment; @@ -156,4 +157,12 @@ class ApplicationProperties { this.webApplicationType = webApplicationType; } + static class ApplicationPropertiesRuntimeHints extends BindableRuntimeHintsRegistrar { + + ApplicationPropertiesRuntimeHints() { + super(ApplicationProperties.class); + } + + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index fed80707e5..005f8e81d3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -58,7 +58,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.boot.Banner.Mode; import org.springframework.boot.context.properties.bind.Bindable; -import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; import org.springframework.boot.convert.ApplicationConversionService; @@ -1594,14 +1593,6 @@ public class SpringApplication { } - static class SpringApplicationRuntimeHints extends BindableRuntimeHintsRegistrar { - - SpringApplicationRuntimeHints() { - super(SpringApplication.class); - } - - } - /** * Exception that can be thrown to silently exit a running {@link SpringApplication} * without handling run failures. diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories b/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories index 905cd71740..d938a89eda 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories @@ -1,5 +1,5 @@ org.springframework.aot.hint.RuntimeHintsRegistrar=\ -org.springframework.boot.SpringApplication.SpringApplicationRuntimeHints,\ +org.springframework.boot.ApplicationProperties.ApplicationPropertiesRuntimeHints,\ org.springframework.boot.SpringApplicationBannerPrinter.SpringApplicationBannerPrinterRuntimeHints,\ org.springframework.boot.WebApplicationType.WebApplicationTypeRuntimeHints,\ org.springframework.boot.context.config.ConfigDataLocationRuntimeHints,\ diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ApplicationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ApplicationPropertiesTests.java index ead83d7c38..2620bc8745 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ApplicationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ApplicationPropertiesTests.java @@ -18,6 +18,9 @@ package org.springframework.boot; import org.junit.jupiter.api.Test; +import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; +import org.springframework.boot.ApplicationProperties.ApplicationPropertiesRuntimeHints; import org.springframework.boot.Banner.Mode; import org.springframework.mock.env.MockEnvironment; @@ -44,4 +47,19 @@ class ApplicationPropertiesTests { assertThat(properties.getBannerMode(environment)).isEqualTo(Mode.OFF); } + @Test + void shouldRegisterHints() { + RuntimeHints hints = new RuntimeHints(); + new ApplicationPropertiesRuntimeHints().registerHints(hints, getClass().getClassLoader()); + assertThat(RuntimeHintsPredicates.reflection().onType(ApplicationProperties.class)).accepts(hints); + assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "setBannerMode")) + .accepts(hints); + assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "getSources")) + .accepts(hints); + assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "setSources")) + .accepts(hints); + assertThat(RuntimeHintsPredicates.reflection().onMethod(ApplicationProperties.class, "getBannerMode")) + .rejects(hints); + } + } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 353553d14b..2f07827407 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -44,8 +44,6 @@ import org.mockito.Mockito; import reactor.core.publisher.Mono; import org.springframework.aot.AotDetector; -import org.springframework.aot.hint.RuntimeHints; -import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCurrentlyInCreationException; import org.springframework.beans.factory.ObjectProvider; @@ -58,7 +56,6 @@ import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.support.DefaultBeanNameGenerator; import org.springframework.boot.Banner.Mode; import org.springframework.boot.BootstrapRegistry.InstanceSupplier; -import org.springframework.boot.SpringApplication.SpringApplicationRuntimeHints; import org.springframework.boot.availability.AvailabilityChangeEvent; import org.springframework.boot.availability.AvailabilityState; import org.springframework.boot.availability.LivenessState; @@ -1412,18 +1409,6 @@ class SpringApplicationTests { then(listener).should(never()).onApplicationEvent(any(ApplicationFailedEvent.class)); } - @Test - void shouldRegisterHints() { - RuntimeHints hints = new RuntimeHints(); - new SpringApplicationRuntimeHints().registerHints(hints, getClass().getClassLoader()); - assertThat(RuntimeHintsPredicates.reflection().onType(SpringApplication.class)).accepts(hints); - assertThat(RuntimeHintsPredicates.reflection().onMethod(SpringApplication.class, "setBannerMode")) - .accepts(hints); - assertThat(RuntimeHintsPredicates.reflection().onMethod(SpringApplication.class, "getSources")).accepts(hints); - assertThat(RuntimeHintsPredicates.reflection().onMethod(SpringApplication.class, "setSources")).accepts(hints); - assertThat(RuntimeHintsPredicates.reflection().onMethod(SpringApplication.class, "load")).rejects(hints); - } - @Test // gh-32555 void shouldUseAotInitializer() { SpringApplication application = new SpringApplication(ExampleAotProcessedMainClass.class);