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

feat: Spring boot native image support #609

Merged
merged 12 commits into from
Feb 18, 2024

Conversation

Christopher-Chianelli
Copy link
Contributor

Spring boot does not seem to have a way to record POJOs to use them in generated files. I written a basic one that assumes all fields on POJOs have public setters and can serialize primitives, builtins, and collection types.

@Christopher-Chianelli
Copy link
Contributor Author

Additionally, this uses reflection; future work would be to integrate GIZMO code.

Copy link
Contributor

@triceo triceo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major comments:

  • Serialization must not be our business. If we don't know how to make it happen, we need to ask the Spring guys. I can not accept responsibility for maintaining our own serialization framework.
  • Please use Timefold Solver consistently. Where you're speaking of Timefold, you probably should have been speaking of TimefoldSolver.
  • Please include a section in our documentation for Spring on how to build a native image. Especially mention all the quirks of our implementation which may not be immediately obvious, such as any requirements to make anything public.
  • Please make sure that the Spring quickstart supports native, and that it is tested as part of the standard PR workflow on the Quickstarts repo.

@triceo
Copy link
Contributor

triceo commented Feb 16, 2024

Some outstanding things before we can merge:

  • I changed our Sonar settings, hopefully removing many of the things we don't want to worry about. Please take a look at what remains and resolve as much as makes sense.
  • See Geoffrey's and my comments on Slack.
  • Documentation needs to be added. (Preferrably also for Quarkus, if we're missing that too.)
  • It shows me that the branch has conflicts.
  • The quickstarts PR is not yet ready for review.

Spring boot does not seem to have a way to record POJOs to
use them in generated files. I written a basic one that
assumes all fields on POJOs have public setters and can
serialize primitives, builtins, and collection types.
This is to allow spring-integration-test to run
in native mode, as it requires a local GraalVM
native-image installation.
Also changed the UnsupportedConstraintVerifier class from
an anonymous class to an inner class.
…ig to generated method in spring

Finding out why ObjectMapper wasn't before was trickly. The short of it
is that java.lang.Class was registered for reflection, which made
GraalVM think its cachedHashCode field was reachable in an initializer,
which is not allowed. So we needed to make registerTypeRecursively
ignore java.lang.Class and java.lang.ClassLoader. Then ObjectMapper is
happy. I would use SolverConfigIO/JAXB, but JAXB accesses itself using
reflection, so I would need to register a bunch more (possible unstable)
classes for reflections to use it.
The no-args default constructor is not included in "queryAllDeclaredMethods".
Copy link

Quality Gate Passed Quality Gate passed

Issues
2 New issues

Measures
0 Security Hotspots
85.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@triceo triceo merged commit 8462888 into TimefoldAI:main Feb 18, 2024
11 checks passed
@triceo triceo linked an issue Feb 18, 2024 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spring Boot native images
2 participants