< prev index next >

src/java.base/share/classes/java/nio/charset/Charset.java

Print this page
rev 17470 : 8184665: Skip name and alias checks for standard Charsets
Reviewed-by: sherman, rriggs, forax

*** 23,32 **** --- 23,37 ---- * questions. */ package java.nio.charset; + import jdk.internal.misc.VM; + import sun.nio.cs.StandardCharsets; + import sun.nio.cs.ThreadLocalCoders; + import sun.security.action.GetPropertyAction; + import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.spi.CharsetProvider; import java.security.AccessController; import java.security.PrivilegedAction;
*** 36,54 **** import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; - import java.util.Set; - import java.util.ServiceLoader; import java.util.ServiceConfigurationError; import java.util.SortedMap; import java.util.TreeMap; - import jdk.internal.misc.VM; - import sun.nio.cs.StandardCharsets; - import sun.nio.cs.ThreadLocalCoders; - import sun.security.action.GetPropertyAction; /** * A named mapping between sequences of sixteen-bit Unicode <a * href="../../lang/Character.html#unicode">code units</a> and sequences of --- 41,55 ---- import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; import java.util.ServiceConfigurationError; + import java.util.ServiceLoader; + import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; /** * A named mapping between sequences of sixteen-bit Unicode <a * href="../../lang/Character.html#unicode">code units</a> and sequences of
*** 633,646 **** * * @throws IllegalCharsetNameException * If the canonical name or any of the aliases are illegal */ protected Charset(String canonicalName, String[] aliases) { - checkName(canonicalName); String[] as = Objects.requireNonNullElse(aliases, zeroAliases); ! for (int i = 0; i < as.length; i++) checkName(as[i]); this.name = canonicalName; this.aliases = as; } /** --- 634,656 ---- * * @throws IllegalCharsetNameException * If the canonical name or any of the aliases are illegal */ protected Charset(String canonicalName, String[] aliases) { String[] as = Objects.requireNonNullElse(aliases, zeroAliases); ! ! // Skip checks for the standard, built-in Charsets we always load ! // during initialization. Use of identity is intentional to be ! // consistent with sun.nio.cs.StandardCharsets ! if (canonicalName != StandardCharsets.ISO_8859_1 ! && canonicalName != StandardCharsets.US_ASCII ! && canonicalName != StandardCharsets.UTF_8) { ! checkName(canonicalName); ! for (int i = 0; i < as.length; i++) { checkName(as[i]); + } + } this.name = canonicalName; this.aliases = as; } /**
< prev index next >