On Tue, 24 Jan 2023 21:57:25 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> This issue was found during the review of this PR: >> https://github.com/openjdk/jdk/pull/12132 where `Charset` class was >> loaded/initialized at the phase 1 of the startup process. Since `Charset` >> depends on `StaticProperty`, loading of `Charset` class should be delayed. I >> basically moved cache for `jnuCharset` into the actual calling locations >> `ProcessImpl` and `ProcessEnvironment` for unix platforms so that >> initPhase1() won't initialize `Charset` class. >> Unrelated, but I replaced `Locale.ENGLISH` with `Locale.ROOT` in the >> argument of `toLowerCase()`. > > Naoto Sato has updated the pull request incrementally with one additional > commit since the last revision: > > One more. Hello Naoto, > This issue was found during the review of this PR: > https://github.com/openjdk/jdk/pull/12132 where Charset class was > loaded/initialized at the phase 1 of the startup process. Since Charset > depends on StaticProperty >From the comment in that PR: > That said, the change does highlight an issue in StaticProperty. where it > calls Charset.defaultCharset(), which in turn will > StaticProperty.FILE_ENCODING before that class is fully initialized. Looking at the code in `Charset.defaultCharset()` https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/nio/charset/Charset.java#L651, I don't see it using `StaticProperty` class. Instead, it just queries the `System.getProperty()`. I don't see any other methods in `Charset` using `StaticProperty` either. ------------- PR: https://git.openjdk.org/jdk/pull/12171