RFR: 8317246: Cleanup java.net.URLEncoder and URLDecoder use of file.encoding property
Roger Riggs
rriggs at openjdk.org
Thu Sep 28 18:13:08 UTC 2023
On Sat, 19 Aug 2023 09:05:47 GMT, Glavo <duke at openjdk.org> wrote:
> `DEFAULT_ENCODING_NAME ` in `URLEncoder` and `URLDecoder` can be replaced with `Charset.defaultCharset()`, which removes unnecessary static fields and avoid looking up charset when calling `URLDecoder.decode(String)` and `URLEncoder.encode(String)`.
>
> This PR is trivial, since `Charset.defaultCharset()` is also initialized with `StaticProperty.fileEncoding()`, this causes no change in behavior.
>
> Moreover, the javadoc of `URLDecoder.decode(String)` and `URLEncoder.encode(String)` say that they use the default charset, so this change is semantically consistent with the documentation.
No big gains here, but it does eliminate a couple of static field initializations and corresponding runtime lookups of the default charset.
If file.encoding is set to COMPAT, it is substituted from native.encoding very early when the system properties are initialized.
BTW, the PR description is quite lacking. It should explain the issue and benefit without having to go read the code.
Write the description with details that would be in the issue.
Created, note change in title.
[8317246](https://bugs.openjdk.org/browse/JDK-8317246) Cleanup java.net.URLEncoder and URLDecoder use of file.encoding property
-------------
Marked as reviewed by rriggs (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15353#pullrequestreview-1647303547
PR Comment: https://git.openjdk.org/jdk/pull/15353#issuecomment-1737880647
PR Comment: https://git.openjdk.org/jdk/pull/15353#issuecomment-1739243247
More information about the net-dev
mailing list