Integrated: 8272805: Avoid looking up standard charsets

Sergey Bylokhov serb at
Thu Sep 2 22:59:31 UTC 2021

On Sun, 22 Aug 2021 02:53:44 GMT, Sergey Bylokhov <serb at> wrote:

> This is the continuation of JDK-8233884, JDK-8271456, and JDK-8272120.
> In many places standard charsets are looked up via their names, for example:
> absolutePath.getBytes("UTF-8");
> This could be done more efficiently(up to x20 time faster) with use of java.nio.charset.StandardCharsets:
> absolutePath.getBytes(StandardCharsets.UTF_8);
> The later variant also makes the code cleaner, as it is known not to throw UnsupportedEncodingException in contrary to the former variant.
> This change includes:
>  * demo/utils
>  * jdk.xx packages
>  * Some places were missed in the previous changes. I have found it by tracing the calls to the Charset.forName() by executing tier1,2,3 and desktop tests.
> Some performance discussion:
> Code excluded in this fix: the Xerces library(should be fixed upstream), J2DBench(should be compatible to 1.4), some code in the network(the change there are not straightforward, will do it later).
> Tested by the tier1/tier2/tier3 tests on Linux/Windows/macOS.

This pull request has now been integrated.

Changeset: 7fff22af
Author:    Sergey Bylokhov <serb at>
Stats:     364 lines in 53 files changed: 98 ins; 128 del; 138 mod

8272805: Avoid looking up standard charsets

Reviewed-by: weijun, naoto, dfuchs, azvegint, erikj



More information about the compiler-dev mailing list