Sha256: 23ceda34d5eb465366a5e32edb3e34334edd6b4a5f20e892328da3c4579f34b8

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

import java.security.Permission;

// Copy-&-pasted (almost) from
// http://www.jroller.com/ethdsy/entry/disabling_system_exit
class ForbidSystemExit
{
  public static class Exception extends SecurityException { }

  public static void apply() {
    final SecurityManager securityManager = new SecurityManager() {
      public void checkPermission( Permission permission ) {
        if( permission.getName().startsWith("exitVM") ) {
          throw new Exception() ;
        }
      }
    } ;
    System.setSecurityManager( securityManager ) ;
  }

  public static void unapply() {
    System.setSecurityManager( null ) ;
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gjman-0.1.0 lib/gjman/java_hacks/ForbidSystemExit.java