mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8201179: Regression due loading java.nio.charset.StandardCharsets during bootstrap
Reviewed-by: sherman, martin
This commit is contained in:
parent
370977cf4f
commit
c40af49970
7 changed files with 33 additions and 16 deletions
|
@ -39,6 +39,8 @@ public class ISO_8859_1
|
|||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
public static final ISO_8859_1 INSTANCE = new ISO_8859_1();
|
||||
|
||||
public ISO_8859_1() {
|
||||
super("ISO-8859-1", StandardCharsets.aliases_ISO_8859_1());
|
||||
}
|
||||
|
|
|
@ -83,9 +83,9 @@ public class StandardCharsets extends CharsetProvider {
|
|||
Map<String,Charset> map = cache;
|
||||
if (map == null) {
|
||||
map = new Cache();
|
||||
map.put("utf-8", java.nio.charset.StandardCharsets.UTF_8);
|
||||
map.put("iso-8859-1", java.nio.charset.StandardCharsets.ISO_8859_1);
|
||||
map.put("us-ascii", java.nio.charset.StandardCharsets.US_ASCII);
|
||||
map.put("utf-8", UTF_8.INSTANCE);
|
||||
map.put("iso-8859-1", ISO_8859_1.INSTANCE);
|
||||
map.put("us-ascii", US_ASCII.INSTANCE);
|
||||
map.put("utf-16", java.nio.charset.StandardCharsets.UTF_16);
|
||||
map.put("utf-16be", java.nio.charset.StandardCharsets.UTF_16BE);
|
||||
map.put("utf-16le", java.nio.charset.StandardCharsets.UTF_16LE);
|
||||
|
@ -122,15 +122,19 @@ public class StandardCharsets extends CharsetProvider {
|
|||
private Charset lookup(String charsetName) {
|
||||
init();
|
||||
|
||||
// By checking these built-ins we can avoid initializing Aliases and
|
||||
// Classes eagerly during bootstrap
|
||||
// By checking these built-ins we can avoid initializing Aliases,
|
||||
// Classes and Cache eagerly during bootstrap.
|
||||
//
|
||||
// Initialization of java.nio.charset.StandardCharsets should be
|
||||
// avoided here to minimize time spent in System.initPhase1, as it
|
||||
// may delay initialization of performance critical VM subsystems.
|
||||
String csn;
|
||||
if (charsetName.equals("UTF-8")) {
|
||||
return java.nio.charset.StandardCharsets.UTF_8;
|
||||
return UTF_8.INSTANCE;
|
||||
} else if (charsetName.equals("US-ASCII")) {
|
||||
return java.nio.charset.StandardCharsets.US_ASCII;
|
||||
return US_ASCII.INSTANCE;
|
||||
} else if (charsetName.equals("ISO-8859-1")) {
|
||||
return java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
return ISO_8859_1.INSTANCE;
|
||||
} else {
|
||||
csn = canonicalize(toLower(charsetName));
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ public class US_ASCII
|
|||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
public static final US_ASCII INSTANCE = new US_ASCII();
|
||||
|
||||
public US_ASCII() {
|
||||
super("US-ASCII", StandardCharsets.aliases_US_ASCII());
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ import java.nio.charset.CodingErrorAction;
|
|||
*/
|
||||
|
||||
public final class UTF_8 extends Unicode {
|
||||
|
||||
public static final UTF_8 INSTANCE = new UTF_8();
|
||||
|
||||
public UTF_8() {
|
||||
super("UTF-8", StandardCharsets.aliases_UTF_8());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue