8174831: Reduce number of Charset classes loaded on bootstrap

Reviewed-by: alanb
This commit is contained in:
Claes Redestad 2017-02-13 20:32:06 +01:00
parent bf8ad52b22
commit e17bdd6c77
4 changed files with 29 additions and 21 deletions

View file

@ -46,9 +46,6 @@ import sun.nio.cs.ArrayEncoder;
import static java.lang.String.LATIN1;
import static java.lang.String.UTF16;
import static java.lang.String.COMPACT_STRINGS;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Utility class for string encoding and decoding.
@ -64,6 +61,10 @@ class StringCoding {
private static final ThreadLocal<SoftReference<StringEncoder>> encoder =
new ThreadLocal<>();
private static final Charset ISO_8859_1 = Charset.forName("iso-8859-1");
private static final Charset US_ASCII = Charset.forName("us-ascii");
private static final Charset UTF_8 = Charset.forName("utf-8");
private static boolean warnUnsupportedCharset = true;
private static <T> T deref(ThreadLocal<SoftReference<T>> tl) {