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

Models implements serializable interface to support native image(GraalVM) #1074

Merged
merged 5 commits into from
Dec 21, 2023

Conversation

nilchina
Copy link
Contributor

Hi guys! When building a native image, the classes under the models package need to be registered in the form of serialization, so they need to implement the serialization interface.

@nilchina
Copy link
Contributor Author

@configuration
@ImportRuntimeHints(MyRuntimeHints.class)
public class MyRuntimeHints implements RuntimeHintsRegistrar {
@OverRide
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.serialization().registerType(org.gitlab4j.api.models.Project.class);
hints.serialization().registerType(org.gitlab4j.api.models.Namespace.class);
//......
}
}

@jmini
Copy link
Collaborator

jmini commented Dec 20, 2023

This is fine for me. I think this PR could target main since I am merging all the changes on main also to 6.x (see #926 (comment))

We have a test class TestGitLabApiBeans to test all the models to JSON serialization and deserialization.
I make sure it stays up to date with each PR.

Probably we could add somewhere a test to make sure each class and its sub-class are implementing Serializable. Otherwise we can often miss one case.

@jmini jmini changed the base branch from 6.x to main December 20, 2023 14:25
@jmini
Copy link
Collaborator

jmini commented Dec 20, 2023

I have made some changes to this PR:

  • to target the main branch.
git rebase --onto origin/main origin/6.x
  • to use 1L as serialVersionUID
  • to add a test in JsonUtils to make sure we catch all the classes that we are converting to JSON (in the tests)

@nilchina please review.


@nilchina Be aware that your local branch 6.x has diverged with the one on the GitHub.
If you need to do one more change on this branch:
I recommend to use git fetch and git reset --hard origin/6.x before doing any local modifications instead of git pull.

@jmini jmini merged commit ad6d8d4 into gitlab4j:main Dec 21, 2023
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.

2 participants