Basically copy of #29646
I have verified that builders are still not supported in Spring Boot 3.2.2 (Spring 6.1.3) despite fixes in https://github.com/spring-projects/spring-framework/commit/e6397c8a38696d7da58401eecea515f0cd986554
This is because only constructors are added as seen here: https://github.com/spring-projects/spring-framework/blob/e6397c8a38696d7da58401eecea515f0cd986554/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java#L182
So what ends up happening is that the builder gets instantiated, but cannot finish creating the object via calling #build
.
If I add hints for #build
, the objects would be empty, because no other builder methods are available. So basically the solution is to also add hints for all declared methods of the builder.
The repro provided here is still viable.
I see that the registration is quite generic, as in doesn't "know" what it's doing, so doesn't know about JsonDeserialize
and it's builder. I'm not sure how to add support for builder
in a generic way without adding specific logic around JsonDeserialize
, which goes against the idea of not going too deep into jackson support.
Anyway, please have a look, thanks.
Comment From: simonbasle
There is a chance we can have a quick win and cover that particular case in time for the next 6.1 release without going too deep into Jackson support specifics.
I need to review the BindingReflectionHintsRegistrar
responsibilities and see if a more generic improvement can be made for 6.2, to be discussed with the team.