Drifter-yh opened a new pull request, #16428: URL: https://github.com/apache/dubbo/pull/16428
## What is the purpose of the change? Fixes #16145. This PR fixes AOT support for Java-config `@Bean` methods annotated with `@DubboReference` and returning `ReferenceBean<T>`. There were two related issues in this path: 1. The Java-config `ReferenceBean` metadata, including `interfaceClass`, `interfaceName`, and reference properties, was stored as `BeanDefinition` attributes, while the generated-artifact path restores this metadata from property values. As a result, the interface metadata and `referencePropsJson` were missing in AOT mode. 2. `ReferenceAnnotationWithAotBeanPostProcessor.processAheadOfTime()` only generated AOT contributions for field/method injection. A `ReferenceBean<T>` created by an annotated `@Bean` factory method therefore did not register the required proxy, reflection, and serialization runtime hints. This change: - persists the Java-config `ReferenceBean` metadata required by generated artifacts; - adds AOT contribution support for annotated `@Bean` `ReferenceBean<T>`; - reuses the existing RuntimeHints registration logic; - handles `ReferenceBean<GenericService>` with an explicitly configured service interface; - adds focused regression tests for metadata persistence and RuntimeHints generation. Thanks to @mattmok for the detailed Native Image investigation in #16145. ### Verification The following focused and related tests pass: - `ReferenceAnnotationWithAotBeanPostProcessorTest` - `JavaConfigReferenceBeanTest` - `ReferenceAnnotationBeanPostProcessorTest` The new tests verify: - `interfaceClass`, `interfaceName`, and `referencePropsJson` persistence; - AOT contribution generation; - JDK proxy RuntimeHints; - reflection and serialization RuntimeHints; - `GenericService` with an explicit service interface. I did not run an end-to-end GraalVM `native-image` build locally. The regression tests exercise the Spring AOT metadata and RuntimeHints paths involved in the reported failure. ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project. - [ ] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
