diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-26 16:20:50 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-28 11:53:52 -0400 |
commit | bd75b5af0161013b26e2feda9cfcc1e152926071 (patch) | |
tree | 6fef7506f432f780fa64bca5afd5f944790be196 /stage1/Stage1Lib.scala | |
parent | 2c20a0dddc70a5eee207fb1c588bfd53eaaa7841 (diff) | |
download | cbt-bd75b5af0161013b26e2feda9cfcc1e152926071.tar.gz cbt-bd75b5af0161013b26e2feda9cfcc1e152926071.tar.bz2 cbt-bd75b5af0161013b26e2feda9cfcc1e152926071.zip |
Early classloading improvements
- Changed launcher to already load zinc
- use code generation to generate necessary dependencies
- changed resolver to linearize dependency DAG in a way that guarantees that every transitive dependee of a node in the DAG is a transitive dependee of that node in the linear sequence
- move exit code trapping code into java so it can be used for zinc early
There seems to be a bug in this version, where CBT crashes about half of the time with a "object is not an instance of declaring class" Exception during running the task from the build object via reflection.
Diffstat (limited to 'stage1/Stage1Lib.scala')
-rw-r--r-- | stage1/Stage1Lib.scala | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index 0259cb0..c8af672 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -20,14 +20,14 @@ object ExitCode{ val Failure = ExitCode(1) } -class TrappedExitCode(private val exitCode: Int) extends Exception -object TrappedExitCode{ - def unapply(e: Throwable): Option[ExitCode] = +object CatchTrappedExitCode{ + def unapply(e: Throwable): Option[ExitCode] = { Option(e) flatMap { case i: InvocationTargetException => unapply(i.getTargetException) case e: TrappedExitCode => Some( ExitCode(e.exitCode) ) case _ => None } + } } case class Context( cwd: File, args: Seq[String], logger: Logger, classLoaderCache: ClassLoaderCache ) @@ -205,30 +205,12 @@ class Stage1Lib( val logger: Logger ) extends BaseLib{ } } - private val trapSecurityManager = new SecurityManager { - override def checkPermission( permission: Permission ) = { - /* - NOTE: is it actually ok, to just make these empty? - Calling .super leads to ClassNotFound exteption for a lambda. - Calling to the previous SecurityManager leads to a stack overflow - */ - } - override def checkPermission( permission: Permission, context: Any ) = { - /* Does this methods need to be overidden? */ - } - override def checkExit( status: Int ) = { - super.checkExit(status) - logger.lib(s"checkExit($status)") - throw new TrappedExitCode(status) - } - } - def trapExitCode( code: => ExitCode ): ExitCode = { try{ - System.setSecurityManager( trapSecurityManager ) + System.setSecurityManager( new TrapSecurityManager ) code } catch { - case TrappedExitCode(exitCode) => + case CatchTrappedExitCode(exitCode) => exitCode } finally { System.setSecurityManager(NailgunLauncher.defaultSecurityManager) |