*/
private final String[] libpath;
- /**
- * The current security manager. This is located here instead of in
- * System, to avoid security problems, as well as bootstrap issues.
- * Make sure to access it in a thread-safe manner; it is package visible
- * to avoid overhead in java.lang.
- */
- static SecurityManager securityManager;
-
static
{
init();
*/
public void exit(int status)
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkExit(status);
boolean first = false;
*/
public void addShutdownHook(Thread hook)
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkPermission(new RuntimePermission("shutdownHooks"));
if (hook.isAlive() || hook.getThreadGroup() == null)
*/
public boolean removeShutdownHook(Thread hook)
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkPermission(new RuntimePermission("shutdownHooks"));
synchronized (libpath)
*/
public void halt(int status)
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkExit(status);
exitInternal(status);
*/
public static void runFinalizersOnExit(boolean finalizeOnExit)
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkExit(0);
current.finalizeOnExit = finalizeOnExit;
public Process exec(String[] cmd, String[] env, File dir)
throws IOException
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkExec(cmd[0]);
return execInternal(cmd, env, dir);
*/
public void load(String filename)
{
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkLink(filename);
_load(filename, false);
{
// This is different from the Classpath implementation, but I
// believe it is more correct.
- SecurityManager sm = securityManager; // Be thread-safe!
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
if (sm != null)
sm.checkLink(libname);
_load(libname, true);
*/
public static void setIn(InputStream in)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("setIO"));
setIn0(in);
*/
public static void setOut(PrintStream out)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("setIO"));
*/
public static void setErr(PrintStream err)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("setIO"));
setErr0(err);
// Implementation note: the field lives in Runtime because of bootstrap
// initialization issues. This method is synchronized so that no other
// thread changes it to null before this thread makes the change.
- if (Runtime.securityManager != null)
- Runtime.securityManager.checkPermission
+ if (SecurityManager.current != null)
+ SecurityManager.current.checkPermission
(new RuntimePermission("setSecurityManager"));
- Runtime.securityManager = sm;
+ SecurityManager.current = sm;
}
/**
{
// Implementation note: the field lives in Runtime because of bootstrap
// initialization issues.
- return Runtime.securityManager;
+ return SecurityManager.current;
}
/**
*/
public static Properties getProperties()
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertiesAccess();
return SystemProperties.getProperties();
*/
public static void setProperties(Properties properties)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertiesAccess();
SystemProperties.setProperties(properties);
*/
public static String getProperty(String key)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertyAccess(key);
else if (key.length() == 0)
*/
public static String getProperty(String key, String def)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertyAccess(key);
return SystemProperties.getProperty(key, def);
*/
public static String setProperty(String key, String value)
{
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new PropertyPermission(key, "write"));
return SystemProperties.setProperty(key, value);
{
if (name == null)
throw new NullPointerException();
- SecurityManager sm = Runtime.securityManager; // Be thread-safe.
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("getenv." + name));
return getenv0(name);