Merge pull request #314 from alexarchambault/topic/fix

Fix
This commit is contained in:
Alexandre Archambault 2016-08-06 11:39:04 -04:00 committed by GitHub
commit 0f0c6bea4f
3 changed files with 16 additions and 9 deletions

View File

@ -130,7 +130,11 @@ case class Bootstrap(
if (nonHttpUrls.nonEmpty)
Console.err.println(s"Warning: non HTTP URLs:\n${nonHttpUrls.mkString("\n")}")
val mainClass = helper.retainedMainClass
val mainClass =
if (options.mainClass.isEmpty)
helper.retainedMainClass
else
options.mainClass
val buffer = new ByteArrayOutputStream

View File

@ -664,10 +664,7 @@ class Helper(
}
val mainClass =
if (mainClasses.isEmpty) {
Helper.errPrintln("No main class found. Specify one with -M or --main.")
sys.exit(255)
} else if (mainClasses.size == 1) {
if (mainClasses.size == 1) {
val (_, mainClass) = mainClasses.head
mainClass
} else {

View File

@ -80,22 +80,28 @@ case class Launch(
isolated = options.isolated
)
val mainClass =
if (options.mainClass.isEmpty)
helper.retainedMainClass
else
options.mainClass
val cls =
try helper.loader.loadClass(helper.retainedMainClass)
try helper.loader.loadClass(mainClass)
catch { case e: ClassNotFoundException =>
Helper.errPrintln(s"Error: class ${helper.retainedMainClass} not found")
Helper.errPrintln(s"Error: class $mainClass not found")
sys.exit(255)
}
val method =
try cls.getMethod("main", classOf[Array[String]])
catch { case e: NoSuchMethodException =>
Helper.errPrintln(s"Error: method main not found in ${helper.retainedMainClass}")
Helper.errPrintln(s"Error: method main not found in $mainClass")
sys.exit(255)
}
method.setAccessible(true)
if (options.common.verbosityLevel >= 2)
Helper.errPrintln(s"Launching ${helper.retainedMainClass} ${userArgs.mkString(" ")}")
Helper.errPrintln(s"Launching $mainClass ${userArgs.mkString(" ")}")
else if (options.common.verbosityLevel == 1)
Helper.errPrintln(s"Launching")