On Wed, 22 Feb 2023 11:34:59 GMT, Alan Bateman <al...@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