diff options
author | Elliott Hughes <enh@google.com> | 2010-04-08 11:10:54 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2010-04-08 11:10:54 -0700 |
commit | ce0718b376fc0668b4b4527d2714168342b9578f (patch) | |
tree | 9322ca9b744fce44d7cc8c88c918f17294c56b1d /luni-kernel/src | |
parent | 7ffbba5ea549f43c74419079ceebe048bfd75d59 (diff) | |
download | libcore-ce0718b376fc0668b4b4527d2714168342b9578f.zip libcore-ce0718b376fc0668b4b4527d2714168342b9578f.tar.gz libcore-ce0718b376fc0668b4b4527d2714168342b9578f.tar.bz2 |
Disable System.setSecurityManager.
We plan on removing SecurityManager checks, which are expensive and non-useful,
especially because Android doesn't use SecurityManager itself. As a first step,
let's ship a release where it's no longer possible to set a SecurityManager.
Bug: 1320501
Change-Id: I88664dbc1d8b087579d54003a1aaed7b3d8412be
Diffstat (limited to 'luni-kernel/src')
-rw-r--r-- | luni-kernel/src/main/java/java/lang/System.java | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/luni-kernel/src/main/java/java/lang/System.java b/luni-kernel/src/main/java/java/lang/System.java index aa78b1b..a238de7 100644 --- a/luni-kernel/src/main/java/java/lang/System.java +++ b/luni-kernel/src/main/java/java/lang/System.java @@ -89,11 +89,6 @@ public final class System { private static Properties systemProperties; /** - * The System default SecurityManager. - */ - private static SecurityManager securityManager; - - /** * Initialize all the slots in System on first use. */ static { @@ -496,13 +491,13 @@ public final class System { } /** - * Returns the active security manager. + * Returns null. Android does not use {@code SecurityManager}. This method + * is only provided for source compatibility. * - * @return the system security manager object. - * @since Android 1.0 + * @return null */ public static SecurityManager getSecurityManager() { - return securityManager; + return null; } /** @@ -603,13 +598,11 @@ public final class System { } /** - * <strong>Warning:</strong> security managers do <strong>not</strong> - * provide a secure environment for executing untrusted code. Untrusted code - * cannot be safely isolated within the Dalvik VM. + * Throws {@code UnsupportedOperationException}. * - * <p>Sets the active security manager. Note that once the security manager - * has been set, it can not be changed. Attempts to do that will cause a - * security exception. + * <p>Security managers do <i>not</i> provide a secure environment for + * executing untrusted code and are unsupported on Android. Untrusted code + * cannot be safely isolated within the Dalvik VM. * * @param sm * the new security manager. @@ -617,28 +610,11 @@ public final class System { * if the security manager has already been set and if its * checkPermission method does not allow to redefine the * security manager. - * @since Android 1.0 */ - public static void setSecurityManager(final SecurityManager sm) { - if (securityManager != null) { - securityManager.checkPermission(new java.lang.RuntimePermission("setSecurityManager")); - } - + public static void setSecurityManager(SecurityManager sm) { if (sm != null) { - // before the new manager assumed office, make a pass through - // the common operations and let it load needed classes (if any), - // to avoid infinite recursion later on - try { - sm.checkPermission(new SecurityPermission("getProperty.package.access")); - } catch (Exception ignore) { - } - try { - sm.checkPackageAccess("java.lang"); - } catch (Exception ignore) { - } + throw new UnsupportedOperationException(); } - - securityManager = sm; } /** |