From 1ab98be85b4a4ecdfb7afdf0c98bd0ef7e634b4e Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Thu, 22 Jun 2006 13:58:01 +0000 Subject: Do not suppress ClassNotFoundException, NoSuchM... Do not suppress ClassNotFoundException, NoSuchMethodError, or InvocationTargetException. Document that the caller must handle them. --- src/compiler/scala/tools/nsc/ObjectRunner.scala | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index d64ad2947d..64aafb0007 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -13,24 +13,23 @@ import java.net.URLClassLoader /** An object that runs another object specified by name. */ object ObjectRunner { + /** Run a given object, specified by name, using a + * specified classpath and argument list. + * + * Throws: ClassNotFoundException, NoSuchMtehodError, + * InvocationTargetException + */ def run( classpath: List[String], objectName: String, arguments: Seq[String]): Unit = - try { + { val classpathURLs = classpath.map(s => new File(s).toURL).toArray val mainLoader = new URLClassLoader(classpathURLs, null) val clsToRun = Class.forName(objectName, true, mainLoader) val method = clsToRun.getMethod("main", List(classOf[Array[String]]).toArray) - val res = method.invoke(null, List(arguments.toArray).toArray) - () - } catch { - case e: Exception => - // ClassNotFoundException, InvocationTargetException, NoSuchMethod .. - Console.println(e) - exit(1) - } - + method.invoke(null, List(arguments.toArray).toArray) + } } -- cgit v1.2.3