ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane Bailliez <sbaill...@imediation.com>
Subject Security Manager and System.exit
Date Fri, 14 Dec 2001 08:42:09 GMT

A while ago the SecurityManager was replaced when running Ant so that non
forked tasks do not terminate Ant when they contain a System.exit (typically
a non-forked Java command line).

[ there is some code remaining in Main and the Java task) ]

It has been removed immediately because (from the comments) it did not work
with JDK 1.1.

So is there any issue if we use a System manager for JDK 1.2+ (see below) ?

SecurityManager oldSm = null;
if (jdk1.2+){
  oldSm = System.getSecurityManager();
  System.setSecurityManager( new NoExitSecurityManager() );
}
try  {
  ....
} finally {
  if (oldSm != null){
     System.setSecurityManager( oldSm );
  }
}

-- 
 St├ęphane Bailliez 
 Software Engineer, Paris - France 
 iMediation - http://www.imediation.com 
 Disclaimer: All the opinions expressed above are mine and not those from my
company. 


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message