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/ChildMain.scala | |
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/ChildMain.scala')
-rw-r--r-- | compiler/test/dotty/tools/vulpix/ChildMain.scala | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/compiler/test/dotty/tools/vulpix/ChildMain.scala b/compiler/test/dotty/tools/vulpix/ChildMain.scala deleted file mode 100644 index 30059a9c5..000000000 --- a/compiler/test/dotty/tools/vulpix/ChildMain.scala +++ /dev/null @@ -1,82 +0,0 @@ -package dotty.tools.vulpix - -import java.io.{ - File => JFile, - InputStream, ObjectInputStream, - OutputStream, ObjectOutputStream, - ByteArrayOutputStream, PrintStream -} -import java.lang.reflect.InvocationTargetException - -import dotty.tools.vulpix.Statuses._ - -object ChildMain { - val realStdin = System.in - val realStderr = System.err - val realStdout = System.out - - private def runMain(dir: JFile): Status = { - def renderStackTrace(ex: Throwable): String = - ex.getStackTrace - .takeWhile(_.getMethodName != "invoke0") - .mkString(" ", "\n ", "") - - def resetOutDescriptors(): Unit = { - System.setOut(realStdout) - System.setErr(realStderr) - } - - import java.net.{ URL, URLClassLoader } - - val printStream = new ByteArrayOutputStream - - try { - // Do classloading magic and running here: - val ucl = new URLClassLoader(Array(dir.toURI.toURL)) - val cls = ucl.loadClass("Test") - val meth = cls.getMethod("main", classOf[Array[String]]) - - try { - val ps = new PrintStream(printStream) - System.setOut(ps) - System.setErr(ps) - Console.withOut(printStream) { - Console.withErr(printStream) { - // invoke main with "jvm" as arg - meth.invoke(null, Array("jvm")) - } - } - resetOutDescriptors() - } catch { - case t: Throwable => - resetOutDescriptors() - throw t - } - new Success(printStream.toString("utf-8")) - } - catch { - case ex: NoSuchMethodException => - val msg = s"test in '$dir' did not contain method: ${ex.getMessage}" - new Failure(msg, renderStackTrace(ex.getCause)) - - case ex: ClassNotFoundException => - val msg = s"test in '$dir' did not contain class: ${ex.getMessage}" - new Failure(msg, renderStackTrace(ex.getCause)) - - case ex: InvocationTargetException => - val msg = s"An exception ocurred when running main: ${ex.getCause}" - new Failure(msg, renderStackTrace(ex.getCause)) - } - } - - def main(args: Array[String]): Unit = { - val stdin = new ObjectInputStream(System.in); - val stdout = new ObjectOutputStream(System.out); - - while (true) { - val dir = stdin.readObject().asInstanceOf[JFile] - stdout.writeObject(runMain(dir)) - stdout.flush() - } - } -} |