summaryrefslogtreecommitdiff
path: root/src/java.base/share/classes/java/lang/System.java
diff options
context:
space:
mode:
authorRoger Riggs <rriggs@openjdk.org>2018-06-27 09:36:34 -0400
committerRoger Riggs <rriggs@openjdk.org>2018-06-27 09:36:34 -0400
commit4098f2560aaa0c805f4e8f293a38f878d70dd03e (patch)
tree3a345b2e8bb7a97ce9779a37a0784cca750c5a15 /src/java.base/share/classes/java/lang/System.java
parentcad47f4a03425276c8fc79bf84f1f6cdaf35dced (diff)
downloadopenjdk-4098f2560aaa0c805f4e8f293a38f878d70dd03e.tar.gz
openjdk-4098f2560aaa0c805f4e8f293a38f878d70dd03e.zip
8066709: Make some JDK system properties read only
Reviewed-by: lancea, sundar, bchristi, weijun, mchung, alanb, mullan
Diffstat (limited to 'src/java.base/share/classes/java/lang/System.java')
-rw-r--r--src/java.base/share/classes/java/lang/System.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java
index d775b9aecc3..c1dcff2e4ed 100644
--- a/src/java.base/share/classes/java/lang/System.java
+++ b/src/java.base/share/classes/java/lang/System.java
@@ -59,6 +59,7 @@ import java.util.function.Supplier;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
+import jdk.internal.util.StaticProperty;
import jdk.internal.module.ModuleBootstrap;
import jdk.internal.module.ServicesCatalog;
import jdk.internal.reflect.CallerSensitive;
@@ -669,7 +670,16 @@ public final class System {
* {@code getProperties} operation, it may choose to permit the
* {@link #getProperty(String)} operation.
*
- * @implNote In addition to the standard system properties, the system
+ * @apiNote
+ * <strong>Changing a standard system property may have unpredictable results
+ * unless otherwise specified.</strong>
+ * Property values may be cached during initialization or on first use.
+ * Setting a standard property after initialization using {@link #getProperties()},
+ * {@link #setProperties(Properties)}, {@link #setProperty(String, String)}, or
+ * {@link #clearProperty(String)} may not have the desired effect.
+ *
+ * @implNote
+ * In addition to the standard system properties, the system
* properties may include the following keys:
* <table class="striped">
* <caption style="display:none">Shows property keys and associated values</caption>
@@ -736,6 +746,11 @@ public final class System {
* {@code null}, then the current set of system properties is
* forgotten.
*
+ * @apiNote
+ * <strong>Changing a standard system property may have unpredictable results
+ * unless otherwise specified</strong>.
+ * See {@linkplain #getProperties getProperties} for details.
+ *
* @param props the new system properties.
* @throws SecurityException if a security manager exists and its
* {@code checkPropertiesAccess} method doesn't allow access
@@ -768,6 +783,11 @@ public final class System {
* properties is first created and initialized in the same manner as
* for the {@code getProperties} method.
*
+ * @apiNote
+ * <strong>Changing a standard system property may have unpredictable results
+ * unless otherwise specified</strong>.
+ * See {@linkplain #getProperties getProperties} for details.
+ *
* @param key the name of the system property.
* @return the string value of the system property,
* or {@code null} if there is no property with that key.
@@ -837,6 +857,11 @@ public final class System {
* If no exception is thrown, the specified property is set to the given
* value.
*
+ * @apiNote
+ * <strong>Changing a standard system property may have unpredictable results
+ * unless otherwise specified</strong>.
+ * See {@linkplain #getProperties getProperties} for details.
+ *
* @param key the name of the system property.
* @param value the value of the system property.
* @return the previous value of the system property,
@@ -875,6 +900,11 @@ public final class System {
* permission. This may result in a SecurityException being thrown.
* If no exception is thrown, the specified property is removed.
*
+ * @apiNote
+ * <strong>Changing a standard system property may have unpredictable results
+ * unless otherwise specified</strong>.
+ * See {@linkplain #getProperties getProperties} method for details.
+ *
* @param key the name of the system property to be removed.
* @return the previous string value of the system property,
* or {@code null} if there was no property with that key.
@@ -1927,6 +1957,7 @@ public final class System {
VM.saveAndRemoveProperties(props);
lineSeparator = props.getProperty("line.separator");
+ StaticProperty.javaHome(); // Load StaticProperty to cache the property values
VersionProps.init();
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);