[GR-42114] Integrate missing resource metadata #7179
Closed
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 allows to throw
MissingResourceRegistrationError
when the metadata for a resource the user tries to access is not included in the image.The goal is to match this proposal: https://github.com/graalvm/taming-build-time-initialization/blob/main/metadata-exceptions/Exceptions%20proposal.md.
Changes:
The main changes lies in
Resources.java
. We now use a map from aModule
and aString
to anObject
instead of aResourceStorageEntry
. This allows to store a dummy object for negative queries, or an exception for resources and bundles that threw when accessed at build time.Accessing the map:
null
.MissingResourceRegistrationError
.To avoid saving
Regexes
and increasing the image size, only a simple pattern matching is performed using the functionmatchResource
. It only accepts exact matches, or matches with one.*
anywhere in the pattern. If there are more than one.*
, only the last one is used as a wildcard, while the others are treated as normal characters.The agent now registers all resources and bundles encountered, even if it is
null
or caused an exception (see changes inBreakpointInterceptor.java
). Those resources will be saved either as negative queries, or as exceptions that will be thrown at run time.The
LocalizationSupport
now registers intermediate bundles for reflection and resource access. This is needed because, for example, when querying the bundleResourceBundle_en_US
, the bundlesResourceBundle
andResourceBundle_en
are accessed by reflection and queried as well.The
NativeImageResourceFileSystem
now differentiates inodes that are true resources from inodes that are created as placeholders (intermediate directories) or at run time (see NativeImageResourceFileSystem.java).MissingResourceRegistrationError
.MissingResourceRegistrationError
.MissingResourceRegistrationError
is thrown.