8200310: Avoid charset lookup machinery in java.nio.charset.StandardCharsets

Reviewed-by: sherman, ulfzibis
This commit is contained in:
Martin Buchholz 2018-03-28 21:14:06 -07:00
parent 08adfe31b3
commit 4546512c19
11 changed files with 31 additions and 30 deletions

View file

@ -26,7 +26,6 @@
package java.nio.charset;
import jdk.internal.misc.VM;
import sun.nio.cs.StandardCharsets;
import sun.nio.cs.ThreadLocalCoders;
import sun.security.action.GetPropertyAction;
@ -311,7 +310,8 @@ public abstract class Charset
}
/* The standard set of charsets */
private static final CharsetProvider standardProvider = new StandardCharsets();
private static final CharsetProvider standardProvider
= new sun.nio.cs.StandardCharsets();
private static final String[] zeroAliases = new String[0];
@ -609,7 +609,7 @@ public abstract class Charset
if (cs != null)
defaultCharset = cs;
else
defaultCharset = sun.nio.cs.UTF_8.INSTANCE;
defaultCharset = StandardCharsets.UTF_8;
}
}
return defaultCharset;

View file

@ -41,26 +41,26 @@ public final class StandardCharsets {
* Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the
* Unicode character set
*/
public static final Charset US_ASCII = sun.nio.cs.US_ASCII.INSTANCE;
public static final Charset US_ASCII = new sun.nio.cs.US_ASCII();
/**
* ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
*/
public static final Charset ISO_8859_1 = sun.nio.cs.ISO_8859_1.INSTANCE;
public static final Charset ISO_8859_1 = new sun.nio.cs.ISO_8859_1();
/**
* Eight-bit UCS Transformation Format
*/
public static final Charset UTF_8 = sun.nio.cs.UTF_8.INSTANCE;
public static final Charset UTF_8 = new sun.nio.cs.UTF_8();
/**
* Sixteen-bit UCS Transformation Format, big-endian byte order
*/
public static final Charset UTF_16BE = Charset.forName("UTF-16BE");
public static final Charset UTF_16BE = new sun.nio.cs.UTF_16BE();
/**
* Sixteen-bit UCS Transformation Format, little-endian byte order
*/
public static final Charset UTF_16LE = Charset.forName("UTF-16LE");
public static final Charset UTF_16LE = new sun.nio.cs.UTF_16LE();
/**
* Sixteen-bit UCS Transformation Format, byte order identified by an
* optional byte-order mark
*/
public static final Charset UTF_16 = Charset.forName("UTF-16");
public static final Charset UTF_16 = new sun.nio.cs.UTF_16();
}