Class NoExitSecurityManager

java.lang.Object
java.lang.SecurityManager
org.fest.swing.security.NoExitSecurityManager

public class NoExitSecurityManager extends SecurityManager
Understands a SecurityManager that does not allow an application under test to terminate the current JVM. Adapted from Abbot's NoExitSecurityManager.
  • Field Details

    • NULL_HOOK

      private static final ExitCallHook NULL_HOOK
    • hook

      private final ExitCallHook hook
    • stackTraces

      private final org.fest.util.StackTraces stackTraces
  • Constructor Details

    • NoExitSecurityManager

      public NoExitSecurityManager()
      Creates a new NoExitSecurityManager.
    • NoExitSecurityManager

      public NoExitSecurityManager(ExitCallHook hook)
      Creates a new NoExitSecurityManager.
      Parameters:
      hook - notified when an application tries to terminate the current JVM.
      Throws:
      NullPointerException - if the given hook is null.
    • NoExitSecurityManager

      NoExitSecurityManager(ExitCallHook hook, org.fest.util.StackTraces stackTraces)
  • Method Details

    • checkPermission

      public void checkPermission(Permission permission, Object context)
      Allows everything.
      Overrides:
      checkPermission in class SecurityManager
      Parameters:
      permission - the specified permission.
      context - a system-dependent security context.
    • checkPermission

      public void checkPermission(Permission permission)
      Allows everything.
      Overrides:
      checkPermission in class SecurityManager
      Parameters:
      permission - the specified permission.
    • checkExit

      public void checkExit(int status)
      Throws an ExitException if an application tries to terminate the current JVM (through Runtime.exit(int) or Runtime.halt(int).)
      Overrides:
      checkExit in class SecurityManager
      Parameters:
      status - the exit status.
      Throws:
      ExitException - if an application tries to terminate the current JVM.
    • exitInvoked

      private boolean exitInvoked()
      Indicates whether "exit" has been invoked through a call of Runtime.exit(int) or Runtime.halt(int).
      Returns:
      true if an exit has been invoked through a call of Runtime.exit or Runtime.halt; false otherwise.
    • exitInvoked

      private boolean exitInvoked(StackTraceElement e)