On Tue, 27 Jan 2026 10:44:42 GMT, Eirik Bjørsnøs <[email protected]> wrote:

> Please review this PR which removes a dependency on 
> `java.nio.charset.StandardCharsets` introduced in 
> [JDK-8365703](https://bugs.openjdk.org/browse/JDK-8365703).
> 
> We can use `UTF_8.INSTANCE` here as elsewhere in this class to prevent 
> startup regression loading otherwise unused classes and charsets.
> 
> Verified that running `java -cp hello.jar Hello` observes the following diff 
> in loaded classes when run with this PR:
> 
> 
> < java.nio.charset.StandardCharsets
> < sun.nio.cs.US_ASCII
> < sun.nio.cs.ISO_8859_1
> < sun.nio.cs.UTF_16BE
> < sun.nio.cs.UTF_16LE
> < sun.nio.cs.UTF_16
> < sun.nio.cs.UTF_32BE
> < sun.nio.cs.UTF_32LE
> < sun.nio.cs.UTF_32
> 
> 
> This is a strict refactoring, no tests updated, `noreg-trivial`.

There was effort a few years ago to push out the first use of StandardCharsets 
as its initializer loaded all the standard charsets. So this is why you will 
have seen usages replaced with (mostly) UTF_8.INSTANCE. This was all before 
Project Leyden and the recent work on AOT. It would be useful to do some 
measurements to see if this change shows any benefit.

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

PR Comment: https://git.openjdk.org/jdk/pull/29443#issuecomment-3949805217

Reply via email to