[Fix] Support AOT for @Bean ReferenceBean - #16428
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16428 +/- ##
============================================
- Coverage 36.93% 36.89% -0.04%
+ Complexity 11752 11749 -3
============================================
Files 1952 1952
Lines 89249 89284 +35
Branches 13389 13397 +8
============================================
- Hits 32961 32943 -18
- Misses 51710 51752 +42
- Partials 4578 4589 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I investigated the failing Unit Test matrix. The failure is unrelated to the AOT changes in this PR and is reproducible on the current
I reproduced the same order-dependent failure on both this PR branch and I have intentionally not included the test-isolation cleanup in this PR to keep #16428 scoped to the AOT fix. |
What is the purpose of the change?
Fixes #16145.
This PR fixes AOT support for Java-config
@Beanmethods annotated with@DubboReferenceand returningReferenceBean<T>.There were two related issues in this path:
The Java-config
ReferenceBeanmetadata, includinginterfaceClass,interfaceName, and reference properties, was stored asBeanDefinitionattributes, while the generated-artifact path restores this metadata from property values. As a result, the interface metadata andreferencePropsJsonwere missing in AOT mode.ReferenceAnnotationWithAotBeanPostProcessor.processAheadOfTime()only generated AOT contributions for field/method injection. AReferenceBean<T>created by an annotated@Beanfactory method therefore did not register the required proxy, reflection, and serialization runtime hints.This change:
ReferenceBeanmetadata required by generated artifacts;@BeanReferenceBean<T>;ReferenceBean<GenericService>with an explicitly configured service interface;Thanks to @mattmok for the detailed Native Image investigation in #16145.
Verification
The following focused and related tests pass:
ReferenceAnnotationWithAotBeanPostProcessorTestJavaConfigReferenceBeanTestReferenceAnnotationBeanPostProcessorTestThe new tests verify:
interfaceClass,interfaceName, andreferencePropsJsonpersistence;GenericServicewith an explicit service interface.I did not run an end-to-end GraalVM
native-imagebuild locally. The regression tests exercise the Spring AOT metadata and RuntimeHints paths involved in the reported failure.Checklist