mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8295232: "java.locale.useOldISOCodes" property is read lazily
Reviewed-by: lancea, bpb, iris, rriggs, coffeys
This commit is contained in:
parent
3b3438752c
commit
4224d45132
3 changed files with 70 additions and 3 deletions
|
@ -55,6 +55,7 @@ public final class StaticProperty {
|
|||
private static final String JAVA_PROPERTIES_DATE;
|
||||
private static final String SUN_JNU_ENCODING;
|
||||
private static final Charset jnuCharset;
|
||||
private static final String JAVA_LOCALE_USE_OLD_ISO_CODES;
|
||||
|
||||
private StaticProperty() {}
|
||||
|
||||
|
@ -74,6 +75,7 @@ public final class StaticProperty {
|
|||
JAVA_PROPERTIES_DATE = getProperty(props, "java.properties.date", null);
|
||||
SUN_JNU_ENCODING = getProperty(props, "sun.jnu.encoding");
|
||||
jnuCharset = Charset.forName(SUN_JNU_ENCODING, Charset.defaultCharset());
|
||||
JAVA_LOCALE_USE_OLD_ISO_CODES = getProperty(props, "java.locale.useOldISOCodes", "");
|
||||
}
|
||||
|
||||
private static String getProperty(Properties props, String key) {
|
||||
|
@ -243,4 +245,15 @@ public final class StaticProperty {
|
|||
public static Charset jnuCharset() {
|
||||
return jnuCharset;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the {@code java.locale.useOldISOCodes} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*/
|
||||
public static String javaLocaleUseOldISOCodes() {
|
||||
return JAVA_LOCALE_USE_OLD_ISO_CODES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
package sun.util.locale;
|
||||
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.util.StaticProperty;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.StringJoiner;
|
||||
|
@ -101,9 +101,10 @@ public final class BaseLocale {
|
|||
|
||||
/**
|
||||
* Boolean for the old ISO language code compatibility.
|
||||
* The system property "java.locale.useOldISOCodes" is not security sensitive,
|
||||
* so no need to ensure privileged access here.
|
||||
*/
|
||||
private static final boolean OLD_ISO_CODES = GetPropertyAction.privilegedGetProperties()
|
||||
.getProperty("java.locale.useOldISOCodes", "false")
|
||||
private static final boolean OLD_ISO_CODES = StaticProperty.javaLocaleUseOldISOCodes()
|
||||
.equalsIgnoreCase("true");
|
||||
|
||||
// This method must be called with normalize = false only when creating the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue