Consider the following configuration class:
@Configuration
public class MyConfiguration {
@Bean
A a() { return new A(); }
@Bean
B b() { return new B(this.a()); }
static class A {
public A() { System.out.println("A constructor"); }
}
static class B {
public B(A a) { System.out.println("B constructor"); }
}
}
On JVM in regular mode, it prints:
A constructor
B constructor
On JVM in AOT mode or native, while it seems CGLIB proxies are generated correctly at build time, but they seems not used since it prints:
A constructor
A constructor
B constructor
The code generated AOT maybe needs to be updated to leverage those CGLIB proxies.
Comment From: snicoll
We need to swap the creation of the raw class to the cglib proxy. I was hoping I could avoid having to change code generation for this but it turns out that there isn't a way to achieve this using an instance supplier.
I've a proposal in 3b8bcdf.
This is blocked by https://github.com/spring-projects/spring-boot/issues/32304 and, to some extent, https://github.com/spring-projects/spring-framework/issues/29141
Comment From: snicoll
I have it working but I think it needs a bit more work to test it correctly.