Skip to content

Commit

Permalink
Add exception to cdsHeapVerifier for new StaticProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
naotoj committed Dec 5, 2023
1 parent 26214cb commit 01b361a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
18 changes: 17 additions & 1 deletion src/hotspot/share/cds/cdsHeapVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,23 @@ CDSHeapVerifier::CDSHeapVerifier() : _archived_objs(0), _problems(0)
// This just points to an empty Map
ADD_EXCL("jdk/internal/reflect/Reflection", "methodFilterMap"); // E
ADD_EXCL("jdk/internal/util/StaticProperty", "FILE_ENCODING", // C
"JAVA_LOCALE_USE_OLD_ISO_CODES"); // C
"JAVA_LOCALE_USE_OLD_ISO_CODES", // C
"USER_LANGUAGE", // C
"USER_LANGUAGE_DISPLAY", // C
"USER_LANGUAGE_FORMAT", // C
"USER_SCRIPT", // C
"USER_SCRIPT_DISPLAY", // C
"USER_SCRIPT_FORMAT", // C
"USER_COUNTRY", // C
"USER_COUNTRY_DISPLAY", // C
"USER_COUNTRY_FORMAT", // C
"USER_VARIANT", // C
"USER_VARIANT_DISPLAY", // C
"USER_VARIANT_FORMAT", // C
"USER_EXTENSIONS", // C
"USER_EXTENSIONS_DISPLAY", // C
"USER_EXTENSIONS_FORMAT", // C
"USER_REGION"); // C

// Integer for 0 and 1 are in java/lang/Integer$IntegerCache and are archived
ADD_EXCL("sun/invoke/util/ValueConversions", "ONE_INT", // E
Expand Down
10 changes: 10 additions & 0 deletions src/java.base/share/classes/java/util/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,13 @@ private static synchronized Locale getFormatLocale() {
return loc;
}

@SuppressWarnings("removal")
private static Locale initDefault() {
String language, region, script, country, variant;
var sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
language = StaticProperty.userLanguage(0);
// for compatibility, check for old user.region property
region = StaticProperty.userRegion();
Expand All @@ -1079,8 +1084,13 @@ private static Locale initDefault() {
.orElse(null));
}

@SuppressWarnings("removal")
private static Locale initDefault(Locale.Category category) {
Locale locale = Locale.defaultLocale;
var sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
return getInstance(
StaticProperty.userLanguage(category.ordinal() + 1),
StaticProperty.userScript(category.ordinal() + 1),
Expand Down
24 changes: 12 additions & 12 deletions src/java.base/share/classes/jdk/internal/util/StaticProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public final class StaticProperty {
private static final String USER_COUNTRY;
private static final String USER_COUNTRY_DISPLAY;
private static final String USER_COUNTRY_FORMAT;
private static final String USER_REGION;
private static final String USER_VARIANT;
private static final String USER_VARIANT_DISPLAY;
private static final String USER_VARIANT_FORMAT;
private static final String USER_EXTENSIONS;
private static final String USER_EXTENSIONS_DISPLAY;
private static final String USER_EXTENSIONS_FORMAT;
private static final String USER_REGION;

private StaticProperty() {}

Expand Down Expand Up @@ -104,13 +104,13 @@ private StaticProperty() {}
USER_COUNTRY = getProperty(props, "user.country", "");
USER_COUNTRY_DISPLAY = getProperty(props, "user.country.display", USER_COUNTRY);
USER_COUNTRY_FORMAT = getProperty(props, "user.country.format", USER_COUNTRY);
USER_REGION = getProperty(props, "user.region", "");
USER_VARIANT = getProperty(props, "user.variant", "");
USER_VARIANT_DISPLAY = getProperty(props, "user.variant.display", USER_VARIANT);
USER_VARIANT_FORMAT = getProperty(props, "user.variant.format", USER_VARIANT);
USER_EXTENSIONS = getProperty(props, "user.extensions", "");
USER_EXTENSIONS_DISPLAY = getProperty(props, "user.extensions.display", USER_EXTENSIONS);
USER_EXTENSIONS_FORMAT = getProperty(props, "user.extensions.format", USER_EXTENSIONS);
USER_REGION = getProperty(props, "user.region", "");
}

private static String getProperty(Properties props, String key) {
Expand Down Expand Up @@ -366,16 +366,6 @@ public static String userCountry(int category) {
};
}

/**
* {@return the {@code user.region} 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 userRegion() {
return USER_REGION;
}

/**
* {@return the {@code user.variant} system property}
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
Expand Down Expand Up @@ -413,4 +403,14 @@ public static String userExtensions(int category) {
default -> throw new InternalError();
};
}

/**
* {@return the {@code user.region} 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 userRegion() {
return USER_REGION;
}
}

0 comments on commit 01b361a

Please sign in to comment.