[GR-60238] Include JNI reachability metadata with reflection #11066
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR merges the
"jni"
section ofreachability-metadata.json
into the"reflection"
section.Semantics
JNI access registration relies on a single
"jniAccessible"
at the class level. When this flag is set, the type as well as any method or field registered for reflection on the type are registered for JNI access as well.On the other hand, classes, fields and methods that are registered for JNI access are now unconditionally registered for reflective access as well. This has no impact on reachability and only adds a limited amount of metadata to the image, which is acceptable.
The metadata file parsers of course still support the
"jni"
section, and the new semantics of"reflection"
, as well as the new"jniAccessible"
flag, will be backported to the previous LTS releases.Example
The following reflection and JNI registration:
can now be expressed with the much simpler:
Configuration merging
Configuration merging will work by first converting any legacy
"jni"
section ofreachability-metadata.json
orjni-config.json
file to the"reflection"
section ofreachability-metadata.json
, and then merging according to the current rules."jniAccessible"
will be set on a merged configuration type if the flag was set on any of the source types.As an example, merging the following
reachability-metadata.json
files:will result in the following
reachability-metadata.json
:PR organization
The PR is organized in two commits, which are best reviewed separately:
Class.forName
-compliant names and names used for JNI queries) and and where each of them is expected in the Native Image configuration handling code, centered around the newClassNameSupport
class.ReflectionMetadataParser
) and in the internal data structures (inConfigurationSet
and related classes).