mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8185496
: Improve performance of system properties initialization in initPhase1
8213424: VersionProps duplicate and skipped initialization Reviewed-by: mchung, redestad, dholmes
This commit is contained in:
parent
1b20a6781f
commit
29e742273e
12 changed files with 311 additions and 184 deletions
|
@ -802,6 +802,7 @@ public final class System {
|
|||
if (props == null) {
|
||||
props = new Properties();
|
||||
initProperties(props);
|
||||
VersionProps.init(props);
|
||||
}
|
||||
System.props = props;
|
||||
}
|
||||
|
@ -1973,6 +1974,7 @@ public final class System {
|
|||
// be put into it directly.
|
||||
props = new Properties(84);
|
||||
initProperties(props); // initialized by the VM
|
||||
VersionProps.init(props);
|
||||
|
||||
// There are certain system configurations that may be controlled by
|
||||
// VM options such as the maximum amount of direct memory and
|
||||
|
@ -1992,7 +1994,6 @@ public final class System {
|
|||
|
||||
lineSeparator = props.getProperty("line.separator");
|
||||
StaticProperty.javaHome(); // Load StaticProperty to cache the property values
|
||||
VersionProps.init();
|
||||
|
||||
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
|
||||
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.io.PrintStream;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
class VersionProps {
|
||||
|
||||
|
@ -69,17 +70,13 @@ class VersionProps {
|
|||
(VENDOR_VERSION_STRING.length() > 0
|
||||
? " " + VENDOR_VERSION_STRING : "");
|
||||
|
||||
static {
|
||||
init();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
System.setProperty("java.version", java_version);
|
||||
System.setProperty("java.version.date", java_version_date);
|
||||
System.setProperty("java.runtime.version", java_runtime_version);
|
||||
System.setProperty("java.runtime.name", java_runtime_name);
|
||||
public static void init(Properties props) {
|
||||
props.setProperty("java.version", java_version);
|
||||
props.setProperty("java.version.date", java_version_date);
|
||||
props.setProperty("java.runtime.version", java_runtime_version);
|
||||
props.setProperty("java.runtime.name", java_runtime_name);
|
||||
if (VENDOR_VERSION_STRING.length() > 0)
|
||||
System.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
props.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
}
|
||||
|
||||
private static int parseVersionNumber(String version, int prevIndex, int index) {
|
||||
|
|
|
@ -199,17 +199,16 @@ public class VM {
|
|||
// by the vm option -XX:MaxDirectMemorySize=<size>.
|
||||
// The maximum amount of allocatable direct buffer memory (in bytes)
|
||||
// from the system property sun.nio.MaxDirectMemorySize set by the VM.
|
||||
// If not set or set to -1, the max memory will be used
|
||||
// The system property will be removed.
|
||||
String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
|
||||
if (s != null) {
|
||||
if (s.equals("-1")) {
|
||||
// -XX:MaxDirectMemorySize not given, take default
|
||||
directMemory = Runtime.getRuntime().maxMemory();
|
||||
} else {
|
||||
long l = Long.parseLong(s);
|
||||
if (l > -1)
|
||||
directMemory = l;
|
||||
}
|
||||
if (s == null || s.isEmpty() || s.equals("-1")) {
|
||||
// -XX:MaxDirectMemorySize not given, take default
|
||||
directMemory = Runtime.getRuntime().maxMemory();
|
||||
} else {
|
||||
long l = Long.parseLong(s);
|
||||
if (l > -1)
|
||||
directMemory = l;
|
||||
}
|
||||
|
||||
// Check if direct buffers should be page aligned
|
||||
|
|
|
@ -211,7 +211,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
|||
PUTPROP(props, "java.specification.vendor",
|
||||
JAVA_SPECIFICATION_VENDOR);
|
||||
|
||||
PUTPROP(props, "java.version", VERSION_SHORT);
|
||||
PUTPROP(props, "java.vendor", VENDOR);
|
||||
PUTPROP(props, "java.vendor.url", VENDOR_URL);
|
||||
PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG);
|
||||
|
@ -255,8 +254,10 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
|||
|
||||
/* unicode_encoding specifies the default endianness */
|
||||
PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
|
||||
PUTPROP(props, "sun.cpu.isalist",
|
||||
(sprops->cpu_isalist ? sprops->cpu_isalist : ""));
|
||||
if (sprops->cpu_isalist != NULL) {
|
||||
// leave undefined if none
|
||||
PUTPROP(props, "sun.cpu.isalist", sprops->cpu_isalist);
|
||||
}
|
||||
PUTPROP(props, "sun.cpu.endian", sprops->cpu_endian);
|
||||
|
||||
|
||||
|
@ -330,8 +331,10 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
|||
sprops->data_model);
|
||||
|
||||
/* patch level */
|
||||
PUTPROP(props, "sun.os.patch.level", \
|
||||
if (sprops->patch_level != NULL) {
|
||||
PUTPROP(props, "sun.os.patch.level", \
|
||||
sprops->patch_level);
|
||||
}
|
||||
|
||||
/* Java2D properties */
|
||||
/* Note: java.awt.graphicsenv is an implementation private property which
|
||||
|
@ -354,9 +357,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
|||
|
||||
PUTPROP_ForPlatformNString(props, "user.name", sprops->user_name);
|
||||
PUTPROP_ForPlatformNString(props, "user.home", sprops->user_home);
|
||||
|
||||
PUTPROP(props, "user.timezone", sprops->timezone);
|
||||
|
||||
PUTPROP_ForPlatformNString(props, "user.dir", sprops->user_dir);
|
||||
|
||||
/* This is a sun. property as it is currently only set for Gnome and
|
||||
|
|
|
@ -56,23 +56,18 @@ typedef struct {
|
|||
nchar *user_name;
|
||||
nchar *user_home;
|
||||
|
||||
char *language;
|
||||
char *format_language;
|
||||
char *display_language;
|
||||
char *script;
|
||||
char *format_script;
|
||||
char *display_script;
|
||||
char *country;
|
||||
char *format_country;
|
||||
char *display_country;
|
||||
char *variant;
|
||||
char *format_variant;
|
||||
char *display_variant;
|
||||
char *encoding;
|
||||
char *sun_jnu_encoding;
|
||||
char *sun_stdout_encoding;
|
||||
char *sun_stderr_encoding;
|
||||
char *timezone;
|
||||
|
||||
char *printerJob;
|
||||
char *graphics_env;
|
||||
|
|
|
@ -399,7 +399,7 @@ GetJavaProperties(JNIEnv *env)
|
|||
#endif
|
||||
|
||||
/* patches/service packs installed */
|
||||
sprops.patch_level = "unknown";
|
||||
sprops.patch_level = NULL; // leave it undefined
|
||||
|
||||
/* Java 2D/AWT properties */
|
||||
#ifdef MACOSX
|
||||
|
@ -488,19 +488,15 @@ GetJavaProperties(JNIEnv *env)
|
|||
&(sprops.format_variant),
|
||||
&(sprops.encoding))) {
|
||||
ParseLocale(env, LC_MESSAGES,
|
||||
&(sprops.language),
|
||||
&(sprops.script),
|
||||
&(sprops.country),
|
||||
&(sprops.variant),
|
||||
&(sprops.display_language),
|
||||
&(sprops.display_script),
|
||||
&(sprops.display_country),
|
||||
&(sprops.display_variant),
|
||||
NULL);
|
||||
} else {
|
||||
sprops.language = "en";
|
||||
sprops.display_language = "en";
|
||||
sprops.encoding = "ISO8859-1";
|
||||
}
|
||||
sprops.display_language = sprops.language;
|
||||
sprops.display_script = sprops.script;
|
||||
sprops.display_country = sprops.country;
|
||||
sprops.display_variant = sprops.variant;
|
||||
|
||||
/* ParseLocale failed with OOME */
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
|
@ -543,18 +539,12 @@ GetJavaProperties(JNIEnv *env)
|
|||
}
|
||||
}
|
||||
|
||||
/* User TIMEZONE */
|
||||
{
|
||||
/*
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). However, the system
|
||||
* property is necessary to be able to be set by the command
|
||||
* line interface -D. Here temporarily set a null string to
|
||||
* timezone.
|
||||
*/
|
||||
tzset(); /* for compatibility */
|
||||
sprops.timezone = "";
|
||||
}
|
||||
/* User TIMEZONE
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). The system property
|
||||
* is able to be set by the command line interface -Duser.timezone.
|
||||
*/
|
||||
tzset(); /* for compatibility */
|
||||
|
||||
/* Current directory */
|
||||
{
|
||||
|
|
|
@ -661,12 +661,6 @@ GetJavaProperties(JNIEnv* env)
|
|||
userDefaultUILang = userDefaultLCID;
|
||||
}
|
||||
|
||||
SetupI18nProps(userDefaultUILang,
|
||||
&sprops.language,
|
||||
&sprops.script,
|
||||
&sprops.country,
|
||||
&sprops.variant,
|
||||
&display_encoding);
|
||||
SetupI18nProps(userDefaultLCID,
|
||||
&sprops.format_language,
|
||||
&sprops.format_script,
|
||||
|
@ -710,17 +704,12 @@ GetJavaProperties(JNIEnv* env)
|
|||
}
|
||||
|
||||
sprops.unicode_encoding = "UnicodeLittle";
|
||||
/* User TIMEZONE */
|
||||
{
|
||||
/*
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). However, the system
|
||||
* property is necessary to be able to be set by the command
|
||||
* line interface -D. Here temporarily set a null string to
|
||||
* timezone.
|
||||
*/
|
||||
sprops.timezone = "";
|
||||
}
|
||||
|
||||
/* User TIMEZONE
|
||||
* We defer setting up timezone until it's actually necessary.
|
||||
* Refer to TimeZone.getDefault(). The system property
|
||||
* is able to be set by the command line interface -Duser.timezone.
|
||||
*/
|
||||
|
||||
/* Current directory */
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue