On Sat, 23 Oct 2021 19:29:30 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> Just an idea, should we check that the second parameter is null or not? Any 
> pros and cons of that? For example should this code be allowed:
> 
> ```
> var cs = Charset.forName(charsetName, null);
> if (cs == null) {
>    System.err.println("Used UTF-8 encoding instead of "+charsetName+");
>    cs = StandardCharsets.UTF_8;
> }
> ```

Yes, that's the whole purpose of allowing `null` for `fallback`.

> src/java.base/share/classes/java/io/Console.java line 589:
> 
>> 587:         }
>> 588:         if (cs == null) {
>> 589:             cs = Charset.forName(StaticProperty.nativeEncoding(), 
>> Charset.defaultCharset());
> 
> Not sure but looks like this class tries to maintain 80 chars per line rule?

Fixed.

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

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

Reply via email to