RFR: 8260265: UTF-8 by Default [v2]
Naoto Sato
naoto at openjdk.java.net
Wed Jul 14 21:02:06 UTC 2021
On Wed, 14 Jul 2021 14:55:39 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Naoto Sato has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>>
>> - Reflects review comments
>> - Merge branch 'master' into JDK-8260265
>> - 8260265: UTF-8 by Default
>
> src/java.base/share/classes/java/io/Console.java line 587:
>
>> 585: try {
>> 586: cs = Charset.forName(csname);
>> 587: } catch (Exception ignored) { }
>
> A separate enhancement...
> I've long thought that should be a way to avoid the exception here.
> For example, a Charset.forName(csname, default);
> The caller might have a default in mind or supply null and then be able to test for null.
Agreed. Will file an RFE for this.
> src/java.base/share/classes/java/io/FileReader.java line 41:
>
>> 39: * @see InputStreamReader
>> 40: * @see FileInputStream
>> 41: * @see java.nio.charset.Charset#defaultCharset()
>
> The @ see duplicates the link above, the javadoc can do without the @ see.
If I remove that `@see`, I don't see the link in `See Also` section. Am I missing something?
> src/java.base/share/classes/java/lang/System.java line 802:
>
>> 800: * <tr><th scope="row">{@systemProperty file.encoding}</th>
>> 801: * <td>The name of the default charset. Users may specify
>> 802: * {@code UTF-8} or {@code COMPAT} on the command line to the value.
>
> The wording could imply that only those two values can be supplied.
> It could be rephrased to say that *if* the property is supplied on the command line
> it overrides the default UTF-8.
That was intentional. Only those two are supported, others continue to work as before (but not supported).
> src/java.base/share/classes/java/nio/charset/Charset.java line 601:
>
>> 599: * value designates {@code COMPAT}, the default charset is derived from
>> 600: * the {@code native.encoding} system property, which typically depends
>> 601: * upon the locale and charset of the underlying operating system.
>
> The description in java.lang.System of the file.encoding property does not indicate it is 'implementation specific'.
> In that context, it appears to be part of the JavaSE spec.
> Having the spec in a single place with references to it from others could avoid duplication.
`file.encoding` is listed under `@implNote` tag in `System.getProperties()`, so it is implementation-specific.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4733
More information about the net-dev
mailing list