Browse Source

Merge branch '6.0.x'

pull/30396/merge
Sébastien Deleuze 1 year ago
parent
commit
ccb8db41f0
  1. 6
      spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java
  2. 11
      spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java

6
spring-beans/src/main/java/org/springframework/beans/BeanUtilsRuntimeHints.java

@ -17,8 +17,10 @@ @@ -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 { @@ -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);
}

11
spring-beans/src/test/java/org/springframework/beans/BeanUtilsRuntimeHintsTests.java

@ -22,9 +22,10 @@ import org.junit.jupiter.api.Test; @@ -22,9 +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;
@ -48,7 +49,13 @@ class BeanUtilsRuntimeHintsTests { @@ -48,7 +49,13 @@ 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);
}
@Test
void resourceEditorHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(ResourceEditor.class)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints);
}

Loading…
Cancel
Save