Add missing reflection hint in BeanRegistrationsAotContribution
Prior to this commit, the `BeanRegistrationsAotContribution` would only contribute introspection hints for declared methods. This does not cover inherited public methods. This commit adds the missing hint on public methods. Fixes gh-31293
This commit is contained in:
parent
db5ba8562f
commit
1e5e8db0e0
|
|
@ -117,10 +117,10 @@ class BeanRegistrationsAotContribution
|
||||||
registrations.keySet().forEach(beanRegistrationKey -> {
|
registrations.keySet().forEach(beanRegistrationKey -> {
|
||||||
ReflectionHints hints = runtimeHints.reflection();
|
ReflectionHints hints = runtimeHints.reflection();
|
||||||
Class<?> beanClass = beanRegistrationKey.beanClass();
|
Class<?> beanClass = beanRegistrationKey.beanClass();
|
||||||
hints.registerType(beanClass, MemberCategory.INTROSPECT_DECLARED_METHODS);
|
hints.registerType(beanClass, MemberCategory.INTROSPECT_PUBLIC_METHODS, MemberCategory.INTROSPECT_DECLARED_METHODS);
|
||||||
// Workaround for https://github.com/oracle/graal/issues/6510
|
// Workaround for https://github.com/oracle/graal/issues/6510
|
||||||
if (beanClass.isRecord()) {
|
if (beanClass.isRecord()) {
|
||||||
hints.registerType(beanClass, MemberCategory.INVOKE_DECLARED_METHODS);
|
hints.registerType(beanClass, MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||||
}
|
}
|
||||||
// Workaround for https://github.com/oracle/graal/issues/6529
|
// Workaround for https://github.com/oracle/graal/issues/6529
|
||||||
ReflectionUtils.doWithMethods(beanClass, method -> {
|
ReflectionUtils.doWithMethods(beanClass, method -> {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class BeanRegistrationsAotContributionTests {
|
||||||
BeanRegistrationsAotContribution contribution = createContribution(TestBean.class, generator);
|
BeanRegistrationsAotContribution contribution = createContribution(TestBean.class, generator);
|
||||||
contribution.applyTo(this.generationContext, this.beanFactoryInitializationCode);
|
contribution.applyTo(this.generationContext, this.beanFactoryInitializationCode);
|
||||||
assertThat(reflection().onType(TestBean.class)
|
assertThat(reflection().onType(TestBean.class)
|
||||||
.withMemberCategory(MemberCategory.INTROSPECT_DECLARED_METHODS))
|
.withMemberCategories(MemberCategory.INTROSPECT_PUBLIC_METHODS, MemberCategory.INTROSPECT_DECLARED_METHODS))
|
||||||
.accepts(this.generationContext.getRuntimeHints());
|
.accepts(this.generationContext.getRuntimeHints());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +159,8 @@ class BeanRegistrationsAotContributionTests {
|
||||||
BeanRegistrationsAotContribution contribution = createContribution(RecordBean.class, generator);
|
BeanRegistrationsAotContribution contribution = createContribution(RecordBean.class, generator);
|
||||||
contribution.applyTo(this.generationContext, this.beanFactoryInitializationCode);
|
contribution.applyTo(this.generationContext, this.beanFactoryInitializationCode);
|
||||||
assertThat(reflection().onType(RecordBean.class)
|
assertThat(reflection().onType(RecordBean.class)
|
||||||
.withMemberCategories(MemberCategory.INTROSPECT_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_METHODS))
|
.withMemberCategories(MemberCategory.INTROSPECT_PUBLIC_METHODS, MemberCategory.INTROSPECT_DECLARED_METHODS,
|
||||||
|
MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_METHODS))
|
||||||
.accepts(this.generationContext.getRuntimeHints());
|
.accepts(this.generationContext.getRuntimeHints());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue