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

Naoto Sato naoto at openjdk.org
Wed Feb 22 18:22:41 UTC 2023


On Wed, 22 Feb 2023 11:34:59 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template line 217:
>> 
>>> 215:             if (VM.initLevel() < 1) {
>>> 216:                 // Cannot get the system property yet. Assumes non-2000
>>> 217:                 GB18030_2000 = "";
>> 
>> curious - what scenario triggers this call at initLevel < 1 ? would it be better to simply return "false" at that time and leave the GB18030_2000 variable to be set once we're at initLevel >=1  ?  -- or perhaps that would invalidate the workflow of the original caller (which called in at initLevel <1)
>
>> curious - what scenario triggers this call at initLevel < 1 ?
> 
> It's not supported, but it is possible that someone might run with -Dfile.encoding=GB18030, in which case the default charset is used before the system properties are initialized in initPhase1. Checking the init level breaks the circularity, the only downside is that can't switch to GB18030-2000 at the same time.

`Charset` class is initialized *before* system properties are set up, in order to check the JNU encoding (used for file path name) is a supported charset or not. In some OS environments, GB18030 is the native encoding so we need to avoid checking the system property in such a case.

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

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


More information about the i18n-dev mailing list