Add AOT support for generic constructor argument values

This commit improves compatibility with the core container when running
in AOT mode by adding support for generic constructor argument values.

Previously, these were ignored altogether. We now have code generation
support for them as well as resolution that is similar to what
AbstractAutowiredCapableBeanFactory does in a regular runtime.

This commit also improves AOT support for XML bean configurations by
adding more support for TypedStringValue and inner bean definitions.

Closes gh-31420
This commit is contained in:
Stéphane Nicoll
2023-10-12 15:01:28 +02:00
parent ca4d0d784b
commit 85388aa642
11 changed files with 445 additions and 57 deletions

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="petInnerBean" class="org.springframework.beans.testfixture.beans.Pet">
<constructor-arg>
<bean class="java.lang.String">
<constructor-arg value="Fido"/>
</bean>
</constructor-arg>
</bean>
<bean id="petName" class="java.lang.String">
<constructor-arg value="Dofi"/>
</bean>
<bean id="petRefBean" class="org.springframework.beans.testfixture.beans.Pet">
<constructor-arg ref="petName"/>
</bean>
</beans>

View File

@@ -8,8 +8,12 @@
<property name="company" value="Acme Widgets, Inc." />
</bean>
<bean id="pet" class="org.springframework.beans.testfixture.beans.Pet">
<bean id="petIndexed" class="org.springframework.beans.testfixture.beans.Pet">
<constructor-arg index="0" value="Fido" />
</bean>
<bean id="petGeneric" class="org.springframework.beans.testfixture.beans.Pet">
<constructor-arg value="Dofi" />
</bean>
</beans>