Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dpozinen opened this issue Feb 10, 2024 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@dpozinen
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 10, 2024
@simonbasle simonbasle self-assigned this Feb 13, 2024
@simonbasle simonbasle added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 13, 2024
@simonbasle
Copy link
Contributor

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.

@snicoll snicoll added this to the 6.1.x milestone Feb 13, 2024
@simonbasle simonbasle modified the milestones: 6.1.x, 6.1.4 Feb 13, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.0.x labels Feb 13, 2024
simonbasle added a commit that referenced this issue Feb 13, 2024
This notably enables Jackson to reflectively call a user-provided
builder class and invoke its declared methods (setters and build) in
a native app.

See gh-32238
Closes gh-32257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants