JDK-8200310 cleaned up java.nio.charset.StandardCharsets to not use Charset.forName, but also removed the optimization to have unconditionally loaded charsets set up static INSTANCE constants, which means that many systems the java.nio.charset.StandardCharsets will be initialized in System.initPhase1.

This should be avoided since at this point the VM is just booting up and any code executed delays initialization of JIT etc.

Webrev: http://cr.openjdk.java.net/~redestad/8201179/open.00/
Bug: https://bugs.openjdk.java.net/browse/JDK-8201179

This patch makes all the constants in j.n.c.StandardCharsets use new INSTANCE fields of each respective Charset and adds some comments as to why they exist.

I also think we should avoid depending on j.n.c.StandardCharsets within java.base as to not accidentally execute more code in initPhase1 than absolutely necessary, so I've changed uses in core packages (java.lang, java.util, java.zip...) to use the internal alternative.



Reply via email to