aboutsummaryrefslogtreecommitdiff
path: root/nailgun_launcher/NailgunLauncher.java
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-03-06 17:25:24 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2016-03-06 17:25:24 -0500
commit9a46a52f6fb3d7c0d07f3c5aa15fc95289738d52 (patch)
tree8a7e46be3916d0b6b617c22b11d4624f7b205302 /nailgun_launcher/NailgunLauncher.java
parent1a7677838554b727ea49131f1d890ddd6d7d295f (diff)
downloadcbt-9a46a52f6fb3d7c0d07f3c5aa15fc95289738d52.tar.gz
cbt-9a46a52f6fb3d7c0d07f3c5aa15fc95289738d52.tar.bz2
cbt-9a46a52f6fb3d7c0d07f3c5aa15fc95289738d52.zip
cleanup NailgunLauncher script, make CBT recompilation more fine-grained for speed and easier transfer of part of it into java. Also enable looping to recompile NailgunLauncher and stage1
Diffstat (limited to 'nailgun_launcher/NailgunLauncher.java')
-rw-r--r--nailgun_launcher/NailgunLauncher.java41
1 files changed, 15 insertions, 26 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java
index e33a959..8b3b746 100644
--- a/nailgun_launcher/NailgunLauncher.java
+++ b/nailgun_launcher/NailgunLauncher.java
@@ -9,7 +9,10 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* This launcher allows to use Nailgun without loading anything else permanenetly into its
- * classpath. The main method loads the given class from the given class math, calls it's main
+ * classpath except for the launcher itself. That's why it is written in Java without
+ * dependencies outside the JDK.
+ *
+ * The main method loads the given class from the given class path, calls it's main
* methods passing in the additional arguments.
*/
public class NailgunLauncher{
@@ -24,38 +27,24 @@ public class NailgunLauncher{
public static void main(String[] args) throws ClassNotFoundException,
NoSuchMethodException,
IllegalAccessException,
- InvocationTargetException {
+ InvocationTargetException,
+ MalformedURLException {
if (args.length < 3) {
-
System.out.println("usage: <main class> <class path> <... args>");
-
} else {
-
// TODO: cache this classloader, but invalidate on changes
- final URL[] urls =
- Arrays.stream(
- args[1].split(File.pathSeparator)
- ).filter( cp -> !(cp == "") ).map( cp -> {
- try { return new URL("file:" + cp); }
- catch(MalformedURLException e) { throw new RuntimeException(e); }
- }).toArray(URL[]::new);
+ String[] cp = args[1].split(File.pathSeparator);
- URLClassLoader cl = new URLClassLoader(urls) {
- public String toString() {
- String suffix = "";
- if (getParent() != ClassLoader.getSystemClassLoader())
- suffix = ", "+getParent();
- return "URLClassLoader(" + Arrays.toString(getURLs()) + suffix +")";
- }
- };
+ URL[] urls = new URL[cp.length];
+ for(int i = 0; i < cp.length; i++){ urls[i] = new URL("file:"+cp[i]); }
- cl.loadClass(args[0])
- .getMethod("main", String[].class)
- .invoke(
- null/* _cls.newInstance()*/,
- (Object) Arrays.stream(args).skip(2).toArray(String[]::new)
- );
+ String[] newArgs = new String[cp.length - 2];
+ for(int i = 2; i < cp.length; i++){ newArgs[i] = args[i]; }
+ new URLClassLoader( urls )
+ .loadClass(args[0])
+ .getMethod("main", String[].class)
+ .invoke( null/* _cls.newInstance()*/, (Object) newArgs );
}
}
}