From 4f69e5325de4a66f67485a9a6ed03795597b644a Mon Sep 17 00:00:00 2001 From: michelou Date: Thu, 15 Jun 2006 20:49:54 +0000 Subject: fixed "guess" test in MainGenericRunner.scala added try/catch around Class.forName in ObjectRunner.scala --- src/compiler/scala/tools/nsc/ObjectRunner.scala | 31 ++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/compiler/scala/tools/nsc/ObjectRunner.scala') diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index cf636af7ab..d2202f5046 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -27,19 +27,24 @@ object ObjectRunner { classpath: List[String], objectName: String, arguments: Seq[String]): Unit = - { - 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.getMethods.find(isMainMethod) match { - case Some(meth) => - meth - case None => { - throw new Error("no main method in object " + objectName) + 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.getMethods.find(isMainMethod) match { + case Some(meth) => + meth + case None => + throw new Error("no main method in object " + objectName) } + val res = method.invoke(null, List(arguments.toArray).toArray) + () + } catch { + case e: Exception => + // ClassNotFoundException, InvocationTargetException, .. + Console.println(e) + exit(1) } - val res = method.invoke(null, List(arguments.toArray).toArray) - () - } + } -- cgit v1.2.3