Skip to content

@JsonDeserialize(builder = ...) does not work in GraalVM native image #32238

Closed
@dpozinen

Description

@dpozinen

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 e6397c8

This is because only constructors are added as seen here:

hints.registerType(classValue, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestheme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions