RFR: 8376483: Avoid loading java.nio.charset.StandardCharsets in java.util.zip.ZipCoder
Eirik Bjørsnøs
eirbjo at openjdk.org
Tue Feb 24 14:05:49 UTC 2026
On Tue, 24 Feb 2026 07:39:10 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> 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.
We could certainly do measurements. However; the use of `StandardCharsets` was introduced last August via #26822. Before that change `ZipCoder` used strictly `UTF_8.INSTANCE`. That PR did not mention `StandardCharsets` or any motivation for introducing it. To me, this looked like a simple oversight.
I don't have strong opinions of whether we should use `UTF_8.INSTANCE` or `StandardCharsets`, but would prefer if we can be consistent in this class/area and that any choice is deliberate and not just something slipped in sideways.
In other words, I think the burden of proof should be on #26822 for introducing `StandardCharsets.UTF_8.INSTANCE` in a class that otherwise uses `UTF_8.INSTANCE`, not for this PR reestablishing consistency and long time practise.
But again, opinions loosely help, I can surely withdraw this PR if that's consenus, even if I don't quite understand why :-)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29443#issuecomment-3952119241
More information about the core-libs-dev
mailing list