mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
4947890: Minimize JNI upcalls in system-properties initialization
Reviewed-by: erikj, mchung, bchristi, ihse, coleenp, stuefe
This commit is contained in:
parent
94f0c828e3
commit
c1034b1cad
13 changed files with 628 additions and 294 deletions
|
@ -72,6 +72,7 @@ import jdk.internal.misc.VM;
|
|||
import jdk.internal.logger.LoggerFinderLoader;
|
||||
import jdk.internal.logger.LazyLoggers;
|
||||
import jdk.internal.logger.LocalizedLoggerWrapper;
|
||||
import jdk.internal.util.SystemProps;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
import sun.reflect.annotation.AnnotationType;
|
||||
import sun.nio.ch.Interruptible;
|
||||
|
@ -605,7 +606,6 @@ public final class System {
|
|||
*/
|
||||
|
||||
private static Properties props;
|
||||
private static native Properties initProperties(Properties props);
|
||||
|
||||
/**
|
||||
* Determines the current system properties.
|
||||
|
@ -799,9 +799,9 @@ public final class System {
|
|||
if (sm != null) {
|
||||
sm.checkPropertiesAccess();
|
||||
}
|
||||
|
||||
if (props == null) {
|
||||
props = new Properties();
|
||||
initProperties(props);
|
||||
props = SystemProps.initProperties();
|
||||
VersionProps.init(props);
|
||||
}
|
||||
System.props = props;
|
||||
|
@ -1966,15 +1966,11 @@ public final class System {
|
|||
|
||||
// VM might invoke JNU_NewStringPlatform() to set those encoding
|
||||
// sensitive properties (user.home, user.name, boot.class.path, etc.)
|
||||
// during "props" initialization, in which it may need access, via
|
||||
// System.getProperty(), to the related system encoding property that
|
||||
// have been initialized (put into "props") at early stage of the
|
||||
// initialization. So make sure the "props" is available at the
|
||||
// very beginning of the initialization and all system properties to
|
||||
// be put into it directly.
|
||||
props = new Properties(84);
|
||||
initProperties(props); // initialized by the VM
|
||||
// during "props" initialization.
|
||||
// The charset is initialized in System.c and does not depend on the Properties.
|
||||
props = SystemProps.initProperties();
|
||||
VersionProps.init(props);
|
||||
StaticProperty.javaHome(); // Load StaticProperty to cache the property values
|
||||
|
||||
// There are certain system configurations that may be controlled by
|
||||
// VM options such as the maximum amount of direct memory and
|
||||
|
@ -1993,7 +1989,6 @@ public final class System {
|
|||
VM.saveAndRemoveProperties(props);
|
||||
|
||||
lineSeparator = props.getProperty("line.separator");
|
||||
StaticProperty.javaHome(); // Load StaticProperty to cache the property values
|
||||
|
||||
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
|
||||
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -63,6 +63,9 @@ class VersionProps {
|
|||
private static final boolean isLTS =
|
||||
"@@VERSION_OPT@@".startsWith("LTS");
|
||||
|
||||
private static final String CLASSFILE_MAJOR_MINOR =
|
||||
"@@VERSION_CLASSFILE_MAJOR@@.@@VERSION_CLASSFILE_MINOR@@";
|
||||
|
||||
private static final String VENDOR_VERSION_STRING =
|
||||
"@@VENDOR_VERSION_STRING@@";
|
||||
|
||||
|
@ -70,6 +73,20 @@ class VersionProps {
|
|||
(VENDOR_VERSION_STRING.length() > 0
|
||||
? " " + VENDOR_VERSION_STRING : "");
|
||||
|
||||
private static final String VENDOR =
|
||||
"@@VENDOR@@";
|
||||
|
||||
private static final String VENDOR_URL =
|
||||
"@@VENDOR_URL@@";
|
||||
|
||||
private static final String VENDOR_URL_BUG =
|
||||
"@@VENDOR_URL_BUG@@";
|
||||
|
||||
/**
|
||||
* Initialize system properties using build provided values.
|
||||
*
|
||||
* @param props Properties instance in which to insert the properties
|
||||
*/
|
||||
public static void init(Properties props) {
|
||||
props.setProperty("java.version", java_version);
|
||||
props.setProperty("java.version.date", java_version_date);
|
||||
|
@ -77,6 +94,16 @@ class VersionProps {
|
|||
props.setProperty("java.runtime.name", java_runtime_name);
|
||||
if (VENDOR_VERSION_STRING.length() > 0)
|
||||
props.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
|
||||
props.setProperty("java.class.version", CLASSFILE_MAJOR_MINOR);
|
||||
|
||||
props.setProperty("java.specification.version", VERSION_NUMBER);
|
||||
props.setProperty("java.specification.name", "Java Platform API Specification");
|
||||
props.setProperty("java.specification.vendor", "Oracle Corporation");
|
||||
|
||||
props.setProperty("java.vendor", VENDOR);
|
||||
props.setProperty("java.vendor.url", VENDOR_URL);
|
||||
props.setProperty("java.vendor.url.bug", VENDOR_URL_BUG);
|
||||
}
|
||||
|
||||
private static int parseVersionNumber(String version, int prevIndex, int index) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue