JDK-8269513 : Clarify the spec wrt `useOldISOCodes` system property
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-06-28
  • Updated: 2021-07-15
  • Resolved: 2021-06-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 18
17 b30Fixed 18Fixed
Related Reports
CSR :  
Relates :  
Description
Hebrew/Indonesian/Yiddish ISO 639 language codes failed to work in backward compatible manner even if system property java.locale.useOldISOCodes sets to true.

Code snippet:
import java.util.Locale;
public class Test1 {
    public static void main(String[] args) {
        System.setProperty("java.locale.useOldISOCodes","true");
        new Test1().test();
    }
    String languages[] = new String[]{"he", "yi", "id"};
    String excepted[] = new String[]{"iw", "ji", "in"};
    private void test() {
        Locale locale = null;
        for (int i = 0; i < languages.length; i++) {
            locale = new Locale(languages[i]);
            if (excepted[i] != null) {
                if (!locale.getLanguage().equals(excepted[i])) {
                    System.out.println(
                            "getLanguage returned wrong value : "
                                    + locale.getLanguage()
                                    + " language = " + excepted[i]
                    );
                }
            }
        }
    }
} 
Comments
Changeset: 3e022247 Author: Naoto Sato <naoto@openjdk.org> Date: 2021-06-30 22:11:58 +0000 URL: https://git.openjdk.java.net/jdk17/commit/3e022247d2e80c43393bfdb5888b03210c6975d3
30-06-2021

The system property is read at the runtime startup, so later alteration with setProperty() won't work. Will need to clarify it in the spec.
28-06-2021

As per updated spec : ====== "Locale's constructor has always converted three language codes to their earlier, obsoleted forms: he maps to iw, yi maps to ji, and id maps to in. Since Java SE 17, this is no longer the case. Each language maps to its new form; iw maps to he, ji maps to yi, and in maps to id. For the backward compatible behavior, the system property java.locale.useOldISOCodes reverts the behavior back to prior to Java SE 17 one. If the system property is set to true, those three current language codes are mapped to their backward compatible forms. ===== As understand, the earlier behavior ( behavior before this CSR) should be honored when the property java.locale.useOldISOCodes set to true. But the observation is not as per this. [~naoto] Please comment on this.
28-06-2021