public class ExitPreventingSecurityManager extends SecurityManager
TestCase
to detect
and report calls to System.exit() without actually terminating the JVM.
With this security manager in place, any call to System.exit() will be
turned into a ExitCalledException
.
This security manager is designed to work in conjunction with any other security manager currently installed. It chains to an existing security manager and delegates all checks other than System.exit() checks to the other manager. This way it can easily be "added" on top of a sandboxing security manager without requiring that manager to be rewritten.
inCheck
Constructor and Description |
---|
ExitPreventingSecurityManager(SecurityManager parent)
Create a new manager with the given security manager as its "parent".
|
Modifier and Type | Method and Description |
---|---|
void |
checkExit(int status) |
void |
checkPermission(Permission perm) |
void |
checkPermission(Permission perm,
Object context) |
static void |
install()
Install a new instance of this class as the current security manager,
taking any existing security manager and using it as the parent to
chain to.
|
static void |
uninstall()
If the current security manager is an instance of this class,
uninstall it and replace it with its parent, if any.
|
checkAccept, checkAccess, checkAccess, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkSystemClipboardAccess, checkTopLevelWindow, checkWrite, checkWrite, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getClassContext, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader
public ExitPreventingSecurityManager(SecurityManager parent)
parent
- The security manager to chain to (delegate to) for all
other checks besides System.exit() calls.public void checkPermission(Permission perm)
checkPermission
in class SecurityManager
public void checkPermission(Permission perm, Object context)
checkPermission
in class SecurityManager
public void checkExit(int status)
checkExit
in class SecurityManager
public static void install()
public static void uninstall()