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

The format of the reachability metadata identified in the NativeImage tool does not match the description of the document #10088

Closed
SWQXDBA opened this issue Nov 14, 2024 · 1 comment
Labels
tools Relating to Truffle Tools (CPUSampler, Coverage tool, etc)

Comments

@SWQXDBA
Copy link

SWQXDBA commented Nov 14, 2024

https://www.graalvm.org/latest/reference-manual/native-image/metadata/
In the documentation, we are told to write this information to a file META-INF/native-image///reachability-metadata.json.Like this:

{
  "reflection": [
    {
      "type": "reflectively.accessed.Type",
      "fields": [
        {
          "name": "field1"
        }
      ],
      "methods": [
        {
          "name": "method1",
          "parameterTypes": ["<param-type1>", "<param-typeI>", "<param-typeN>"] 
        }
      ],
      "allDeclaredConstructors": true,
      "allPublicConstructors": true,
      "allDeclaredFields": true,
      "allPublicFields": true,
      "allDeclaredMethods": true,
      "allPublicMethods": true,
      "unsafeAllocated": true
    }
  ],
  "jni": [
    {
      "type": "jni.accessed.Type",
      "fields": [
        {
          "name": "field1"
        }
      ],
      "methods": [
        {
          "name": "method1",
          "parameterTypes": ["<param-type1>", "<param-typeI>", "<param-typeN>"]
        }
      ],
      "allDeclaredConstructors": true,
      "allPublicConstructors": true,
      "allDeclaredFields": true,
      "allPublicFields": true,
      "allDeclaredMethods": true,
      "allPublicMethods": true
    }
  ],
  "resources": [
    {
      "module": "optional.module.of.a.resource",
      "glob": "path1/level*/**"
    }
  ],
  "bundles": [
    {
      "name": "fully.qualified.bundle.name",
      "locales": ["en", "de", "other_optional_locales"]
    }
  ],
  "serialization": [
    {
      "type": "serialized.Type",
      "customTargetConstructorClass": "optional.serialized.super.Type"
    }
  ]
}

but I've found that this isn't the case for the various frameworks.

https://github.com/oracle/graalvm-reachability-metadata/tree/master/metadata/com.graphql-java/graphql-java/19.2

I found that each of these entries was put into a separate json file.
index.json
reflect-config.json
resource-config.json

Which format is the correct one? Is there something missing/wrong in the document? Or is there more than one supported format, but it's not stated in the documentation

@SWQXDBA SWQXDBA added the tools Relating to Truffle Tools (CPUSampler, Coverage tool, etc) label Nov 14, 2024
@zakkak
Copy link
Collaborator

zakkak commented Nov 14, 2024

Hello @SWQXDBA, the reachability-metadata format is the correct and most recent (introduced in GraalVM for JDK 23 with #9048) one.

The separated json config files you mention are still supported but now considered legacy.

The reason the frameworks haven't adopted the new format is because older GraalVM versions, like GraalVM for JDK 21, do not support it yet. The plan is to backport the code required to support the new format in older GraalVM versions (only the LTS ones, see graalvm/graalvm-community-jdk21u#23 and #9671) in the hopes that frameworks will gradually transition to the new format.

HTH

@zakkak zakkak closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relating to Truffle Tools (CPUSampler, Coverage tool, etc)
Projects
None yet
Development

No branches or pull requests

2 participants