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

Jersey does not supply "commonly used" native image reflection metadata #9510

Closed
ljnelson opened this issue Nov 19, 2024 · 1 comment · Fixed by #9441
Closed

Jersey does not supply "commonly used" native image reflection metadata #9510

ljnelson opened this issue Nov 19, 2024 · 1 comment · Fixed by #9441

Comments

@ljnelson
Copy link
Member

ljnelson commented Nov 19, 2024

A Jersey-based (Helidon MP) application running in native image may need to deal with @PathParam objects of type String, Integer, etc. (or a user-created type). To work with them successfully, Jersey will in many codepaths call their single-String-argument constructors reflectively. Jersey does not supply the relevant reflect-config.json metadata for such invocations. End users may see stack traces similar to the following:

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public java.lang.String(java.lang.String) without it being registered for runtime reflection. Add public java.lang.String(java.lang.String) to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.

The Helidon team's opinion is that—rather than the end user having to follow this advice—Jersey should supply metadata for "commonly used" types, for some value of "commonly used", which might be as simple as "types in java.lang that feature single-String-argument constructors", so that the most basic of JAX-RS applications will work, hopefully, out of the box. This may end up being true as well for static valueOf(String) methods and the like.

In the meantime, Helidon should add this, and/or similar, information to our jersey/server reflect-config.json file.

@ljnelson
Copy link
Member Author

See #9441, which introduces this resource as described.

@github-project-automation github-project-automation bot moved this from Triage to Closed in Backlog Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant