Add reflection hints for bean registration interfaces
Prior to this commit, the bean registration AOT contributions would register introspection and invocation hints on both declared and public methods for bean types. The bean introspection algorithm also looks at default methods implemented by interfaces when collecting bean property information. This commit ensures that introspection hints are registered for all implemented interfaces when registering beans. Closes gh-31350
This commit is contained in:
parent
c45bf3c061
commit
b832df6087
|
|
@ -118,6 +118,9 @@ class BeanRegistrationsAotContribution
|
|||
ReflectionHints hints = runtimeHints.reflection();
|
||||
Class<?> beanClass = beanRegistrationKey.beanClass();
|
||||
hints.registerType(beanClass, MemberCategory.INTROSPECT_PUBLIC_METHODS, MemberCategory.INTROSPECT_DECLARED_METHODS);
|
||||
for (Class<?> interfaceType : beanClass.getInterfaces()) {
|
||||
hints.registerType(interfaceType, MemberCategory.INTROSPECT_PUBLIC_METHODS);
|
||||
}
|
||||
// Workaround for https://github.com/oracle/graal/issues/6510
|
||||
if (beanClass.isRecord()) {
|
||||
hints.registerType(beanClass, MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
|
|
|
|||
|
|
@ -149,6 +149,11 @@ class BeanRegistrationsAotContributionTests {
|
|||
assertThat(reflection().onType(TestBean.class)
|
||||
.withMemberCategories(MemberCategory.INTROSPECT_PUBLIC_METHODS, MemberCategory.INTROSPECT_DECLARED_METHODS))
|
||||
.accepts(this.generationContext.getRuntimeHints());
|
||||
for (Class<?> interfaceType : TestBean.class.getInterfaces()) {
|
||||
assertThat(reflection().onType(interfaceType)
|
||||
.withMemberCategory(MemberCategory.INTROSPECT_PUBLIC_METHODS))
|
||||
.accepts(this.generationContext.getRuntimeHints());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue