Fix hints and predicates for Field reflective access

This commit revisits the arrangement for Field hints after changes made
in gh-34239.

Closes gh-34294
This commit is contained in:
Brian Clozel
2025-01-21 20:05:12 +01:00
parent 3302bc46f8
commit f85752a956
21 changed files with 115 additions and 145 deletions

View File

@@ -253,10 +253,10 @@ class BeanDefinitionPropertiesCodeGenerator {
// ReflectionUtils#findField searches recursively in the type hierarchy
Class<?> searchType = beanDefinition.getTargetType();
while (searchType != null && searchType != writeMethod.getDeclaringClass()) {
this.hints.reflection().registerType(searchType, MemberCategory.INVOKE_DECLARED_FIELDS);
this.hints.reflection().registerType(searchType, MemberCategory.ACCESS_DECLARED_FIELDS);
searchType = searchType.getSuperclass();
}
this.hints.reflection().registerType(writeMethod.getDeclaringClass(), MemberCategory.INVOKE_DECLARED_FIELDS);
this.hints.reflection().registerType(writeMethod.getDeclaringClass(), MemberCategory.ACCESS_DECLARED_FIELDS);
}
private void addQualifiers(CodeBlock.Builder code, RootBeanDefinition beanDefinition) {

View File

@@ -574,7 +574,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
private void assertHasDeclaredFieldsHint(Class<?> beanType) {
assertThat(RuntimeHintsPredicates.reflection()
.onType(beanType).withMemberCategory(MemberCategory.INVOKE_DECLARED_FIELDS))
.onType(beanType).withMemberCategory(MemberCategory.ACCESS_DECLARED_FIELDS))
.accepts(this.generationContext.getRuntimeHints());
}