-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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-30205] Extend the agent to collect the locale and classname of resource bundles. #3557
[GR-30205] Extend the agent to collect the locale and classname of resource bundles. #3557
Conversation
5811da0
to
38c2154
Compare
8b50a6d
to
8eb8a5a
Compare
8778ff7
to
967cf2d
Compare
811a9fb
to
b0cdc3e
Compare
23adb58
to
3155f86
Compare
a398adf
to
6fe6f2f
Compare
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/NativeImageAgentJNIHandleSet.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
...m/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ResourceConfigurationParser.java
Outdated
Show resolved
Hide resolved
...m/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ResourceConfigurationParser.java
Outdated
Show resolved
Hide resolved
...m/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ResourceConfigurationParser.java
Outdated
Show resolved
Hide resolved
...m.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/OptimizedLocalizationSupport.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java
Outdated
Show resolved
Hide resolved
…nfig entry if they are non-empty
bundle basename is only needed for the OptimizedLocalizationSupport support
…upport only if they have the right type
39a892f
to
d516367
Compare
d516367
to
860f582
Compare
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public void addResourceBundles(ConfigurationCondition condition, String basename, Collection<Locale> locales) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is used not only in the image build, but also in the agent and the native-image-configure
images at runtime. Could using Locale
objects here be an issue since these images might not include the locales in question? If so, it would be preferable to use plain strings instead and do any checks during the image build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Fortunately, it should not be a problem - it is possible to create Locale objects even for non-existent locales such as aa-bb-ccccc
. The method parseLocaleFromTag uses the locale tag parsing from JDK, which only cares about the syntatic structure of the tag, again aa-bb-ccccc
works here. And there is also a fallback for handling locales with invalid tags (driven from a test case in the JCK). So creating the Locale objects on their own should not be an issue, even in an image that does not have corresponding locale data included.
bundleNameField.set(bundle, basename); | ||
bundleLocaleField.set(bundle, locale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could setting these fields reflectively break ResourceBundle
implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, it should not. There is no special logic in their getters and setters and in the ResourceBundle class, they are used only during the lookup process which is completely substituted in the optimized mode. There is no suspicious use outside the class either. I am setting them reflectively because they are also set during the lookup, see ResourceBundle.loadLookup. Without setting them, the class bundles in the optimized mode would have no locale and basename associated, which would be inconsistent with the JDK. The whole idea of not instantiating bundles and only preparing their classes for reflection, unfortunately, does not work with the older optimized mode, in which everything is stored in the map at build time, so I have to instantiate them in that scenario anyway.
a17caba
to
f516400
Compare
* ci: upgrade GraalVM versions * ci: fix workflows * fix: add necessary metadata to new versions * fix: support Java 17 * fix: add options to the gu command * fix: support the latest format of ResourceBundleUsage refs oracle/graal#3557 * chore: reformat * fix: stop using Java9 feature for Java8 compatibility Arrays.compare() is not ready to use for Java8 * fix: handle nullness of lists properly * fix: handle nullness of lists properly
This PR extends the resource-config.json configuration file structure and adds two new fields locales and classNames for each bundle. By using these entries one can narrow down which bundles should be included, the default being all selected locales.
Specifying bundles using classNames has the advantage that they don't have to be looked up and instantiated at build time, which can be dangerous.
NativeImageAgent was updated to provide more detailed configuration using classNames.