RFR: 8275007: Java fails to start with null charset if LC_ALL is set to certain locales [v3]

Alan Bateman alanb at openjdk.java.net
Sat Nov 13 19:30:35 UTC 2021


On Fri, 12 Nov 2021 19:11:07 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> Please review the subject fix. In light of JEP400, Java runtime can/should start in UTF-8 charset if the underlying native encoding is not supported.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Force the jnu encoding to UTF-8 if the original one is not supported

src/java.base/share/classes/java/lang/System.java line 2127:

> 2125:             props.setProperty("sun.jnu.encoding", "UTF-8");
> 2126:         }
> 2127: 

You could replace the two fields with something like "notSupportedJnuEncoding" that is only set when not supported. That keeps the additional code in initPhase1 to a minimum.

src/java.base/share/classes/java/lang/System.java line 2267:

> 2265:                     "WARNING: The encoding of the underlying platform's" +
> 2266:                             " file system is not supported by the JVM: %s%n",
> 2267:                     jnuEncoding);

I think you can drop "by the JVM" from the warning. 

Also just to point out that this is running in initPhase3. I'm pretty sure the use of formatters here will execute code that checks VM.isBooted. It might be better to just use string concatenation and avoid loading formatters here.

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

PR: https://git.openjdk.java.net/jdk/pull/6282


More information about the core-libs-dev mailing list