<i18n dev> RFR: 8301119: Support for GB18030-2022 [v2]

Sean Coffey coffeys at openjdk.org
Thu Feb 23 09:51:06 UTC 2023


On Thu, 23 Feb 2023 09:03:49 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Scratch that: as it seems to be important that we don't switch after startup then what this code is really reaching for is `static final` field semantics. Since `StandardCharsets` might be loaded very early a holder class pattern might be necessary:
>> 
>> 
>>     isGB18030_2000() { return GB18030Properties.GB18030_2000; }
>> 
>>     private static class GB18030Properties {
>>         private static final GB18030_2000 = init();
>>         private static boolean init() {
>>             if (VM.initLevel() < 1) {
>>                 // Cannot get the system property yet. Assumes non-2000
>>                 return false;
>>             }
>>             return "2000".equals(GetPropertyAction.privilegedGetProperty("jdk.charset.GB18030"));
>>         }
>>     }
>
> Right, doing nothing for the initLevel < 1 case means that  `-Dfile.encoding=GB18030 -Djdk.charset.GB18030=2000` would use version 2022 in early startup (JNU encoding init) and then switch to version 2000. Using a holder class seems a better idea than trying to coordinate concurrent writers.

would use of jdk.internal.util.SystemProps be an option here (if having to retrieve that value when we're at VM init level <1 ?

-------------

PR: https://git.openjdk.org/jdk/pull/12518


More information about the i18n-dev mailing list