From 4e33d0c2931025c72ebc39111753a35a09a2cb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 9 Jun 2023 15:15:20 +0200 Subject: [PATCH 1/2] Add missing hint for ResourceEditor Closes gh-30628 --- .../org/springframework/beans/BeanUtilsRuntimeHints.java | 6 +++++- .../springframework/beans/BeanUtilsRuntimeHintsTests.java | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java index f0d18656a8d..3fc2e306739 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java @@ -17,8 +17,10 @@ package org.springframework.beans; import org.springframework.aot.hint.MemberCategory; +import org.springframework.aot.hint.ReflectionHints; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.core.io.ResourceEditor; import org.springframework.lang.Nullable; /** @@ -32,7 +34,9 @@ class BeanUtilsRuntimeHints implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { - hints.reflection().registerTypeIfPresent(classLoader, "org.springframework.http.MediaTypeEditor", + ReflectionHints reflectionHints = hints.reflection(); + reflectionHints.registerType(ResourceEditor.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); + reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.http.MediaTypeEditor", MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java index 23f6f56260f..af3e8da4033 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java @@ -24,6 +24,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; +import org.springframework.core.io.ResourceEditor; import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.util.ClassUtils; @@ -52,4 +53,10 @@ class BeanUtilsRuntimeHintsTests { .withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints); } + @Test + void resourceEditorHasHints() { + assertThat(RuntimeHintsPredicates.reflection().onType(ResourceEditor.class) + .withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints); + } + } From 439bcd67156277fcc05a75b5731572beb5523ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 9 Jun 2023 15:19:42 +0200 Subject: [PATCH 2/2] Polishing --- .../org/springframework/beans/BeanUtilsRuntimeHintsTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java index af3e8da4033..acd3cb68362 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; -import org.springframework.aot.hint.TypeReference; import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; import org.springframework.core.io.ResourceEditor; import org.springframework.core.io.support.SpringFactoriesLoader; +import org.springframework.http.MediaTypeEditor; import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -49,7 +49,7 @@ class BeanUtilsRuntimeHintsTests { @Test void mediaTypeEditorHasHints() { - assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of("org.springframework.http.MediaTypeEditor")) + assertThat(RuntimeHintsPredicates.reflection().onType(MediaTypeEditor.class) .withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints); }