8154231: Simplify access to System properties from JDK code

Reviewed-by: rriggs, chegar, weijun
This commit is contained in:
Claes Redestad 2016-04-21 13:39:53 +02:00
parent b909478b3d
commit 2b5207e74d
78 changed files with 391 additions and 453 deletions

View file

@ -102,8 +102,8 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
@Override @Override
FileTypeDetector getFileTypeDetector() { FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(AccessController.doPrivileged( String userHome = GetPropertyAction.getProperty("user.home");
new GetPropertyAction("user.home")), ".mime.types"); Path userMimeTypes = Paths.get(userHome, ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types"); Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GioFileTypeDetector(), return chain(new GioFileTypeDetector(),

View file

@ -32,9 +32,9 @@
package sun.nio.ch; package sun.nio.ch;
import java.io.IOException; import java.io.IOException;
import java.io.FileDescriptor;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import sun.security.action.GetPropertyAction;
/* /*
* struct kevent { // 32-bit 64-bit * struct kevent { // 32-bit 64-bit
@ -84,10 +84,8 @@ class KQueueArrayWrapper {
static { static {
IOUtil.load(); IOUtil.load();
initStructSizes(); initStructSizes();
String datamodel = java.security.AccessController.doPrivileged( String datamodel = GetPropertyAction.getProperty("sun.arch.data.model");
new sun.security.action.GetPropertyAction("sun.arch.data.model") is64bit = "64".equals(datamodel);
);
is64bit = datamodel.equals("64");
} }
KQueueArrayWrapper() { KQueueArrayWrapper() {

View file

@ -28,7 +28,6 @@ package sun.nio.fs;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.spi.FileTypeDetector; import java.nio.file.spi.FileTypeDetector;
import java.security.AccessController;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -47,8 +46,8 @@ public class MacOSXFileSystemProvider extends BsdFileSystemProvider {
@Override @Override
FileTypeDetector getFileTypeDetector() { FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(AccessController.doPrivileged( Path userMimeTypes = Paths.get(
new GetPropertyAction("user.home")), ".mime.types"); GetPropertyAction.getProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes), return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new UTIFileTypeDetector()); new UTIFileTypeDetector());

View file

@ -31,7 +31,6 @@ import java.net.MalformedURLException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.security.AccessController;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
@ -1896,8 +1895,8 @@ public class File
private TempDirectory() { } private TempDirectory() { }
// temporary directory location // temporary directory location
private static final File tmpdir = new File(AccessController private static final File tmpdir = new File(
.doPrivileged(new GetPropertyAction("java.io.tmpdir"))); GetPropertyAction.getProperty("java.io.tmpdir"));
static File location() { static File location() {
return tmpdir; return tmpdir;
} }

View file

@ -30,13 +30,12 @@ import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.channels.Pipe;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.security.AccessController; import sun.security.action.GetPropertyAction;
import java.security.PrivilegedAction;
/** /**
* This class is used to create operating system processes. * This class is used to create operating system processes.
* *
@ -468,11 +467,9 @@ public final class ProcessBuilder
* @since 1.7 * @since 1.7
*/ */
public abstract static class Redirect { public abstract static class Redirect {
private static final File NULL_FILE = AccessController.doPrivileged( private static final File NULL_FILE = new File(
(PrivilegedAction<File>) () -> { (GetPropertyAction.getProperty("os.name")
return new File((System.getProperty("os.name") .startsWith("Windows") ? "NUL" : "/dev/null")
.startsWith("Windows") ? "NUL" : "/dev/null"));
}
); );
/** /**

View file

@ -30,8 +30,6 @@ import java.lang.StackWalker.StackFrame;
import java.lang.annotation.Native; import java.lang.annotation.Native;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashSet; import java.util.HashSet;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Objects; import java.util.Objects;
@ -41,6 +39,7 @@ import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import sun.security.action.GetPropertyAction;
import static java.lang.StackStreamFactory.WalkerState.*; import static java.lang.StackStreamFactory.WalkerState.*;
@ -990,14 +989,9 @@ final class StackStreamFactory {
} }
private static boolean getProperty(String key, boolean value) { private static boolean getProperty(String key, boolean value) {
String s = AccessController.doPrivileged(new PrivilegedAction<>() { String s = GetPropertyAction.getProperty(key);
@Override
public String run() {
return System.getProperty(key);
}
});
if (s != null) { if (s != null) {
return Boolean.valueOf(s); return Boolean.parseBoolean(s);
} }
return value; return value;
} }

View file

@ -88,8 +88,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
static { static {
final String key = "jdk.internal.lambda.dumpProxyClasses"; final String key = "jdk.internal.lambda.dumpProxyClasses";
String path = AccessController.doPrivileged( String path = GetPropertyAction.getProperty(key);
new GetPropertyAction(key));
dumper = (null == path) ? null : ProxyClassesDumper.getInstance(path); dumper = (null == path) ? null : ProxyClassesDumper.getInstance(path);
} }

View file

@ -25,9 +25,9 @@
package java.lang.invoke; package java.lang.invoke;
import java.security.AccessController; import java.util.Properties;
import java.security.PrivilegedAction;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import sun.security.action.GetPropertyAction;
/** /**
* This class consists exclusively of static names internal to the * This class consists exclusively of static names internal to the
@ -53,32 +53,27 @@ import jdk.internal.misc.Unsafe;
static final boolean VAR_HANDLE_GUARDS; static final boolean VAR_HANDLE_GUARDS;
static { static {
final Object[] values = new Object[10]; Properties props = GetPropertyAction.getProperties();
AccessController.doPrivileged(new PrivilegedAction<>() { DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean(
public Void run() { props.getProperty("java.lang.invoke.MethodHandle.DEBUG_NAMES"));
values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES"); DUMP_CLASS_FILES = Boolean.parseBoolean(
values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"); props.getProperty("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"));
values[2] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_INTERPRETER"); TRACE_INTERPRETER = Boolean.parseBoolean(
values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE"); props.getProperty("java.lang.invoke.MethodHandle.TRACE_INTERPRETER"));
values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 0); TRACE_METHOD_LINKAGE = Boolean.parseBoolean(
values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30); props.getProperty("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE"));
values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0); COMPILE_THRESHOLD = Integer.parseInt(
values[7] = Boolean.parseBoolean(System.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true")); props.getProperty("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", "0"));
values[8] = Integer.getInteger("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", 127); DONT_INLINE_THRESHOLD = Integer.parseInt(
values[9] = Boolean.parseBoolean(System.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true")); props.getProperty("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", "30"));
return null; PROFILE_LEVEL = Integer.parseInt(
} props.getProperty("java.lang.invoke.MethodHandle.PROFILE_LEVEL", "0"));
}); PROFILE_GWT = Boolean.parseBoolean(
DEBUG_METHOD_HANDLE_NAMES = (Boolean) values[0]; props.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true"));
DUMP_CLASS_FILES = (Boolean) values[1]; CUSTOMIZE_THRESHOLD = Integer.parseInt(
TRACE_INTERPRETER = (Boolean) values[2]; props.getProperty("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", "127"));
TRACE_METHOD_LINKAGE = (Boolean) values[3]; VAR_HANDLE_GUARDS = Boolean.parseBoolean(
COMPILE_THRESHOLD = (Integer) values[4]; props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true"));
DONT_INLINE_THRESHOLD = (Integer) values[5];
PROFILE_LEVEL = (Integer) values[6];
PROFILE_GWT = (Boolean) values[7];
CUSTOMIZE_THRESHOLD = (Integer) values[8];
VAR_HANDLE_GUARDS = (Boolean) values[9];
if (CUSTOMIZE_THRESHOLD < -1 || CUSTOMIZE_THRESHOLD > 127) { if (CUSTOMIZE_THRESHOLD < -1 || CUSTOMIZE_THRESHOLD > 127) {
throw newInternalError("CUSTOMIZE_THRESHOLD should be in [-1...127] range"); throw newInternalError("CUSTOMIZE_THRESHOLD should be in [-1...127] range");

View file

@ -33,7 +33,6 @@ import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.MethodHandles.Lookup;
import java.security.AccessController;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
@ -188,14 +187,15 @@ public final class StringConcatFactory {
private static final ProxyClassesDumper DUMPER; private static final ProxyClassesDumper DUMPER;
static { static {
final String strategy = AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new GetPropertyAction("java.lang.invoke.stringConcat")); final String strategy =
CACHE_ENABLE = Boolean.parseBoolean(AccessController.doPrivileged( props.getProperty("java.lang.invoke.stringConcat");
new GetPropertyAction("java.lang.invoke.stringConcat.cache"))); CACHE_ENABLE = Boolean.parseBoolean(
DEBUG = Boolean.parseBoolean(AccessController.doPrivileged( props.getProperty("java.lang.invoke.stringConcat.cache"));
new GetPropertyAction("java.lang.invoke.stringConcat.debug"))); DEBUG = Boolean.parseBoolean(
final String dumpPath = AccessController.doPrivileged( props.getProperty("java.lang.invoke.stringConcat.debug"));
new GetPropertyAction("java.lang.invoke.stringConcat.dumpClasses")); final String dumpPath =
props.getProperty("java.lang.invoke.stringConcat.dumpClasses");
STRATEGY = (strategy == null) ? DEFAULT_STRATEGY : Strategy.valueOf(strategy); STRATEGY = (strategy == null) ? DEFAULT_STRATEGY : Strategy.valueOf(strategy);
CACHE = CACHE_ENABLE ? new ConcurrentHashMap<>() : null; CACHE = CACHE_ENABLE ? new ConcurrentHashMap<>() : null;

View file

@ -39,6 +39,7 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import sun.security.action.GetPropertyAction;
/** /**
* A finder of modules. A {@code ModuleFinder} is used to find modules during * A finder of modules. A {@code ModuleFinder} is used to find modules during
@ -152,7 +153,7 @@ public interface ModuleFinder {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
PrivilegedAction<String> pa = () -> System.getProperty("java.home"); PrivilegedAction<String> pa = new GetPropertyAction("java.home");
home = AccessController.doPrivileged(pa); home = AccessController.doPrivileged(pa);
Permission p = new FilePermission(home + File.separator + "-", "read"); Permission p = new FilePermission(home + File.separator + "-", "read");
sm.checkPermission(p); sm.checkPermission(p);

View file

@ -50,6 +50,7 @@ import jdk.internal.misc.VM;
import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection; import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil; import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
/** /**
@ -581,11 +582,7 @@ public class Proxy implements java.io.Serializable {
} }
private static final String DEBUG = private static final String DEBUG =
AccessController.doPrivileged(new PrivilegedAction<>() { GetPropertyAction.getProperty("jdk.proxy.debug", "");
public String run() {
return System.getProperty("jdk.proxy.debug", "");
}
});
private static boolean isDebug() { private static boolean isDebug() {
return !DEBUG.isEmpty(); return !DEBUG.isEmpty();

View file

@ -31,6 +31,7 @@ import sun.net.ResourceManager;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.Collections; import java.util.Collections;
import sun.security.action.GetPropertyAction;
/** /**
* Abstract datagram and multicast socket implementation base class. * Abstract datagram and multicast socket implementation base class.
@ -51,9 +52,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
protected InetAddress connectedAddress = null; protected InetAddress connectedAddress = null;
private int connectedPort = -1; private int connectedPort = -1;
private static final String os = AccessController.doPrivileged( private static final String os = GetPropertyAction.getProperty("os.name");
new sun.security.action.GetPropertyAction("os.name")
);
/** /**
* flag set if the native connect() call not to be used * flag set if the native connect() call not to be used

View file

@ -1123,8 +1123,8 @@ class InetAddress implements java.io.Serializable {
*/ */
private static NameService createNameService() { private static NameService createNameService() {
String hostsFileName = AccessController String hostsFileName =
.doPrivileged(new GetPropertyAction("jdk.net.hosts.file")); GetPropertyAction.getProperty("jdk.net.hosts.file");
NameService theNameService; NameService theNameService;
if (hostsFileName != null) { if (hostsFileName != null) {
theNameService = new HostsFileNameService(hostsFileName); theNameService = new HostsFileNameService(hostsFileName);
@ -1643,8 +1643,7 @@ class InetAddress implements java.io.Serializable {
* property can vary across implementations of the java. * property can vary across implementations of the java.
* classes. The default is an empty String "". * classes. The default is an empty String "".
*/ */
String prefix = AccessController.doPrivileged( String prefix = GetPropertyAction.getProperty("impl.prefix", "");
new GetPropertyAction("impl.prefix", ""));
try { try {
impl = Class.forName("java.net." + prefix + implName).newInstance(); impl = Class.forName("java.net." + prefix + implName).newInstance();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {

View file

@ -33,6 +33,7 @@ import java.security.PrivilegedExceptionAction;
import sun.net.SocksProxy; import sun.net.SocksProxy;
import sun.net.spi.DefaultProxySelector; import sun.net.spi.DefaultProxySelector;
import sun.net.www.ParseUtil; import sun.net.www.ParseUtil;
import sun.security.action.GetPropertyAction;
/* import org.ietf.jgss.*; */ /* import org.ietf.jgss.*; */
/** /**
@ -177,8 +178,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
userName = pw.getUserName(); userName = pw.getUserName();
password = new String(pw.getPassword()); password = new String(pw.getPassword());
} else { } else {
userName = java.security.AccessController.doPrivileged( userName = GetPropertyAction.getProperty("user.name");
new sun.security.action.GetPropertyAction("user.name"));
} }
if (userName == null) if (userName == null)
return false; return false;
@ -1088,8 +1088,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
userName = System.getProperty("user.name"); userName = System.getProperty("user.name");
} catch (SecurityException se) { /* swallow Exception */ } } catch (SecurityException se) { /* swallow Exception */ }
} else { } else {
userName = java.security.AccessController.doPrivileged( userName = GetPropertyAction.getProperty("user.name");
new sun.security.action.GetPropertyAction("user.name"));
} }
return userName; return userName;
} }

View file

@ -42,6 +42,7 @@ import java.util.ServiceConfigurationError;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import sun.security.action.GetPropertyAction;
/** /**
* Class {@code URL} represents a Uniform Resource * Class {@code URL} represents a Uniform Resource
@ -1210,12 +1211,8 @@ public final class URL implements java.io.Serializable {
} }
private static URLStreamHandler lookupViaProperty(String protocol) { private static URLStreamHandler lookupViaProperty(String protocol) {
String packagePrefixList = java.security.AccessController.doPrivileged( String packagePrefixList =
new PrivilegedAction<>() { GetPropertyAction.getProperty(protocolPathProp);
public String run() {
return System.getProperty(protocolPathProp, null);
}
});
if (packagePrefixList == null) { if (packagePrefixList == null) {
// not set // not set
return null; return null;

View file

@ -43,6 +43,7 @@ import java.security.Permission;
import java.security.AccessController; import java.security.AccessController;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import sun.net.www.MessageHeader; import sun.net.www.MessageHeader;
import sun.security.action.GetPropertyAction;
/** /**
* The abstract class {@code URLConnection} is the superclass * The abstract class {@code URLConnection} is the superclass
@ -1395,8 +1396,8 @@ public abstract class URLConnection {
* is always the last one on the returned package list. * is always the last one on the returned package list.
*/ */
private String getContentHandlerPkgPrefixes() { private String getContentHandlerPkgPrefixes() {
String packagePrefixList = AccessController.doPrivileged( String packagePrefixList =
new sun.security.action.GetPropertyAction(contentPathProp, "")); GetPropertyAction.getProperty(contentPathProp, "");
if (packagePrefixList != "") { if (packagePrefixList != "") {
packagePrefixList += "|"; packagePrefixList += "|";

View file

@ -25,19 +25,12 @@
package java.net; package java.net;
import java.io.ByteArrayOutputStream;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.io.CharArrayWriter; import java.io.CharArrayWriter;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException ; import java.nio.charset.UnsupportedCharsetException ;
import java.util.BitSet; import java.util.BitSet;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetBooleanAction;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -140,9 +133,7 @@ public class URLEncoder {
dontNeedEncoding.set('.'); dontNeedEncoding.set('.');
dontNeedEncoding.set('*'); dontNeedEncoding.set('*');
dfltEncName = AccessController.doPrivileged( dfltEncName = GetPropertyAction.getProperty("file.encoding");
new GetPropertyAction("file.encoding")
);
} }
/** /**

View file

@ -283,8 +283,8 @@ public abstract class Charset
if (level == null) { if (level == null) {
if (!VM.isBooted()) if (!VM.isBooted())
return false; return false;
bugLevel = level = AccessController.doPrivileged( bugLevel = level =
new GetPropertyAction("sun.nio.cs.bugLevel", "")); GetPropertyAction.getProperty("sun.nio.cs.bugLevel", "");
} }
return level.equals(bl); return level.equals(bl);
} }
@ -609,8 +609,7 @@ public abstract class Charset
public static Charset defaultCharset() { public static Charset defaultCharset() {
if (defaultCharset == null) { if (defaultCharset == null) {
synchronized (Charset.class) { synchronized (Charset.class) {
String csn = AccessController.doPrivileged( String csn = GetPropertyAction.getProperty("file.encoding");
new GetPropertyAction("file.encoding"));
Charset cs = lookup(csn); Charset cs = lookup(csn);
if (cs != null) if (cs != null)
defaultCharset = cs; defaultCharset = cs;

View file

@ -28,7 +28,6 @@ package java.nio.file;
import java.util.Set; import java.util.Set;
import java.util.EnumSet; import java.util.EnumSet;
import java.security.SecureRandom; import java.security.SecureRandom;
import static java.security.AccessController.*;
import java.io.IOException; import java.io.IOException;
import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermission;
@ -47,7 +46,7 @@ class TempFileHelper {
// temporary directory location // temporary directory location
private static final Path tmpdir = private static final Path tmpdir =
Paths.get(doPrivileged(new GetPropertyAction("java.io.tmpdir"))); Paths.get(GetPropertyAction.getProperty("java.io.tmpdir"));
private static final boolean isPosix = private static final boolean isPosix =
FileSystems.getDefault().supportedFileAttributeViews().contains("posix"); FileSystems.getDefault().supportedFileAttributeViews().contains("posix");

View file

@ -45,7 +45,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.ObjectStreamField; import java.io.ObjectStreamField;
import java.io.Serializable; import java.io.Serializable;
import java.security.AccessController;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.spi.LocaleNameProvider; import java.util.spi.LocaleNameProvider;
@ -859,11 +858,10 @@ public final class Locale implements Cloneable, Serializable {
private static Locale initDefault() { private static Locale initDefault() {
String language, region, script, country, variant; String language, region, script, country, variant;
language = AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new GetPropertyAction("user.language", "en")); language = props.getProperty("user.language", "en");
// for compatibility, check for old user.region property // for compatibility, check for old user.region property
region = AccessController.doPrivileged( region = props.getProperty("user.region");
new GetPropertyAction("user.region"));
if (region != null) { if (region != null) {
// region can be of form country, country_variant, or _variant // region can be of form country, country_variant, or _variant
int i = region.indexOf('_'); int i = region.indexOf('_');
@ -876,27 +874,25 @@ public final class Locale implements Cloneable, Serializable {
} }
script = ""; script = "";
} else { } else {
script = AccessController.doPrivileged( script = props.getProperty("user.script", "");
new GetPropertyAction("user.script", "")); country = props.getProperty("user.country", "");
country = AccessController.doPrivileged( variant = props.getProperty("user.variant", "");
new GetPropertyAction("user.country", ""));
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
} }
return getInstance(language, script, country, variant, null); return getInstance(language, script, country, variant, null);
} }
private static Locale initDefault(Locale.Category category) { private static Locale initDefault(Locale.Category category) {
Properties props = GetPropertyAction.getProperties();
return getInstance( return getInstance(
AccessController.doPrivileged( props.getProperty(category.languageKey,
new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())), defaultLocale.getLanguage()),
AccessController.doPrivileged( props.getProperty(category.scriptKey,
new GetPropertyAction(category.scriptKey, defaultLocale.getScript())), defaultLocale.getScript()),
AccessController.doPrivileged( props.getProperty(category.countryKey,
new GetPropertyAction(category.countryKey, defaultLocale.getCountry())), defaultLocale.getCountry()),
AccessController.doPrivileged( props.getProperty(category.variantKey,
new GetPropertyAction(category.variantKey, defaultLocale.getVariant())), defaultLocale.getVariant()),
null); null);
} }

View file

@ -43,7 +43,6 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.MalformedInputException; import java.nio.charset.MalformedInputException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.charset.UnmappableCharacterException; import java.nio.charset.UnmappableCharacterException;
@ -142,8 +141,8 @@ public class PropertyResourceBundle extends ResourceBundle {
// Check whether the strict encoding is specified. // Check whether the strict encoding is specified.
// The possible encoding is either "ISO-8859-1" or "UTF-8". // The possible encoding is either "ISO-8859-1" or "UTF-8".
private static final String encoding = private static final String encoding =
AccessController.doPrivileged( GetPropertyAction
new GetPropertyAction("java.util.PropertyResourceBundle.encoding", "")) .getProperty("java.util.PropertyResourceBundle.encoding", "")
.toUpperCase(Locale.ROOT); .toUpperCase(Locale.ROOT);
/** /**

View file

@ -660,14 +660,12 @@ public abstract class TimeZone implements Serializable, Cloneable {
private static synchronized TimeZone setDefaultZone() { private static synchronized TimeZone setDefaultZone() {
TimeZone tz; TimeZone tz;
// get the time zone ID from the system properties // get the time zone ID from the system properties
String zoneID = AccessController.doPrivileged( String zoneID = GetPropertyAction.getProperty("user.timezone");
new GetPropertyAction("user.timezone"));
// if the time zone ID is not set (yet), perform the // if the time zone ID is not set (yet), perform the
// platform to Java time zone ID mapping. // platform to Java time zone ID mapping.
if (zoneID == null || zoneID.isEmpty()) { if (zoneID == null || zoneID.isEmpty()) {
String javaHome = AccessController.doPrivileged( String javaHome = GetPropertyAction.getProperty("java.home");
new GetPropertyAction("java.home"));
try { try {
zoneID = getSystemTimeZoneID(javaHome); zoneID = getSystemTimeZoneID(javaHome);
if (zoneID == null) { if (zoneID == null) {

View file

@ -34,7 +34,6 @@ import java.util.stream.StreamSupport;
import java.util.zip.*; import java.util.zip.*;
import java.security.CodeSigner; import java.security.CodeSigner;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.AccessController;
import java.security.CodeSource; import java.security.CodeSource;
import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.SharedSecrets;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
@ -155,16 +154,16 @@ class JarFile extends ZipFile {
BASE_VERSION = 8; // one less than lowest version for versioned entries BASE_VERSION = 8; // one less than lowest version for versioned entries
int runtimeVersion = jdk.Version.current().major(); int runtimeVersion = jdk.Version.current().major();
String jarVersion = AccessController.doPrivileged( String jarVersion =
new GetPropertyAction("jdk.util.jar.version")); GetPropertyAction.getProperty("jdk.util.jar.version");
if (jarVersion != null) { if (jarVersion != null) {
int jarVer = Integer.parseInt(jarVersion); int jarVer = Integer.parseInt(jarVersion);
runtimeVersion = (jarVer > runtimeVersion) runtimeVersion = (jarVer > runtimeVersion)
? runtimeVersion : Math.max(jarVer, 0); ? runtimeVersion : Math.max(jarVer, 0);
} }
RUNTIME_VERSION = runtimeVersion; RUNTIME_VERSION = runtimeVersion;
String enableMultiRelease = AccessController.doPrivileged( String enableMultiRelease = GetPropertyAction
new GetPropertyAction("jdk.util.jar.enableMultiRelease", "true")); .getProperty("jdk.util.jar.enableMultiRelease", "true");
switch (enableMultiRelease) { switch (enableMultiRelease) {
case "true": case "true":
default: default:

View file

@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import sun.security.action.GetPropertyAction;
/** /**
@ -694,8 +695,7 @@ public abstract class Pack200 {
Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl; Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
if (impl == null) { if (impl == null) {
// The first time, we must decide which class to use. // The first time, we must decide which class to use.
implName = java.security.AccessController.doPrivileged( implName = GetPropertyAction.getProperty(prop,"");
new sun.security.action.GetPropertyAction(prop,""));
if (implName != null && !implName.equals("")) if (implName != null && !implName.equals(""))
impl = Class.forName(implName); impl = Class.forName(implName);
else if (PACK_PROVIDER.equals(prop)) else if (PACK_PROVIDER.equals(prop))

View file

@ -94,8 +94,7 @@ public class PatternSyntaxException
} }
private static final String nl = private static final String nl =
java.security.AccessController GetPropertyAction.getProperty("line.separator");
.doPrivileged(new GetPropertyAction("line.separator"));
/** /**
* Returns a multi-line string containing the description of the syntax * Returns a multi-line string containing the description of the syntax

View file

@ -33,6 +33,7 @@ import java.util.Vector;
import java.util.HashSet; import java.util.HashSet;
import static java.util.zip.ZipConstants64.*; import static java.util.zip.ZipConstants64.*;
import static java.util.zip.ZipUtils.*; import static java.util.zip.ZipUtils.*;
import sun.security.action.GetPropertyAction;
/** /**
* This class implements an output stream filter for writing files in the * This class implements an output stream filter for writing files in the
@ -54,9 +55,7 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
*/ */
private static final boolean inhibitZip64 = private static final boolean inhibitZip64 =
Boolean.parseBoolean( Boolean.parseBoolean(
java.security.AccessController.doPrivileged( GetPropertyAction.getProperty("jdk.util.zip.inhibitZip64"));
new sun.security.action.GetPropertyAction(
"jdk.util.zip.inhibitZip64", "false")));
private static class XEntry { private static class XEntry {
final ZipEntry entry; final ZipEntry entry;

View file

@ -51,9 +51,9 @@ public abstract class SSLSocketFactory extends SocketFactory
static final boolean DEBUG; static final boolean DEBUG;
static { static {
String s = java.security.AccessController.doPrivileged( String s = GetPropertyAction.getProperty("javax.net.debug", "")
new GetPropertyAction("javax.net.debug", "")).toLowerCase( .toLowerCase(Locale.ENGLISH);
Locale.ENGLISH);
DEBUG = s.contains("all") || s.contains("ssl"); DEBUG = s.contains("all") || s.contains("ssl");
} }

View file

@ -26,8 +26,6 @@
package jdk; package jdk;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -35,6 +33,7 @@ import java.util.stream.Collectors;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import sun.security.action.GetPropertyAction;
/** /**
* A representation of the JDK version-string which contains a version * A representation of the JDK version-string which contains a version
@ -274,12 +273,7 @@ public final class Version
*/ */
public static Version current() { public static Version current() {
if (current == null) { if (current == null) {
current = parse(AccessController.doPrivileged( current = parse(GetPropertyAction.getProperty("java.version"));
new PrivilegedAction<>() {
public String run() {
return System.getProperty("java.version");
}
}));
} }
return current; return current;
} }

View file

@ -52,6 +52,7 @@ import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@ -69,6 +70,7 @@ import jdk.internal.util.jar.InvalidJarIndexError;
import jdk.internal.util.jar.JarIndex; import jdk.internal.util.jar.JarIndex;
import sun.net.util.URLUtil; import sun.net.util.URLUtil;
import sun.net.www.ParseUtil; import sun.net.www.ParseUtil;
import sun.security.action.GetPropertyAction;
/** /**
* This class is used to maintain a search path of URLs for loading classes * This class is used to maintain a search path of URLs for loading classes
@ -78,20 +80,15 @@ import sun.net.www.ParseUtil;
*/ */
public class URLClassPath { public class URLClassPath {
private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version"; private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
private static final String JAVA_HOME;
private static final String JAVA_VERSION; private static final String JAVA_VERSION;
private static final boolean DEBUG; private static final boolean DEBUG;
private static final boolean DISABLE_JAR_CHECKING; private static final boolean DISABLE_JAR_CHECKING;
static { static {
JAVA_HOME = java.security.AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new sun.security.action.GetPropertyAction("java.home")); JAVA_VERSION = props.getProperty("java.version");
JAVA_VERSION = java.security.AccessController.doPrivileged( DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null);
new sun.security.action.GetPropertyAction("java.version")); String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking");
DEBUG = (java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
String p = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false; DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
} }

View file

@ -33,6 +33,7 @@ import java.util.Locale;
import java.util.ServiceConfigurationError; import java.util.ServiceConfigurationError;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import sun.security.action.GetPropertyAction;
/** /**
* Helper class used to load the {@link java.lang.System.LoggerFinder}. * Helper class used to load the {@link java.lang.System.LoggerFinder}.
@ -79,9 +80,8 @@ public final class LoggerFinderLoader {
// Get configuration error policy // Get configuration error policy
private static ErrorPolicy configurationErrorPolicy() { private static ErrorPolicy configurationErrorPolicy() {
final PrivilegedAction<String> getConfigurationErrorPolicy = String errorPolicy =
() -> System.getProperty("jdk.logger.finder.error"); GetPropertyAction.getProperty("jdk.logger.finder.error");
String errorPolicy = AccessController.doPrivileged(getConfigurationErrorPolicy);
if (errorPolicy == null || errorPolicy.isEmpty()) { if (errorPolicy == null || errorPolicy.isEmpty()) {
return ErrorPolicy.WARNING; return ErrorPolicy.WARNING;
} }
@ -95,9 +95,8 @@ public final class LoggerFinderLoader {
// Whether multiple provider should be considered as an error. // Whether multiple provider should be considered as an error.
// This is further submitted to the configuration error policy. // This is further submitted to the configuration error policy.
private static boolean ensureSingletonProvider() { private static boolean ensureSingletonProvider() {
final PrivilegedAction<Boolean> ensureSingletonProvider = return Boolean.parseBoolean(
() -> Boolean.getBoolean("jdk.logger.finder.singleton"); GetPropertyAction.getProperty("jdk.logger.finder.singleton"));
return AccessController.doPrivileged(ensureSingletonProvider);
} }
private static Iterator<System.LoggerFinder> findLoggerFinderProviders() { private static Iterator<System.LoggerFinder> findLoggerFinderProviders() {

View file

@ -55,8 +55,8 @@ public class SimpleConsoleLogger extends LoggerConfiguration
PlatformLogger.toPlatformLevel(DEFAULT_LEVEL); PlatformLogger.toPlatformLevel(DEFAULT_LEVEL);
static Level getDefaultLevel() { static Level getDefaultLevel() {
String levelName = AccessController.doPrivileged( String levelName = GetPropertyAction
new GetPropertyAction("jdk.system.logger.level", "INFO")); .getProperty("jdk.system.logger.level", "INFO");
try { try {
return Level.valueOf(levelName); return Level.valueOf(levelName);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
@ -425,8 +425,8 @@ public class SimpleConsoleLogger extends LoggerConfiguration
// Make it easier to wrap Logger... // Make it easier to wrap Logger...
static private final String[] skips; static private final String[] skips;
static { static {
String additionalPkgs = AccessController.doPrivileged( String additionalPkgs =
new GetPropertyAction("jdk.logger.packages")); GetPropertyAction.getProperty("jdk.logger.packages");
skips = additionalPkgs == null ? new String[0] : additionalPkgs.split(","); skips = additionalPkgs == null ? new String[0] : additionalPkgs.split(",");
} }
@ -485,7 +485,7 @@ public class SimpleConsoleLogger extends LoggerConfiguration
// jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java // jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java
// to fail - because that test has a testcase which somehow references // to fail - because that test has a testcase which somehow references
// PlatformLogger and counts the number of generated lambda classes. // PlatformLogger and counts the number of generated lambda classes.
String format = AccessController.doPrivileged(new GetPropertyAction(key)); String format = GetPropertyAction.getProperty(key);
if (format == null && defaultPropertyGetter != null) { if (format == null && defaultPropertyGetter != null) {
format = defaultPropertyGetter.apply(key); format = defaultPropertyGetter.apply(key);

View file

@ -27,13 +27,12 @@ package jdk.internal.reflect;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.VM; import jdk.internal.misc.VM;
import sun.security.action.GetPropertyAction;
/** Common utility routines used by both java.lang and /** Common utility routines used by both java.lang and
java.lang.reflect */ java.lang.reflect */
@ -344,15 +343,10 @@ public class Reflection {
private static void printStackTraceIfNeeded(Throwable e) { private static void printStackTraceIfNeeded(Throwable e) {
if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) { if (!printStackWhenAccessFailsSet && VM.initLevel() >= 1) {
// can't use method reference here, might be too early in startup String s = GetPropertyAction
PrivilegedAction<Boolean> pa = new PrivilegedAction<Boolean>() { .getProperty("sun.reflect.debugModuleAccessChecks");
public Boolean run() { printStackWhenAccessFails =
String s; (s != null && !s.equalsIgnoreCase("false"));
s = System.getProperty("sun.reflect.debugModuleAccessChecks");
return (s != null && !s.equalsIgnoreCase("false"));
}
};
printStackWhenAccessFails = AccessController.doPrivileged(pa);
printStackWhenAccessFailsSet = true; printStackWhenAccessFailsSet = true;
} }
if (printStackWhenAccessFails) { if (printStackWhenAccessFails) {

View file

@ -30,10 +30,11 @@ import java.lang.reflect.Executable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.Permission; import java.security.Permission;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.Properties;
import sun.reflect.misc.ReflectUtil; import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetPropertyAction;
/** <P> The master factory for all reflective objects, both those in /** <P> The master factory for all reflective objects, both those in
java.lang.reflect (Fields, Methods, Constructors) as well as their java.lang.reflect (Fields, Methods, Constructors) as well as their
@ -382,9 +383,7 @@ public class ReflectionFactory {
run, before the system properties are set up. */ run, before the system properties are set up. */
private static void checkInitted() { private static void checkInitted() {
if (initted) return; if (initted) return;
AccessController.doPrivileged(
new PrivilegedAction<>() {
public Void run() {
// Tests to ensure the system properties table is fully // Tests to ensure the system properties table is fully
// initialized. This is needed because reflection code is // initialized. This is needed because reflection code is
// called very early in the initialization process (before // called very early in the initialization process (before
@ -396,15 +395,16 @@ public class ReflectionFactory {
if (System.out == null) { if (System.out == null) {
// java.lang.System not yet fully initialized // java.lang.System not yet fully initialized
return null; return;
} }
String val = System.getProperty("sun.reflect.noInflation"); Properties props = GetPropertyAction.getProperties();
String val = props.getProperty("sun.reflect.noInflation");
if (val != null && val.equals("true")) { if (val != null && val.equals("true")) {
noInflation = true; noInflation = true;
} }
val = System.getProperty("sun.reflect.inflationThreshold"); val = props.getProperty("sun.reflect.inflationThreshold");
if (val != null) { if (val != null) {
try { try {
inflationThreshold = Integer.parseInt(val); inflationThreshold = Integer.parseInt(val);
@ -414,9 +414,6 @@ public class ReflectionFactory {
} }
initted = true; initted = true;
return null;
}
});
} }
private static LangReflectAccess langReflectAccess() { private static LangReflectAccess langReflectAccess() {

View file

@ -53,9 +53,8 @@ public class ResourceManager {
private static final AtomicInteger numSockets; private static final AtomicInteger numSockets;
static { static {
String prop = java.security.AccessController.doPrivileged( String prop =
new GetPropertyAction("sun.net.maxDatagramSockets") GetPropertyAction.getProperty("sun.net.maxDatagramSockets");
);
int defmax = DEFAULT_MAX_SOCKETS; int defmax = DEFAULT_MAX_SOCKETS;
try { try {
if (prop != null) { if (prop != null) {

View file

@ -31,6 +31,7 @@ import java.security.AccessController;
import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaIOFileDescriptorAccess; import jdk.internal.misc.JavaIOFileDescriptorAccess;
import sun.security.action.GetPropertyAction;
/** /**
@ -39,8 +40,7 @@ import jdk.internal.misc.JavaIOFileDescriptorAccess;
*/ */
public final class SdpSupport { public final class SdpSupport {
private static final String os = AccessController private static final String os = GetPropertyAction.getProperty("os.name");
.doPrivileged(new sun.security.action.GetPropertyAction("os.name"));
private static final boolean isSupported = (os.equals("SunOS") || (os.equals("Linux"))); private static final boolean isSupported = (os.equals("SunOS") || (os.equals("Linux")));
private static final JavaIOFileDescriptorAccess fdAccess = private static final JavaIOFileDescriptorAccess fdAccess =
SharedSecrets.getJavaIOFileDescriptorAccess(); SharedSecrets.getJavaIOFileDescriptorAccess();

View file

@ -25,10 +25,10 @@
package sun.net.smtp; package sun.net.smtp;
import java.util.StringTokenizer;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import sun.net.TransferProtocolClient; import sun.net.TransferProtocolClient;
import sun.security.action.GetPropertyAction;
/** /**
* This class implements the SMTP client. * This class implements the SMTP client.
@ -157,8 +157,7 @@ public class SmtpClient extends TransferProtocolClient {
} }
try { try {
String s; String s;
mailhost = java.security.AccessController.doPrivileged( mailhost = GetPropertyAction.getProperty("mail.host");
new sun.security.action.GetPropertyAction("mail.host"));
if (mailhost != null) { if (mailhost != null) {
openServer(mailhost); openServer(mailhost);
return; return;
@ -184,8 +183,7 @@ public class SmtpClient extends TransferProtocolClient {
setConnectTimeout(to); setConnectTimeout(to);
try { try {
String s; String s;
mailhost = java.security.AccessController.doPrivileged( mailhost = GetPropertyAction.getProperty("mail.host");
new sun.security.action.GetPropertyAction("mail.host"));
if (mailhost != null) { if (mailhost != null) {
openServer(mailhost); openServer(mailhost);
return; return;

View file

@ -27,6 +27,7 @@ package sun.net.www;
import java.net.URL; import java.net.URL;
import java.io.*; import java.io.*;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import sun.security.action.GetPropertyAction;
class MimeLauncher extends Thread { class MimeLauncher extends Thread {
java.net.URLConnection uc; java.net.URLConnection uc;
@ -182,8 +183,7 @@ class MimeLauncher extends Thread {
} }
String execPathList; String execPathList;
execPathList = java.security.AccessController.doPrivileged( execPathList = GetPropertyAction.getProperty("exec.path");
new sun.security.action.GetPropertyAction("exec.path"));
if (execPathList == null) { if (execPathList == null) {
// exec.path property not set // exec.path property not set
return false; return false;

View file

@ -28,6 +28,7 @@ package sun.net.www.http;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.Locale; import java.util.Locale;
import java.util.Properties;
import sun.net.NetworkClient; import sun.net.NetworkClient;
import sun.net.ProgressSource; import sun.net.ProgressSource;
import sun.net.www.MessageHeader; import sun.net.www.MessageHeader;
@ -37,6 +38,7 @@ import sun.net.www.ParseUtil;
import sun.net.www.protocol.http.HttpURLConnection; import sun.net.www.protocol.http.HttpURLConnection;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*; import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*;
import sun.security.action.GetPropertyAction;
/** /**
* @author Herb Jellinek * @author Herb Jellinek
@ -143,20 +145,18 @@ public class HttpClient extends NetworkClient {
} }
static { static {
String keepAlive = java.security.AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new sun.security.action.GetPropertyAction("http.keepAlive")); String keepAlive = props.getProperty("http.keepAlive");
String retryPost = props.getProperty("sun.net.http.retryPost");
String retryPost = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.net.http.retryPost"));
if (keepAlive != null) { if (keepAlive != null) {
keepAliveProp = Boolean.valueOf(keepAlive).booleanValue(); keepAliveProp = Boolean.parseBoolean(keepAlive);
} else { } else {
keepAliveProp = true; keepAliveProp = true;
} }
if (retryPost != null) { if (retryPost != null) {
retryPostProp = Boolean.valueOf(retryPost).booleanValue(); retryPostProp = Boolean.parseBoolean(retryPost);
} else } else
retryPostProp = true; retryPostProp = true;

View file

@ -46,6 +46,7 @@ import java.net.ProxySelector;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Iterator; import java.util.Iterator;
import java.security.Permission; import java.security.Permission;
import java.util.Properties;
import sun.net.NetworkClient; import sun.net.NetworkClient;
import sun.net.www.MessageHeader; import sun.net.www.MessageHeader;
import sun.net.www.MeteredStream; import sun.net.www.MeteredStream;
@ -277,11 +278,10 @@ public class FtpURLConnection extends URLConnection {
if (user == null) { if (user == null) {
user = "anonymous"; user = "anonymous";
String vers = java.security.AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new GetPropertyAction("java.version")); String vers = props.getProperty("java.version");
password = java.security.AccessController.doPrivileged( password = props.getProperty("ftp.protocol.user",
new GetPropertyAction("ftp.protocol.user", "Java" + vers + "@");
"Java" + vers + "@"));
} }
try { try {
ftp = FtpClient.create(); ftp = FtpClient.create();

View file

@ -25,9 +25,10 @@
package sun.net.www.protocol.http; package sun.net.www.protocol.http;
import sun.net.www.*;
import java.util.Iterator; import java.util.Iterator;
import java.util.HashMap; import java.util.HashMap;
import sun.net.www.*;
import sun.security.action.GetPropertyAction;
/** /**
* This class is used to parse the information in WWW-Authenticate: and Proxy-Authenticate: * This class is used to parse the information in WWW-Authenticate: and Proxy-Authenticate:
@ -93,8 +94,7 @@ public class AuthenticationHeader {
} }
static { static {
authPref = java.security.AccessController.doPrivileged( authPref = GetPropertyAction.getProperty("http.auth.preference");
new sun.security.action.GetPropertyAction("http.auth.preference"));
// http.auth.preference can be set to SPNEGO or Kerberos. // http.auth.preference can be set to SPNEGO or Kerberos.
// In fact they means "Negotiate with SPNEGO" and "Negotiate with // In fact they means "Negotiate with SPNEGO" and "Negotiate with

View file

@ -52,7 +52,6 @@ import java.security.AccessController;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException; import java.security.PrivilegedActionException;
import java.io.*; import java.io.*;
import java.net.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
@ -78,12 +77,15 @@ import java.text.SimpleDateFormat;
import java.util.TimeZone; import java.util.TimeZone;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Properties;
import static sun.net.www.protocol.http.AuthScheme.BASIC; import static sun.net.www.protocol.http.AuthScheme.BASIC;
import static sun.net.www.protocol.http.AuthScheme.DIGEST; import static sun.net.www.protocol.http.AuthScheme.DIGEST;
import static sun.net.www.protocol.http.AuthScheme.NTLM; import static sun.net.www.protocol.http.AuthScheme.NTLM;
import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
import static sun.net.www.protocol.http.AuthScheme.KERBEROS; import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
import static sun.net.www.protocol.http.AuthScheme.UNKNOWN; import static sun.net.www.protocol.http.AuthScheme.UNKNOWN;
import sun.security.action.GetIntegerAction;
import sun.security.action.GetPropertyAction;
/** /**
* A class to represent an HTTP connection to a remote object. * A class to represent an HTTP connection to a remote object.
@ -205,46 +207,38 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}; };
static { static {
maxRedirects = java.security.AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new sun.security.action.GetIntegerAction( maxRedirects = GetIntegerAction.getProperty("http.maxRedirects",
"http.maxRedirects", defaultmaxRedirects)).intValue(); defaultmaxRedirects);
version = java.security.AccessController.doPrivileged( version = props.getProperty("java.version");
new sun.security.action.GetPropertyAction("java.version")); String agent = props.getProperty("http.agent");
String agent = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.agent"));
if (agent == null) { if (agent == null) {
agent = "Java/"+version; agent = "Java/"+version;
} else { } else {
agent = agent + " Java/"+version; agent = agent + " Java/"+version;
} }
userAgent = agent; userAgent = agent;
validateProxy = java.security.AccessController.doPrivileged( validateProxy = Boolean.parseBoolean(
new sun.security.action.GetBooleanAction( props.getProperty("http.auth.digest.validateProxy"));
"http.auth.digest.validateProxy")).booleanValue(); validateServer = Boolean.parseBoolean(
validateServer = java.security.AccessController.doPrivileged( props.getProperty("http.auth.digest.validateServer"));
new sun.security.action.GetBooleanAction(
"http.auth.digest.validateServer")).booleanValue();
enableESBuffer = java.security.AccessController.doPrivileged( enableESBuffer = Boolean.parseBoolean(
new sun.security.action.GetBooleanAction( props.getProperty("sun.net.http.errorstream.enableBuffering"));
"sun.net.http.errorstream.enableBuffering")).booleanValue(); timeout4ESBuffer = GetIntegerAction
timeout4ESBuffer = java.security.AccessController.doPrivileged( .getProperty("sun.net.http.errorstream.timeout", 300);
new sun.security.action.GetIntegerAction(
"sun.net.http.errorstream.timeout", 300)).intValue();
if (timeout4ESBuffer <= 0) { if (timeout4ESBuffer <= 0) {
timeout4ESBuffer = 300; // use the default timeout4ESBuffer = 300; // use the default
} }
bufSize4ES = java.security.AccessController.doPrivileged( bufSize4ES = GetIntegerAction
new sun.security.action.GetIntegerAction( .getProperty("sun.net.http.errorstream.bufferSize", 4096);
"sun.net.http.errorstream.bufferSize", 4096)).intValue();
if (bufSize4ES <= 0) { if (bufSize4ES <= 0) {
bufSize4ES = 4096; // use the default bufSize4ES = 4096; // use the default
} }
allowRestrictedHeaders = java.security.AccessController.doPrivileged( allowRestrictedHeaders = Boolean.parseBoolean(
new sun.security.action.GetBooleanAction( props.getProperty("sun.net.http.allowRestrictedHeaders"));
"sun.net.http.allowRestrictedHeaders")).booleanValue();
if (!allowRestrictedHeaders) { if (!allowRestrictedHeaders) {
restrictedHeaderSet = new HashSet<>(restrictedHeaders.length); restrictedHeaderSet = new HashSet<>(restrictedHeaders.length);
for (int i=0; i < restrictedHeaders.length; i++) { for (int i=0; i < restrictedHeaders.length; i++) {

View file

@ -41,7 +41,6 @@ import java.security.Principal;
import java.security.cert.*; import java.security.cert.*;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import java.security.AccessController;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
@ -139,8 +138,8 @@ final class HttpsClient extends HttpClient
// If ciphers are assigned, sort them into an array. // If ciphers are assigned, sort them into an array.
// //
String ciphers []; String ciphers [];
String cipherString = AccessController.doPrivileged( String cipherString =
new GetPropertyAction("https.cipherSuites")); GetPropertyAction.getProperty("https.cipherSuites");
if (cipherString == null || "".equals(cipherString)) { if (cipherString == null || "".equals(cipherString)) {
ciphers = null; ciphers = null;
@ -163,8 +162,8 @@ final class HttpsClient extends HttpClient
// If protocols are assigned, sort them into an array. // If protocols are assigned, sort them into an array.
// //
String protocols []; String protocols [];
String protocolString = AccessController.doPrivileged( String protocolString =
new GetPropertyAction("https.protocols")); GetPropertyAction.getProperty("https.protocols");
if (protocolString == null || "".equals(protocolString)) { if (protocolString == null || "".equals(protocolString)) {
protocols = null; protocols = null;
@ -184,8 +183,7 @@ final class HttpsClient extends HttpClient
} }
private String getUserAgent() { private String getUserAgent() {
String userAgent = java.security.AccessController.doPrivileged( String userAgent = GetPropertyAction.getProperty("https.agent");
new sun.security.action.GetPropertyAction("https.agent"));
if (userAgent == null || userAgent.length() == 0) { if (userAgent == null || userAgent.length() == 0) {
userAgent = "JSSE"; userAgent = "JSSE";
} }

View file

@ -32,10 +32,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.security.AccessController;
import java.security.Permission; import java.security.Permission;
import java.security.PrivilegedAction;
import java.util.List;
import jdk.internal.jimage.ImageLocation; import jdk.internal.jimage.ImageLocation;
import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReader;
@ -45,6 +42,7 @@ import jdk.internal.loader.URLClassPath;
import jdk.internal.loader.Resource; import jdk.internal.loader.Resource;
import sun.net.www.ParseUtil; import sun.net.www.ParseUtil;
import sun.net.www.URLConnection; import sun.net.www.URLConnection;
import sun.security.action.GetPropertyAction;
/** /**
* URLConnection implementation that can be used to connect to resources * URLConnection implementation that can be used to connect to resources
@ -163,11 +161,7 @@ public class JavaRuntimeURLConnection extends URLConnection {
public Permission getPermission() throws IOException { public Permission getPermission() throws IOException {
Permission p = permission; Permission p = permission;
if (p == null) { if (p == null) {
// using lambda expression here leads to recursive initialization String home = GetPropertyAction.getProperty("java.home");
PrivilegedAction<String> pa = new PrivilegedAction<String>() {
public String run() { return System.getProperty("java.home"); }
};
String home = AccessController.doPrivileged(pa);
p = new FilePermission(home + File.separator + "-", "read"); p = new FilePermission(home + File.separator + "-", "read");
permission = p; permission = p;
} }

View file

@ -40,6 +40,7 @@ import java.net.MalformedURLException;
import java.net.URLStreamHandler; import java.net.URLStreamHandler;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import sun.security.action.GetPropertyAction;
public class Handler extends URLStreamHandler { public class Handler extends URLStreamHandler {
static URL base; static URL base;
@ -54,12 +55,10 @@ public class Handler extends URLStreamHandler {
URLConnection uc = null; URLConnection uc = null;
URL ru; URL ru;
Boolean tmp = java.security.AccessController.doPrivileged( boolean localonly = Boolean.parseBoolean(
new sun.security.action.GetBooleanAction("newdoc.localonly")); GetPropertyAction.getProperty("newdoc.localonly"));
boolean localonly = tmp.booleanValue();
String docurl = java.security.AccessController.doPrivileged( String docurl = GetPropertyAction.getProperty("doc.url");
new sun.security.action.GetPropertyAction("doc.url"));
String file = u.getFile(); String file = u.getFile();
if (!localonly) { if (!localonly) {

View file

@ -1019,9 +1019,8 @@ public class FileChannelImpl
if (!propertyChecked) { if (!propertyChecked) {
synchronized (FileChannelImpl.class) { synchronized (FileChannelImpl.class) {
if (!propertyChecked) { if (!propertyChecked) {
String value = AccessController.doPrivileged( String value = GetPropertyAction.getProperty(
new GetPropertyAction( "sun.nio.ch.disableSystemWideOverlappingFileLockCheck");
"sun.nio.ch.disableSystemWideOverlappingFileLockCheck"));
isSharedFileLockTable = ((value == null) || value.equals("false")); isSharedFileLockTable = ((value == null) || value.equals("false"));
propertyChecked = true; propertyChecked = true;
} }

View file

@ -33,6 +33,7 @@ import java.util.*;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import sun.net.ExtendedOptionsImpl; import sun.net.ExtendedOptionsImpl;
import sun.security.action.GetPropertyAction;
public class Net { public class Net {
@ -382,13 +383,8 @@ public class Net {
} }
public static boolean isFastTcpLoopbackRequested() { public static boolean isFastTcpLoopbackRequested() {
String loopbackProp = java.security.AccessController.doPrivileged( String loopbackProp =
new PrivilegedAction<String>() { GetPropertyAction.getProperty("jdk.net.useFastTcpLoopback");
@Override
public String run() {
return System.getProperty("jdk.net.useFastTcpLoopback");
}
});
boolean enable; boolean enable;
if ("".equals(loopbackProp)) { if ("".equals(loopbackProp)) {
enable = true; enable = true;
@ -647,16 +643,9 @@ public class Net {
int availLevel = isExclusiveBindAvailable(); int availLevel = isExclusiveBindAvailable();
if (availLevel >= 0) { if (availLevel >= 0) {
String exclBindProp = String exclBindProp =
java.security.AccessController.doPrivileged( GetPropertyAction.getProperty("sun.net.useExclusiveBind");
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(
"sun.net.useExclusiveBind");
}
});
if (exclBindProp != null) { if (exclBindProp != null) {
exclusiveBind = exclBindProp.length() == 0 ? exclusiveBind = exclBindProp.isEmpty() ?
true : Boolean.parseBoolean(exclBindProp); true : Boolean.parseBoolean(exclBindProp);
} else if (availLevel == 1) { } else if (availLevel == 1) {
exclusiveBind = true; exclusiveBind = true;

View file

@ -64,13 +64,7 @@ public class Util {
* for potential future-proofing. * for potential future-proofing.
*/ */
private static long getMaxCachedBufferSize() { private static long getMaxCachedBufferSize() {
String s = java.security.AccessController.doPrivileged( String s = GetPropertyAction.getProperty("jdk.nio.maxCachedBufferSize");
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty("jdk.nio.maxCachedBufferSize");
}
});
if (s != null) { if (s != null) {
try { try {
long m = Long.parseLong(s); long m = Long.parseLong(s);
@ -471,8 +465,7 @@ public class Util {
if (bugLevel == null) { if (bugLevel == null) {
if (!jdk.internal.misc.VM.isBooted()) if (!jdk.internal.misc.VM.isBooted())
return false; return false;
String value = AccessController.doPrivileged( String value = GetPropertyAction.getProperty("sun.nio.ch.bugLevel");
new GetPropertyAction("sun.nio.ch.bugLevel"));
bugLevel = (value != null) ? value : ""; bugLevel = (value != null) ? value : "";
} }
return bugLevel.equals(bl); return bugLevel.equals(bl);

View file

@ -34,8 +34,7 @@ import java.nio.charset.spi.CharsetProvider;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.security.AccessController; import sun.security.action.GetPropertyAction;
import java.security.PrivilegedAction;
public class StandardCharsets extends CharsetProvider { public class StandardCharsets extends CharsetProvider {
@ -201,15 +200,7 @@ public class StandardCharsets extends CharsetProvider {
} }
private static String getProperty(String key) { private static String getProperty(String key) {
// this method may be called during initialization of return GetPropertyAction.getProperty(key);
// system class loader and thus not using lambda
return AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(key);
}
});
} }

View file

@ -28,8 +28,7 @@ package sun.nio.fs;
import java.util.*; import java.util.*;
import java.nio.file.*; import java.nio.file.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.*; import sun.security.action.GetPropertyAction;
import sun.security.action.*;
/** /**
* Utility methods * Utility methods
@ -39,7 +38,7 @@ class Util {
private Util() { } private Util() { }
private static final Charset jnuEncoding = Charset.forName( private static final Charset jnuEncoding = Charset.forName(
AccessController.doPrivileged(new GetPropertyAction("sun.jnu.encoding"))); GetPropertyAction.getProperty("sun.jnu.encoding"));
/** /**
* Returns {@code Charset} corresponding to the sun.jnu.encoding property * Returns {@code Charset} corresponding to the sun.jnu.encoding property

View file

@ -25,6 +25,8 @@
package sun.security.action; package sun.security.action;
import java.security.AccessController;
/** /**
* A convenience class for retrieving the integer value of a system property * A convenience class for retrieving the integer value of a system property
* as a privileged action. * as a privileged action.
@ -67,7 +69,7 @@ public class GetIntegerAction
implements java.security.PrivilegedAction<Integer> { implements java.security.PrivilegedAction<Integer> {
private String theProp; private String theProp;
private int defaultVal; private int defaultVal;
private boolean defaultSet = false; private boolean defaultSet;
/** /**
* Constructor that takes the name of the system property whose integer * Constructor that takes the name of the system property whose integer
@ -110,4 +112,39 @@ public class GetIntegerAction
return defaultVal; return defaultVal;
return value; return value;
} }
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
*/
public static Integer getProperty(String theProp) {
if (System.getSecurityManager() == null) {
return Integer.getInteger(theProp);
} else {
return AccessController.doPrivileged(
new GetIntegerAction(theProp));
}
}
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
* @param defaultVal the default value.
*/
public static Integer getProperty(String theProp, int defaultVal) {
Integer value;
if (System.getSecurityManager() == null) {
value = Integer.getInteger(theProp);
} else {
value = AccessController.doPrivileged(
new GetIntegerAction(theProp));
}
return (value != null) ? value : defaultVal;
}
} }

View file

@ -25,6 +25,10 @@
package sun.security.action; package sun.security.action;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Properties;
/** /**
* A convenience class for retrieving the string value of a system * A convenience class for retrieving the string value of a system
* property as a privileged action. * property as a privileged action.
@ -46,8 +50,7 @@ package sun.security.action;
* @since 1.2 * @since 1.2
*/ */
public class GetPropertyAction public class GetPropertyAction implements PrivilegedAction<String> {
implements java.security.PrivilegedAction<String> {
private String theProp; private String theProp;
private String defaultVal; private String defaultVal;
@ -84,4 +87,57 @@ public class GetPropertyAction
String value = System.getProperty(theProp); String value = System.getProperty(theProp);
return (value == null) ? defaultVal : value; return (value == null) ? defaultVal : value;
} }
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
*/
public static String getProperty(String theProp) {
if (System.getSecurityManager() == null) {
return System.getProperty(theProp);
} else {
return AccessController.doPrivileged(
new GetPropertyAction(theProp));
}
}
/**
* Convenience method to get a property without going through doPrivileged
* if no security manager is present. This is unsafe for inclusion in a
* public API but allowable here since this class is now encapsulated.
*
* @param theProp the name of the system property.
* @param defaultVal the default value.
*/
public static String getProperty(String theProp, String defaultVal) {
if (System.getSecurityManager() == null) {
return System.getProperty(theProp, defaultVal);
} else {
return AccessController.doPrivileged(
new GetPropertyAction(theProp, defaultVal));
}
}
/**
* Convenience method to call <code>System.getProperties</code> without
* having to go through doPrivileged if no security manager is present.
* This is unsafe for inclusion in a public API but allowable here since
* this class is now encapsulated.
*/
public static Properties getProperties() {
if (System.getSecurityManager() == null) {
return System.getProperties();
} else {
return AccessController.doPrivileged(
new PrivilegedAction<Properties>() {
public Properties run() {
return System.getProperties();
}
}
);
}
}
} }

View file

@ -70,8 +70,7 @@ public class DSAKeyFactory extends KeyFactorySpi {
* By default this is false. * By default this is false.
* This incompatibility was introduced by 4532506. * This incompatibility was introduced by 4532506.
*/ */
String prop = AccessController.doPrivileged String prop = GetPropertyAction.getProperty(SERIAL_PROP);
(new GetPropertyAction(SERIAL_PROP, null));
SERIAL_INTEROP = "true".equalsIgnoreCase(prop); SERIAL_INTEROP = "true".equalsIgnoreCase(prop);
} }

View file

@ -84,9 +84,8 @@ public final class RSAKeyFactory extends KeyFactorySpi {
public static final int MAX_RESTRICTED_EXPLEN = 64; public static final int MAX_RESTRICTED_EXPLEN = 64;
private static final boolean restrictExpLen = private static final boolean restrictExpLen =
"true".equalsIgnoreCase(AccessController.doPrivileged( "true".equalsIgnoreCase(GetPropertyAction.getProperty(
new GetPropertyAction( "sun.security.rsa.restrictRSAExponent", "true"));
"sun.security.rsa.restrictRSAExponent", "true")));
// instance used for static translateKey(); // instance used for static translateKey();
private static final RSAKeyFactory INSTANCE = new RSAKeyFactory(); private static final RSAKeyFactory INSTANCE = new RSAKeyFactory();

View file

@ -50,10 +50,7 @@ public interface ClientKeyExchangeService {
providers = new HashMap<>(); providers = new HashMap<>();
static { static {
final String key = "java.home"; String path = GetPropertyAction.getProperty("java.home");
String path = AccessController.doPrivileged(
new GetPropertyAction(key), null,
new PropertyPermission(key, "read"));
ServiceLoader<ClientKeyExchangeService> sc = ServiceLoader<ClientKeyExchangeService> sc =
AccessController.doPrivileged( AccessController.doPrivileged(
(PrivilegedAction<ServiceLoader<ClientKeyExchangeService>>) (PrivilegedAction<ServiceLoader<ClientKeyExchangeService>>)

View file

@ -26,7 +26,6 @@
package sun.security.ssl; package sun.security.ssl;
import java.io.PrintStream; import java.io.PrintStream;
import java.security.AccessController;
import java.util.Locale; import java.util.Locale;
import sun.security.util.HexDumpEncoder; import sun.security.util.HexDumpEncoder;
@ -46,8 +45,7 @@ public class Debug {
private static String args; private static String args;
static { static {
args = java.security.AccessController.doPrivileged( args = GetPropertyAction.getProperty("javax.net.debug", "");
new GetPropertyAction("javax.net.debug", ""));
args = args.toLowerCase(Locale.ENGLISH); args = args.toLowerCase(Locale.ENGLISH);
if (args.equals("help")) { if (args.equals("help")) {
Help(); Help();
@ -184,8 +182,7 @@ public class Debug {
*/ */
static boolean getBooleanProperty(String propName, boolean defaultValue) { static boolean getBooleanProperty(String propName, boolean defaultValue) {
// if set, require value of either true or false // if set, require value of either true or false
String b = AccessController.doPrivileged( String b = GetPropertyAction.getProperty(propName);
new GetPropertyAction(propName));
if (b == null) { if (b == null) {
return defaultValue; return defaultValue;
} else if (b.equalsIgnoreCase("false")) { } else if (b.equalsIgnoreCase("false")) {

View file

@ -656,8 +656,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
// the provider service. Instead, please handle the initialization // the provider service. Instead, please handle the initialization
// exception in the caller's constructor. // exception in the caller's constructor.
static { static {
String property = AccessController.doPrivileged( String property = GetPropertyAction.getProperty(PROPERTY_NAME);
new GetPropertyAction(PROPERTY_NAME));
if (property != null && property.length() != 0) { if (property != null && property.length() != 0) {
// remove double quote marks from beginning/end of the property // remove double quote marks from beginning/end of the property
if (property.length() > 1 && property.charAt(0) == '"' && if (property.length() > 1 && property.charAt(0) == '"' &&

View file

@ -119,8 +119,8 @@ final class ServerHandshaker extends Handshaker {
private long statusRespTimeout; private long statusRespTimeout;
static { static {
String property = AccessController.doPrivileged( String property =
new GetPropertyAction("jdk.tls.ephemeralDHKeySize")); GetPropertyAction.getProperty("jdk.tls.ephemeralDHKeySize");
if (property == null || property.length() == 0) { if (property == null || property.length() == 0) {
useLegacyEphemeralDHKeys = false; useLegacyEphemeralDHKeys = false;
useSmartEphemeralDHKeys = false; useSmartEphemeralDHKeys = false;

View file

@ -73,8 +73,8 @@ final class StatusResponseManager {
DEFAULT_CACHE_LIFETIME)); DEFAULT_CACHE_LIFETIME));
cacheLifetime = life > 0 ? life : 0; cacheLifetime = life > 0 ? life : 0;
String uriStr = AccessController.doPrivileged( String uriStr =
new GetPropertyAction("jdk.tls.stapling.responderURI")); GetPropertyAction.getProperty("jdk.tls.stapling.responderURI");
URI tmpURI; URI tmpURI;
try { try {
tmpURI = ((uriStr != null && !uriStr.isEmpty()) ? tmpURI = ((uriStr != null && !uriStr.isEmpty()) ?

View file

@ -29,6 +29,7 @@ import java.math.BigInteger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.Locale; import java.util.Locale;
import sun.security.action.GetPropertyAction;
/** /**
* A utility class for debuging. * A utility class for debuging.
@ -42,13 +43,10 @@ public class Debug {
private static String args; private static String args;
static { static {
args = java.security.AccessController.doPrivileged args = GetPropertyAction.getProperty("java.security.debug");
(new sun.security.action.GetPropertyAction
("java.security.debug"));
String args2 = java.security.AccessController.doPrivileged String args2 =
(new sun.security.action.GetPropertyAction GetPropertyAction.getProperty("java.security.auth.debug");
("java.security.auth.debug"));
if (args == null) { if (args == null) {
args = args2; args = args2;

View file

@ -27,6 +27,7 @@ package sun.util.calendar;
import java.security.AccessController; import java.security.AccessController;
import java.util.TimeZone; import java.util.TimeZone;
import sun.security.action.GetPropertyAction;
/** /**
* *
@ -142,8 +143,8 @@ public class LocalGregorianCalendar extends BaseCalendar {
} }
// Append an era to the predefined eras if it's given by the property. // Append an era to the predefined eras if it's given by the property.
String prop = AccessController.doPrivileged( String prop = GetPropertyAction
new sun.security.action.GetPropertyAction("jdk.calendar.japanese.supplemental.era")); .getProperty("jdk.calendar.japanese.supplemental.era");
if (prop != null) { if (prop != null) {
Era era = parseEraEntry(prop); Era era = parseEraEntry(prop);
if (era != null) { if (era != null) {

View file

@ -245,11 +245,8 @@ public final class ZoneInfoFile {
}; };
static { static {
String oldmapping = AccessController.doPrivileged( USE_OLDMAPPING = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
new GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT); public Boolean run() {
USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
try { try {
String libDir = System.getProperty("java.home") + File.separator + "lib"; String libDir = System.getProperty("java.home") + File.separator + "lib";
try (DataInputStream dis = new DataInputStream( try (DataInputStream dis = new DataInputStream(
@ -260,7 +257,9 @@ public final class ZoneInfoFile {
} catch (Exception x) { } catch (Exception x) {
throw new Error(x); throw new Error(x);
} }
return null; String oldmapping = System.getProperty("sun.timezone.ids.oldmapping", "false")
.toLowerCase(Locale.ROOT);
return (oldmapping.equals("yes") || oldmapping.equals("true"));
} }
}); });
} }

View file

@ -25,7 +25,6 @@
package sun.util.locale.provider; package sun.util.locale.provider;
import java.security.AccessController;
import java.text.spi.BreakIteratorProvider; import java.text.spi.BreakIteratorProvider;
import java.text.spi.CollatorProvider; import java.text.spi.CollatorProvider;
import java.text.spi.DateFormatProvider; import java.text.spi.DateFormatProvider;
@ -47,6 +46,7 @@ import java.util.spi.CurrencyNameProvider;
import java.util.spi.LocaleNameProvider; import java.util.spi.LocaleNameProvider;
import java.util.spi.LocaleServiceProvider; import java.util.spi.LocaleServiceProvider;
import java.util.spi.TimeZoneNameProvider; import java.util.spi.TimeZoneNameProvider;
import sun.security.action.GetPropertyAction;
import sun.util.spi.CalendarProvider; import sun.util.spi.CalendarProvider;
/** /**
@ -116,8 +116,7 @@ public abstract class LocaleProviderAdapter {
adapterCache = new ConcurrentHashMap<>(); adapterCache = new ConcurrentHashMap<>();
static { static {
String order = AccessController.doPrivileged( String order = GetPropertyAction.getProperty("java.locale.providers");
new sun.security.action.GetPropertyAction("java.locale.providers"));
List<Type> typeList = new ArrayList<>(); List<Type> typeList = new ArrayList<>();
// Check user specified adapter preference // Check user specified adapter preference

View file

@ -28,7 +28,6 @@ package sun.nio.fs;
import java.nio.file.*; import java.nio.file.*;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.security.AccessController;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
import static sun.nio.fs.SolarisNativeDispatcher.*; import static sun.nio.fs.SolarisNativeDispatcher.*;
@ -43,8 +42,7 @@ class SolarisFileSystem extends UnixFileSystem {
super(provider, dir); super(provider, dir);
// check os.version // check os.version
String osversion = AccessController String osversion = GetPropertyAction.getProperty("os.version");
.doPrivileged(new GetPropertyAction("os.version"));
String[] vers = Util.split(osversion, '.'); String[] vers = Util.split(osversion, '.');
assert vers.length >= 2; assert vers.length >= 2;
int majorVersion = Integer.parseInt(vers[0]); int majorVersion = Integer.parseInt(vers[0]);

View file

@ -29,7 +29,6 @@ import java.nio.file.*;
import java.nio.file.attribute.*; import java.nio.file.attribute.*;
import java.nio.file.spi.FileTypeDetector; import java.nio.file.spi.FileTypeDetector;
import java.io.IOException; import java.io.IOException;
import java.security.AccessController;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -85,8 +84,8 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
@Override @Override
FileTypeDetector getFileTypeDetector() { FileTypeDetector getFileTypeDetector() {
Path userMimeTypes = Paths.get(AccessController.doPrivileged( Path userMimeTypes = Paths.get(
new GetPropertyAction("user.home")), ".mime.types"); GetPropertyAction.getProperty("user.home"), ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types"); Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GioFileTypeDetector(), return chain(new GioFileTypeDetector(),

View file

@ -25,7 +25,7 @@
package java.io; package java.io;
import java.security.AccessController; import java.util.Properties;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
@ -36,12 +36,10 @@ class UnixFileSystem extends FileSystem {
private final String javaHome; private final String javaHome;
public UnixFileSystem() { public UnixFileSystem() {
slash = AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new GetPropertyAction("file.separator")).charAt(0); slash = props.getProperty("file.separator").charAt(0);
colon = AccessController.doPrivileged( colon = props.getProperty("path.separator").charAt(0);
new GetPropertyAction("path.separator")).charAt(0); javaHome = props.getProperty("java.home");
javaHome = AccessController.doPrivileged(
new GetPropertyAction("java.home"));
} }

View file

@ -46,8 +46,10 @@ import static java.security.AccessController.doPrivileged;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.security.PrivilegedActionException; import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Properties;
import jdk.internal.misc.JavaIOFileDescriptorAccess; import jdk.internal.misc.JavaIOFileDescriptorAccess;
import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.SharedSecrets;
import sun.security.action.GetPropertyAction;
/** /**
* java.lang.Process subclass in the UNIX environment. * java.lang.Process subclass in the UNIX environment.
@ -123,11 +125,9 @@ final class ProcessImpl extends Process {
} }
String helperPath() { String helperPath() {
return AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
(PrivilegedAction<String>) () -> return helperPath(props.getProperty("java.home"),
helperPath(System.getProperty("java.home"), props.getProperty("os.arch"));
System.getProperty("os.arch"))
);
} }
LaunchMechanism launchMechanism() { LaunchMechanism launchMechanism() {
@ -159,9 +159,7 @@ final class ProcessImpl extends Process {
} }
static Platform get() { static Platform get() {
String osName = AccessController.doPrivileged( String osName = GetPropertyAction.getProperty("os.name");
(PrivilegedAction<String>) () -> System.getProperty("os.name")
);
if (osName.equals("Linux")) { return LINUX; } if (osName.equals("Linux")) { return LINUX; }
if (osName.contains("OS X")) { return BSD; } if (osName.contains("OS X")) { return BSD; }

View file

@ -24,7 +24,7 @@
*/ */
package java.net; package java.net;
import java.security.AccessController; import sun.security.action.GetPropertyAction;
/** /**
* This class defines a factory for creating DatagramSocketImpls. It defaults * This class defines a factory for creating DatagramSocketImpls. It defaults
@ -40,8 +40,7 @@ class DefaultDatagramSocketImplFactory {
static { static {
String prefix = null; String prefix = null;
try { try {
prefix = AccessController.doPrivileged( prefix = GetPropertyAction.getProperty("impl.prefix", null);
new sun.security.action.GetPropertyAction("impl.prefix", null));
if (prefix != null) if (prefix != null)
prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl"); prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl");
} catch (Exception e) { } catch (Exception e) {

View file

@ -34,7 +34,6 @@ import java.io.File;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.security.AccessController;
import sun.net.sdp.SdpSupport; import sun.net.sdp.SdpSupport;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
@ -57,8 +56,7 @@ public class SdpProvider extends NetHooks.Provider {
public SdpProvider() { public SdpProvider() {
// if this property is not defined then there is nothing to do. // if this property is not defined then there is nothing to do.
String file = AccessController.doPrivileged( String file = GetPropertyAction.getProperty("com.sun.sdp.conf");
new GetPropertyAction("com.sun.sdp.conf"));
if (file == null) { if (file == null) {
this.enabled = false; this.enabled = false;
this.rules = null; this.rules = null;
@ -77,8 +75,7 @@ public class SdpProvider extends NetHooks.Provider {
// check if debugging is enabled // check if debugging is enabled
PrintStream out = null; PrintStream out = null;
String logfile = AccessController.doPrivileged( String logfile = GetPropertyAction.getProperty("com.sun.sdp.debug");
new GetPropertyAction("com.sun.sdp.debug"));
if (logfile != null) { if (logfile != null) {
out = System.out; out = System.out;
if (logfile.length() > 0) { if (logfile.length() > 0) {

View file

@ -39,6 +39,7 @@ import sun.net.www.HeaderParser;
import sun.net.www.protocol.http.AuthenticationInfo; import sun.net.www.protocol.http.AuthenticationInfo;
import sun.net.www.protocol.http.AuthScheme; import sun.net.www.protocol.http.AuthScheme;
import sun.net.www.protocol.http.HttpURLConnection; import sun.net.www.protocol.http.HttpURLConnection;
import sun.security.action.GetPropertyAction;
/** /**
* NTLMAuthentication: * NTLMAuthentication:
@ -73,12 +74,9 @@ public class NTLMAuthentication extends AuthenticationInfo {
NTLMAuthenticationCallback.getNTLMAuthenticationCallback(); NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
private String hostname; private String hostname;
private static String defaultDomain; /* Domain to use if not specified by user */ /* Domain to use if not specified by user */
private static String defaultDomain =
static { GetPropertyAction.getProperty("http.auth.ntlm.domain", "");
defaultDomain = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.auth.ntlm.domain", ""));
};
public static boolean supportsTransparentAuth () { public static boolean supportsTransparentAuth () {
return false; return false;
@ -143,8 +141,7 @@ public class NTLMAuthentication extends AuthenticationInfo {
password = pw.getPassword(); password = pw.getPassword();
init0(); init0();
try { try {
String version = java.security.AccessController.doPrivileged( String version = GetPropertyAction.getProperty("ntlm.version");
new sun.security.action.GetPropertyAction("ntlm.version"));
client = new Client(version, hostname, username, ntdomain, password); client = new Client(version, hostname, username, ntdomain, password);
} catch (NTLMException ne) { } catch (NTLMException ne) {
try { try {

View file

@ -26,7 +26,6 @@
package sun.nio.ch; package sun.nio.ch;
import java.nio.channels.spi.AsynchronousChannelProvider; import java.nio.channels.spi.AsynchronousChannelProvider;
import java.security.AccessController;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -60,8 +59,7 @@ public class DefaultAsynchronousChannelProvider {
* Returns the default AsynchronousChannelProvider. * Returns the default AsynchronousChannelProvider.
*/ */
public static AsynchronousChannelProvider create() { public static AsynchronousChannelProvider create() {
String osname = AccessController String osname = GetPropertyAction.getProperty("os.name");
.doPrivileged(new GetPropertyAction("os.name"));
if (osname.equals("SunOS")) if (osname.equals("SunOS"))
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider"); return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
if (osname.equals("Linux")) if (osname.equals("Linux"))

View file

@ -31,7 +31,6 @@ import java.net.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.io.IOException; import java.io.IOException;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.security.AccessController;
import sun.net.NetHooks; import sun.net.NetHooks;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
@ -47,8 +46,8 @@ class UnixAsynchronousSocketChannelImpl
private static final boolean disableSynchronousRead; private static final boolean disableSynchronousRead;
static { static {
String propValue = AccessController.doPrivileged( String propValue = GetPropertyAction
new GetPropertyAction("sun.nio.ch.disableSynchronousRead", "false")); .getProperty("sun.nio.ch.disableSynchronousRead", "false");
disableSynchronousRead = (propValue.length() == 0) ? disableSynchronousRead = (propValue.length() == 0) ?
true : Boolean.valueOf(propValue); true : Boolean.valueOf(propValue);
} }

View file

@ -26,7 +26,6 @@
package sun.nio.fs; package sun.nio.fs;
import java.nio.file.spi.FileSystemProvider; import java.nio.file.spi.FileSystemProvider;
import java.security.AccessController;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -55,8 +54,7 @@ public class DefaultFileSystemProvider {
* Returns the default FileSystemProvider. * Returns the default FileSystemProvider.
*/ */
public static FileSystemProvider create() { public static FileSystemProvider create() {
String osname = AccessController String osname = GetPropertyAction.getProperty("os.name");
.doPrivileged(new GetPropertyAction("os.name"));
if (osname.equals("SunOS")) if (osname.equals("SunOS"))
return createProvider("sun.nio.fs.SolarisFileSystemProvider"); return createProvider("sun.nio.fs.SolarisFileSystemProvider");
if (osname.equals("Linux")) if (osname.equals("Linux"))

View file

@ -31,7 +31,6 @@ import java.nio.file.spi.*;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.security.AccessController;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -57,8 +56,8 @@ abstract class UnixFileSystem
// if process-wide chdir is allowed or default directory is not the // if process-wide chdir is allowed or default directory is not the
// process working directory then paths must be resolved against the // process working directory then paths must be resolved against the
// default directory. // default directory.
String propValue = AccessController.doPrivileged( String propValue = GetPropertyAction
new GetPropertyAction("sun.nio.fs.chdirAllowed", "false")); .getProperty("sun.nio.fs.chdirAllowed", "false");
boolean chdirAllowed = (propValue.length() == 0) ? boolean chdirAllowed = (propValue.length() == 0) ?
true : Boolean.valueOf(propValue); true : Boolean.valueOf(propValue);
if (chdirAllowed) { if (chdirAllowed) {

View file

@ -25,8 +25,8 @@
package java.io; package java.io;
import java.security.AccessController;
import java.util.Locale; import java.util.Locale;
import java.util.Properties;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -42,10 +42,9 @@ class WinNTFileSystem extends FileSystem {
private final char semicolon; private final char semicolon;
public WinNTFileSystem() { public WinNTFileSystem() {
slash = AccessController.doPrivileged( Properties props = GetPropertyAction.getProperties();
new GetPropertyAction("file.separator")).charAt(0); slash = props.getProperty("file.separator").charAt(0);
semicolon = AccessController.doPrivileged( semicolon = props.getProperty("path.separator").charAt(0);
new GetPropertyAction("path.separator")).charAt(0);
altSlash = (this.slash == '\\') ? '/' : '\\'; altSlash = (this.slash == '\\') ? '/' : '\\';
} }

View file

@ -24,8 +24,7 @@
*/ */
package java.net; package java.net;
import java.security.AccessController; import java.util.Properties;
import java.security.PrivilegedAction;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -57,12 +56,11 @@ class DefaultDatagramSocketImplFactory
static { static {
Class<?> prefixImplClassLocal = null; Class<?> prefixImplClassLocal = null;
Properties props = GetPropertyAction.getProperties();
preferIPv4Stack = Boolean.parseBoolean( preferIPv4Stack = Boolean.parseBoolean(
AccessController.doPrivileged( props.getProperty("java.net.preferIPv4Stack"));
new GetPropertyAction("java.net.preferIPv4Stack")));
String exclBindProp = AccessController.doPrivileged( String exclBindProp = props.getProperty("sun.net.useExclusiveBind", "");
new GetPropertyAction("sun.net.useExclusiveBind", ""));
exclusiveBind = (exclBindProp.isEmpty()) exclusiveBind = (exclBindProp.isEmpty())
? true ? true
: Boolean.parseBoolean(exclBindProp); : Boolean.parseBoolean(exclBindProp);
@ -70,8 +68,7 @@ class DefaultDatagramSocketImplFactory
// impl.prefix // impl.prefix
String prefix = null; String prefix = null;
try { try {
prefix = AccessController.doPrivileged( prefix = props.getProperty("impl.prefix");
new GetPropertyAction("impl.prefix", null));
if (prefix != null) if (prefix != null)
prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl"); prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl");
} catch (Exception e) { } catch (Exception e) {

View file

@ -34,6 +34,7 @@ import sun.net.www.HeaderParser;
import sun.net.www.protocol.http.AuthenticationInfo; import sun.net.www.protocol.http.AuthenticationInfo;
import sun.net.www.protocol.http.AuthScheme; import sun.net.www.protocol.http.AuthScheme;
import sun.net.www.protocol.http.HttpURLConnection; import sun.net.www.protocol.http.HttpURLConnection;
import sun.security.action.GetPropertyAction;
/** /**
* NTLMAuthentication: * NTLMAuthentication:
@ -52,9 +53,8 @@ public class NTLMAuthentication extends AuthenticationInfo {
private static String defaultDomain; /* Domain to use if not specified by user */ private static String defaultDomain; /* Domain to use if not specified by user */
static { static {
defaultDomain = java.security.AccessController.doPrivileged( defaultDomain = GetPropertyAction.getProperty("http.auth.ntlm.domain",
new sun.security.action.GetPropertyAction("http.auth.ntlm.domain", "domain");
"domain"));
}; };
private void init0() { private void init0() {

View file

@ -27,9 +27,9 @@ package sun.nio.ch;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException; import java.io.IOException;
import java.security.PrivilegedAction;
import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaIOFileDescriptorAccess; import jdk.internal.misc.JavaIOFileDescriptorAccess;
import sun.security.action.GetPropertyAction;
class FileDispatcherImpl extends FileDispatcher { class FileDispatcherImpl extends FileDispatcher {
@ -119,13 +119,8 @@ class FileDispatcherImpl extends FileDispatcher {
} }
static boolean isFastFileTransferRequested() { static boolean isFastFileTransferRequested() {
String fileTransferProp = java.security.AccessController.doPrivileged( String fileTransferProp = GetPropertyAction
new PrivilegedAction<String>() { .getProperty("jdk.nio.enableFastFileTransfer");
@Override
public String run() {
return System.getProperty("jdk.nio.enableFastFileTransfer");
}
});
boolean enable; boolean enable;
if ("".equals(fileTransferProp)) { if ("".equals(fileTransferProp)) {
enable = true; enable = true;

View file

@ -27,7 +27,6 @@ package sun.nio.fs;
import java.nio.file.attribute.*; import java.nio.file.attribute.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.security.AccessController;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
@ -115,8 +114,8 @@ class WindowsFileAttributes
// indicates if accurate metadata is required (interesting on NTFS only) // indicates if accurate metadata is required (interesting on NTFS only)
private static final boolean ensureAccurateMetadata; private static final boolean ensureAccurateMetadata;
static { static {
String propValue = AccessController.doPrivileged( String propValue = GetPropertyAction
new GetPropertyAction("sun.nio.fs.ensureAccurateMetadata", "false")); .getProperty("sun.nio.fs.ensureAccurateMetadata", "false");
ensureAccurateMetadata = (propValue.length() == 0) ? ensureAccurateMetadata = (propValue.length() == 0) ?
true : Boolean.valueOf(propValue); true : Boolean.valueOf(propValue);
} }