aboutsummaryrefslogtreecommitdiff
path: root/stage1/Stage1Lib.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-03-28 09:35:24 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2017-03-28 10:09:15 -0400
commita3e5f304e99ff47165af6ed20182f06700e15b33 (patch)
treeecd5ab13a2a2c5a11415fa9d4f64f3634e02309a /stage1/Stage1Lib.scala
parent497fff26705be6a21e6099a562ff14bfe1d90003 (diff)
downloadcbt-a3e5f304e99ff47165af6ed20182f06700e15b33.tar.gz
cbt-a3e5f304e99ff47165af6ed20182f06700e15b33.tar.bz2
cbt-a3e5f304e99ff47165af6ed20182f06700e15b33.zip
minor reflection related refactor
Diffstat (limited to 'stage1/Stage1Lib.scala')
-rw-r--r--stage1/Stage1Lib.scala25
1 files changed, 4 insertions, 21 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index 3ffc878..55c9234 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -79,28 +79,11 @@ class Stage1Lib( logger: Logger ) extends
}
}
- /*
- // ========== compilation / execution ==========
- // TODO: move classLoader first
- def runMain( className: String, args: Seq[String], classLoader: ClassLoader ): ExitCode = {
- import java.lang.reflect.Modifier
- logger.run(s"Running $className.main($args) with classLoader: " ++ classLoader.toString)
- trapExitCode{
- /*
- val cls = classLoader.loadClass(className)
- discoverCbtMain( cls ) orElse discoverMain( cls ) getOrElse (
- throw new NoSuchMethodException( "No main method found in " ++ cbt )
- ).apply( arg.toVector )*/
- ExitCode.Success
- }
- }
- */
-
- def discoverCbtMainForced( cls: Class[_] ): cbt.reflect.StaticMethod[Context, ExitCode] =
- discoverStaticMethodForced[Context, ExitCode]( cls, "cbtMain" )
+ def getCbtMain( cls: Class[_] ): cbt.reflect.StaticMethod[Context, ExitCode] =
+ findStaticMethodForced[Context, ExitCode]( cls, "cbtMain" )
- def discoverCbtMain( cls: Class[_] ): Option[cbt.reflect.StaticMethod[Context, ExitCode]] =
- discoverStaticMethod[Context, ExitCode]( cls, "cbtMain" )
+ def findCbtMain( cls: Class[_] ): Option[cbt.reflect.StaticMethod[Context, ExitCode]] =
+ findStaticMethod[Context, ExitCode]( cls, "cbtMain" )
/** shows an interactive dialogue in the shell asking the user to pick one of many choices */
def pickOne[T]( msg: String, choices: Seq[T] )( show: T => String ): Option[T] = {