aboutsummaryrefslogtreecommitdiff
path: root/nailgun_launcher/NailgunLauncher.java
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-09-15 12:18:00 +0100
committerChristopher Vogt <oss.nsp@cvogt.org>2016-09-15 12:18:00 +0100
commitd2e7fcfd0b71a53f22a7e8fbcf5c920c1c689a00 (patch)
treecf0983aae763e084fd05c0c75fceca32453e9ae8 /nailgun_launcher/NailgunLauncher.java
parent32abe161b5454e2c9e9265bb5b95e8fad3c09bb3 (diff)
downloadcbt-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/NailgunLauncher.java')
-rw-r--r--nailgun_launcher/NailgunLauncher.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java
index 904a646..5a70312 100644
--- a/nailgun_launcher/NailgunLauncher.java
+++ b/nailgun_launcher/NailgunLauncher.java
@@ -20,7 +20,15 @@ public class NailgunLauncher{
new ConcurrentHashMap<Object,ClassLoader>()
);
- public final static SecurityManager defaultSecurityManager = System.getSecurityManager();
+ public final static SecurityManager initialSecurityManager
+ = System.getSecurityManager();
+
+ public final static ThreadLocal<Boolean> trapExitCode =
+ new ThreadLocal<Boolean>() {
+ @Override protected Boolean initialValue() {
+ return false;
+ }
+ };
public static String TARGET = System.getenv("TARGET");
private static String NAILGUN = "nailgun_launcher/";
@@ -54,6 +62,7 @@ public class NailgunLauncher{
return;
}
+ System.setSecurityManager( new TrapSecurityManager() );
installProxySettings();
String[] diff = args[0].split("\\.");
long start = _start - (Long.parseLong(diff[0]) * 1000L) - Long.parseLong(diff[1]);
@@ -119,7 +128,7 @@ public class NailgunLauncher{
compatibilitySourceFiles.add(f);
}
}
- changed = compile(changed, start, "", compatibilityTarget, earlyDeps, compatibilitySourceFiles, defaultSecurityManager);
+ changed = compile(changed, start, "", compatibilityTarget, earlyDeps, compatibilitySourceFiles);
if( classLoaderCache.contains( compatibilityTarget ) ){
compatibilityClassLoader = classLoaderCache.get( compatibilityTarget );
@@ -145,7 +154,7 @@ public class NailgunLauncher{
stage1SourceFiles.add(f);
}
}
- changed = compile(changed, start, stage1Classpath, stage1Target, earlyDeps, stage1SourceFiles, defaultSecurityManager);
+ changed = compile(changed, start, stage1Classpath, stage1Target, earlyDeps, stage1SourceFiles);
ClassLoader stage1classLoader;
if( !changed && classLoaderCache.contains( stage1Classpath ) ){