8066709: Make some JDK system properties read only

Reviewed-by: lancea, sundar, bchristi, weijun, mchung, alanb, mullan
This commit is contained in:
Roger Riggs 2018-06-27 09:36:34 -04:00
parent cad47f4a03
commit 4098f2560a
25 changed files with 215 additions and 46 deletions

View file

@ -26,6 +26,8 @@
package java.io;
import java.util.Properties;
import jdk.internal.util.StaticProperty;
import sun.security.action.GetPropertyAction;
@ -40,8 +42,8 @@ class UnixFileSystem extends FileSystem {
Properties props = GetPropertyAction.privilegedGetProperties();
slash = props.getProperty("file.separator").charAt(0);
colon = props.getProperty("path.separator").charAt(0);
javaHome = props.getProperty("java.home");
userDir = props.getProperty("user.dir");
javaHome = StaticProperty.javaHome();
userDir = StaticProperty.userDir();
}

View file

@ -49,6 +49,7 @@ import java.security.PrivilegedExceptionAction;
import java.util.Properties;
import jdk.internal.misc.JavaIOFileDescriptorAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.util.StaticProperty;
import sun.security.action.GetPropertyAction;
/**
@ -122,7 +123,7 @@ final class ProcessImpl extends Process {
String helperPath() {
Properties props = GetPropertyAction.privilegedGetProperties();
return helperPath(props.getProperty("java.home"),
return helperPath(StaticProperty.javaHome(),
props.getProperty("os.arch"));
}

View file

@ -25,6 +25,8 @@
package sun.nio.fs;
import jdk.internal.util.StaticProperty;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.nio.channels.*;
@ -259,7 +261,7 @@ abstract class UnixFileStore
private static Properties loadProperties() {
Properties result = new Properties();
String fstypes = System.getProperty("java.home") + "/lib/fstypes.properties";
String fstypes = StaticProperty.javaHome() + "/lib/fstypes.properties";
Path file = Path.of(fstypes);
try {
try (ReadableByteChannel rbc = Files.newByteChannel(file)) {