Add support for InjectionPoint with AOT

This commit reviews BeanInstanceSupplier to reuse more code from
ConstructorResolver. Previously, the autowired argument resolution was
partially duplicated and this commit introduces a new common path via
RegisteredBean#resolveAutowiredArgument.

Closes gh-30401
This commit is contained in:
Stephane Nicoll
2023-05-05 15:49:40 +02:00
parent a133aae8d6
commit c1f6d7197b
5 changed files with 82 additions and 34 deletions

View File

@@ -59,6 +59,7 @@ import org.springframework.context.testfixture.context.annotation.CglibConfigura
import org.springframework.context.testfixture.context.annotation.ConfigurableCglibConfiguration;
import org.springframework.context.testfixture.context.annotation.GenericTemplateConfiguration;
import org.springframework.context.testfixture.context.annotation.InitDestroyComponent;
import org.springframework.context.testfixture.context.annotation.InjectionPointConfiguration;
import org.springframework.context.testfixture.context.annotation.LazyAutowiredFieldComponent;
import org.springframework.context.testfixture.context.annotation.LazyAutowiredMethodComponent;
import org.springframework.context.testfixture.context.annotation.LazyConstructorArgumentComponent;
@@ -315,6 +316,17 @@ class ApplicationContextAotGeneratorTests {
});
}
@Test
void processAheadOfTimeWithInjectionPoint() {
GenericApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.registerBean(InjectionPointConfiguration.class);
testCompiledResult(applicationContext, (initializer, compiled) -> {
GenericApplicationContext freshApplicationContext = toFreshApplicationContext(initializer);
assertThat(freshApplicationContext.getBean("classToString"))
.isEqualTo(InjectionPointConfiguration.class.getName());
});
}
@Nested
@CompileWithForkedClassLoader
class ConfigurationClassCglibProxy {