diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-04-05 19:22:58 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-04-12 11:31:13 +0200 |
commit | c1e787f7560807ca95e021d9cb7f1406c5953c3c (patch) | |
tree | 75d2d3e93f89d19f5113a10287a739512f9a7d7a /compiler/test/dotty/tools/vulpix/ChildJVMMain.java | |
parent | 923533ea86b53b90e343e4fc0f88956996a2ed5b (diff) | |
download | dotty-c1e787f7560807ca95e021d9cb7f1406c5953c3c.tar.gz dotty-c1e787f7560807ca95e021d9cb7f1406c5953c3c.tar.bz2 dotty-c1e787f7560807ca95e021d9cb7f1406c5953c3c.zip |
Make inter JVM communication be string based
Diffstat (limited to 'compiler/test/dotty/tools/vulpix/ChildJVMMain.java')
-rw-r--r-- | compiler/test/dotty/tools/vulpix/ChildJVMMain.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/vulpix/ChildJVMMain.java b/compiler/test/dotty/tools/vulpix/ChildJVMMain.java new file mode 100644 index 000000000..90b795898 --- /dev/null +++ b/compiler/test/dotty/tools/vulpix/ChildJVMMain.java @@ -0,0 +1,34 @@ +package dotty.tools.vulpix; + +import java.io.File; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.lang.reflect.Method; + +public class ChildJVMMain { + static final String MessageEnd = "##THIS IS THE END FOR ME, GOODBYE##"; + + private static void runMain(String dir) throws Exception { + ArrayList<URL> cp = new ArrayList<>(); + for (String path : dir.split(":")) + cp.add(new File(path).toURI().toURL()); + + URLClassLoader ucl = new URLClassLoader(cp.toArray(new URL[cp.size()])); + Class<?> cls = ucl.loadClass("Test"); + Method meth = cls.getMethod("main", String[].class); + Object[] args = new Object[]{ new String[]{ "jvm" } }; + meth.invoke(null, args); + } + + public static void main(String[] args) throws Exception { + BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); + + while (true) { + runMain(stdin.readLine()); + System.out.println(MessageEnd); + } + } +} |