Skip to content

Fixed Issue #392 ResourceBundle.Control not supported in named modules #393

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hipparchus-core/src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ If the output is not quite correct, check for invisible trailing spaces!
<title>Hipparchus Core Release Notes</title>
</properties>
<body>
<action dev="emeric" type="fix" issue="issues/392">
Fixed default Localizable.getLocalizedString when running on module path.
</action>
<release version="4.0.1" date="2025-03-21" description="This is a patch release.">
<action dev="luc" type="fix" issue="issues/386">
Restores a Java 8 compatible mockito version, which is used only for tests purposes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ public interface Localizable extends Serializable {
default String getLocalizedString(final String baseName, final String key, final Locale locale) {

try {
final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, new UTF8Control());
ResourceBundle bundle;
try {
bundle = ResourceBundle.getBundle(baseName, locale, new UTF8Control());
}
catch (UnsupportedOperationException uoe) {
// fix for Java 9+ on module path
// (see issue https://github.com/Hipparchus-Math/hipparchus/issues/392)
bundle = ResourceBundle.getBundle(baseName, locale);
}

if (bundle.getLocale().getLanguage().equals(locale.getLanguage()))
{
final String translated = bundle.getString(key);
Expand Down