RFR: 8270490: Charset.forName() taking fallback default value [v4]
Naoto Sato
naoto at openjdk.java.net
Tue Oct 26 13:02:16 UTC 2021
On Tue, 26 Oct 2021 10:42:49 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Reflecting review comments
>
> src/java.base/share/classes/java/io/Console.java line 590:
>
>> 588: if (cs == null) {
>> 589: cs = Charset.forName(StaticProperty.nativeEncoding(),
>> 590: Charset.defaultCharset());
>
> I assume that `StaticProperty.nativeEncoding()` will never be `null`? Otherwise an IAE would be thrown here where previously `Charset.defaultCharset()` would be used.
Yes. `StaticProperty.nativeEncoding()` caches the value to `native.encoding` system property. The value is not optional, so it should be considered an error if `StaticProperty.nativeEncoding()` returned `null`.
https://download.java.net/java/early_access/jdk18/docs/api/java.base/java/lang/System.html#native.encoding
-------------
PR: https://git.openjdk.java.net/jdk/pull/6045
More information about the core-libs-dev
mailing list