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

[GR-51064] Inspecting and Testing the Reachability Metadata used in Native-Image Builds #7482

Open
vjovanov opened this issue Sep 23, 2023 · 0 comments

Comments

@vjovanov
Copy link
Member

TL;DR

When building a native image, the user has no information about the elements that were included via the reachability metadata. This makes debugging and testing of reachability metadata hard.

To fix this, we will output all of the reachability metadata in the JSON format together with the image build. Each element in the reachability metadata will have an additional field reasons which contains the list of string reasons for the addition of this element. For example, a method can be added for multiple reasons which will be displayed in the output reflect-config.json as follows:

{
    "reasons": [ "app.Feature#beforeAnalysis", "jar://<path>/app.jar!META-INF/native-image/lib/reflect-config.json" ],
    "name": "sun.misc.Unsafe"
}

The reasons can be the following:

  1. The element was added via a JSON file. In this case, the displayed reason will be the path to the file.
  2. The element was added via a feature. In this case, the feature fully-qualified name will be displayed.
  3. The element was added by analyzing patterns in the user code. In this case, the message displays the class and method where the method was included.
  4. The element was included in the image heap. In this case, the message will display simply "Included in the image heap"

If the files are large, or the output is computationally complex, his feature could be placed behind a flag.

Goals

  1. Make it easy to understand the reachability metadata of a project.
  2. Make it possible to write tests for the reachability metadata.
  3. Make it easy to debug problems with missing metadata in third-party programs.

Non-Goals

  1. Make the image build slower.
  2. Use the produced data in another image build.
  3. Expose user-sensitive information in the output files.
@vjovanov vjovanov added this to the Planned for the Future milestone Sep 23, 2023
@vjovanov vjovanov self-assigned this Sep 23, 2023
@vjovanov vjovanov changed the title Inspecting and Testing the Reachability Metadata used for Native-Image Builds Inspecting and Testing the Reachability Metadata used in Native-Image Builds Sep 24, 2023
@fniephaus fniephaus moved this to In Progress in GraalVM Community Roadmap Feb 27, 2024
@spavlusieva spavlusieva modified the milestones: Planned for the Future, GraalVM for JDK 25 Apr 30, 2024
@fniephaus fniephaus modified the milestones: GraalVM for JDK 25, GraalVM for JDK 25 (September 16, 2025) Apr 30, 2024
@vjovanov vjovanov changed the title Inspecting and Testing the Reachability Metadata used in Native-Image Builds [GR-51064] Inspecting and Testing the Reachability Metadata used in Native-Image Builds Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

3 participants