...
This noncompliant code example passes a null
value to the setSecurityManager
method that is responsible for setting the expected SecurityManager
argument. As a result, no security manager is installed programmatically. In the case where the command line failed to install a security manager, this noncompliant code example would execute in the total absence of subsequent code will run without any security manager monitoring access.
Code Block | ||
---|---|---|
| ||
try { System.setSecurityManager(null); } catch (SecurityException se) { // cannot set security manager, log to file } |
Note that if a SecurityManager
is already active when this code is invoked, it will probably prevent the system from removing it, and so this code will cause a SecurityException
to be thrown.
Compliant Solution (Default Security Manager)
...