/** * Sets the System security. * * <p>If there is a security manager already installed, this method first calls the security * manager's <code>checkPermission</code> method with a <code> * RuntimePermission("setSecurityManager")</code> permission to ensure it's ok to replace the * existing security manager. This may result in throwing a <code>SecurityException</code>. * * <p>Otherwise, the argument is established as the current security manager. If the argument is * <code>null</code> and no security manager has been established, then no action is taken and the * method simply returns. * * @param s the security manager. * @exception SecurityException if the security manager has already been set and its <code> * checkPermission</code> method doesn't allow it to be replaced. * @see #getSecurityManager * @see SecurityManager#checkPermission * @see java.lang.RuntimePermission */ public static void setSecurityManager(final SecurityManager s) { try { s.checkPackageAccess("java.lang"); } catch (Exception e) { // no-op } setSecurityManager0(s); }