diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-09-15 12:18:00 +0100 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-09-15 12:18:00 +0100 |
commit | d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00 (patch) | |
tree | cf0983aae763e084fd05c0c75fceca32453e9ae8 /nailgun_launcher/Stage0Lib.java | |
parent | 32abe161b5454e2c9e9265bb5b95e8fad3c09bb3 (diff) | |
download | cbt-d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00.tar.gz cbt-d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00.tar.bz2 cbt-d2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00.zip |
fix behavior of System.exit trapping
Installing one globally for the JVM live-time and make behavior dependent
on a thread local variable seems safer than globally switching it out
and having race conditions.
Also now all other calls are forwarded to a potential Nailgun
SecurityManager, which should fix some bugs.
Diffstat (limited to 'nailgun_launcher/Stage0Lib.java')
-rw-r--r-- | nailgun_launcher/Stage0Lib.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/nailgun_launcher/Stage0Lib.java b/nailgun_launcher/Stage0Lib.java index ebf9d09..d6df1c6 100644 --- a/nailgun_launcher/Stage0Lib.java +++ b/nailgun_launcher/Stage0Lib.java @@ -19,9 +19,10 @@ public class Stage0Lib{ } } - public static int runMain(String cls, String[] args, ClassLoader cl, SecurityManager defaultSecurityManager) throws Throwable{ + public static int runMain(String cls, String[] args, ClassLoader cl) throws Throwable{ + Boolean trapExitCodeBefore = NailgunLauncher.trapExitCode.get(); try{ - System.setSecurityManager( new TrapSecurityManager() ); + NailgunLauncher.trapExitCode.set(true); cl.loadClass(cls) .getMethod("main", String[].class) .invoke( null, (Object) args); @@ -33,7 +34,7 @@ public class Stage0Lib{ } throw exception; } finally { - System.setSecurityManager(defaultSecurityManager); + NailgunLauncher.trapExitCode.set(trapExitCodeBefore); } } @@ -54,7 +55,7 @@ public class Stage0Lib{ public static Boolean compile( Boolean changed, Long start, String classpath, String target, - EarlyDependencies earlyDeps, List<File> sourceFiles, SecurityManager defaultSecurityManager + EarlyDependencies earlyDeps, List<File> sourceFiles ) throws Throwable{ File statusFile = new File( new File(target) + ".last-success" ); Long lastSuccessfullCompile = statusFile.lastModified(); @@ -89,7 +90,7 @@ public class Stage0Lib{ PrintStream oldOut = System.out; try{ System.setOut(System.err); - int exitCode = runMain( "com.typesafe.zinc.Main", zincArgs.toArray(new String[zincArgs.size()]), earlyDeps.zinc, defaultSecurityManager ); + int exitCode = runMain( "com.typesafe.zinc.Main", zincArgs.toArray(new String[zincArgs.size()]), earlyDeps.zinc ); if( exitCode == 0 ){ write( statusFile, "" ); Files.setLastModifiedTime( statusFile.toPath(), FileTime.fromMillis(start) ); |