-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8355522: Remove the java.locale.useOldISOCodes system property
#26419
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,6 @@ | |
|
|
||
| import jdk.internal.misc.CDS; | ||
| import jdk.internal.util.ReferencedKeySet; | ||
| import jdk.internal.util.StaticProperty; | ||
| import jdk.internal.vm.annotation.Stable; | ||
|
|
||
| import java.util.StringJoiner; | ||
|
|
@@ -110,16 +109,14 @@ public ReferencedKeySet<BaseLocale> get() { | |
| private @Stable int hash; | ||
|
|
||
| /** | ||
| * Boolean for the old ISO language code compatibility. | ||
| * The system property "java.locale.useOldISOCodes" is not security sensitive, | ||
| * so no need to ensure privileged access here. | ||
| * Emit the warning message if the system property "java.locale.useOldISOCodes" is | ||
| * specified. | ||
| */ | ||
| private static final boolean OLD_ISO_CODES = StaticProperty.javaLocaleUseOldISOCodes() | ||
| .equalsIgnoreCase("true"); | ||
| static { | ||
| if (OLD_ISO_CODES) { | ||
| System.err.println("WARNING: The use of the system property \"java.locale.useOldISOCodes\"" + | ||
| " is deprecated. It will be removed in a future release of the JDK."); | ||
| if (!System.getProperty("java.locale.useOldISOCodes", "").isEmpty()) { | ||
| System.err.println("WARNING: The system property" + | ||
| " \"java.locale.useOldISOCodes\" is no longer supported." + | ||
| " Any specified value will be ignored."); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -183,9 +180,9 @@ public static BaseLocale getInstance(String language, String script, | |
|
|
||
| public static String convertOldISOCodes(String language) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was there before this change, but above on line 166 I think we should update the outdated comment,
|
||
| return switch (language) { | ||
| case "he", "iw" -> OLD_ISO_CODES ? "iw" : "he"; | ||
| case "id", "in" -> OLD_ISO_CODES ? "in" : "id"; | ||
| case "yi", "ji" -> OLD_ISO_CODES ? "ji" : "yi"; | ||
| case "iw" -> "he"; | ||
| case "in" -> "id"; | ||
| case "ji" -> "yi"; | ||
| default -> language; | ||
| }; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ | |
|
|
||
| /* | ||
| * @test | ||
| * @bug 8295232 8353118 | ||
| * @bug 8295232 8353118 8355522 | ||
| * @summary Tests for the "java.locale.useOldISOCodes" system property | ||
| * @library /test/lib | ||
| * @run junit UseOldISOCodesTest | ||
|
|
@@ -34,7 +34,7 @@ | |
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
|
||
| public class UseOldISOCodesTest { | ||
|
|
||
|
|
@@ -44,20 +44,19 @@ public void testUseOldISOCodes() throws Exception { | |
| .outputTo(System.out) | ||
| .errorTo(System.err); | ||
| oa.shouldHaveExitValue(0); | ||
| oa.stderrShouldMatch("WARNING: The use of the system property \"java.locale.useOldISOCodes\" is deprecated. It will be removed in a future release of the JDK."); | ||
| oa.stderrShouldMatch("WARNING: The system property \"java.locale.useOldISOCodes\" is no longer supported. Any specified value will be ignored."); | ||
| } | ||
|
|
||
| static class Runner { | ||
| private static final String obsoleteCode = "iw"; | ||
| private static final String newCode = "he"; | ||
|
|
||
| public static void main(String[] args) { | ||
| // Ensure java.locale.useOldISOCodes is only interpreted at runtime startup | ||
| // Should have no effect | ||
| // Ensure java.locale.useOldISOCodes should have no effect | ||
| System.setProperty("java.locale.useOldISOCodes", "false"); | ||
|
||
| Locale locale = Locale.of(newCode); | ||
| assertEquals(obsoleteCode, locale.getLanguage(), | ||
| "newCode 'he' was not mapped to 'iw' with useOldISOCodes=true"); | ||
| assertNotEquals(obsoleteCode, locale.getLanguage(), | ||
| "newCode 'he' was mapped to 'iw' with useOldISOCodes=true"); | ||
| } | ||
| } | ||
| } | ||
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 history was relevant when the property existed. Since this is no longer the case, and we're quite a few releases away from 17, can we also remove this wording as well. Users on 26 should only be concerned with the "old" to "modern" mapping.
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 point. Modified the unnecesarry history.