Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
bgColor#FFcccc
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)

...