[Fix] Support AOT for @Bean ReferenceBean - #16428
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16428 +/- ##
============================================
+ Coverage 60.90% 60.95% +0.05%
- Complexity 11765 11796 +31
============================================
Files 1953 1953
Lines 89271 89306 +35
Branches 13473 13481 +8
============================================
+ Hits 54367 54440 +73
+ Misses 29321 29275 -46
- Partials 5583 5591 +8
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. |
23e8799 to
d329f1c
Compare
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