RFR: 8265989: System property for the native character encoding name
Naoto Sato
naoto at openjdk.java.net
Thu Apr 29 13:14:52 UTC 2021
On Thu, 29 Apr 2021 07:17:26 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> After some internal discussion, we thought it was good to expose the native environment's default character encoding, which Charset.defaultCharset() is currently based on. This way applications will have a better migration path after the [JEP 400](https://openjdk.java.net/jeps/400) is implemented, in which Charset.defaultCharset() will return UTF-8, but the value of this new system property will remain intact. A [CSR](https://bugs.openjdk.java.net/browse/JDK-8266075) has been filed with more detailed information.
>
> src/java.base/share/classes/jdk/internal/util/SystemProps.java line 69:
>
>> 67: ? raw.propDefault(Raw._sun_jnu_encoding_NDX)
>> 68: : raw.propDefault(Raw._file_encoding_NDX));
>> 69: put(props, "native.encoding", nativeEncoding);
>
> Shouldn't native.encoding be biased toward sun.jnu.encoding rather than file.encoding? Or maybe you'll change it when preparing the changes for JEP 400?
`native.encoding` preserves the encoding that current `Charset.defaultCharset()` is returning, which is based on `file.encoding`. So I believe the current implementation is correct. If it is biased toward `sun.jnu.encoding`, it would be problematic especially on Windows where that represents `system locale`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3777
More information about the core-libs-dev
mailing list