diff options
author | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-12 00:09:26 -0500 |
---|---|---|
committer | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-12 00:09:26 -0500 |
commit | b143c01a2e180b647eb27338cb7302aa38ef10c6 (patch) | |
tree | 9608d8ff36a80ac68f968aea8fcc31e4dae4150f /stage1/MultiClassLoader.scala | |
parent | fae67dc6124a12710599ede6e091e2de236079aa (diff) | |
parent | 55fff670befc97a871cf0f85c65764e108f3d3c1 (diff) | |
download | cbt-b143c01a2e180b647eb27338cb7302aa38ef10c6.tar.gz cbt-b143c01a2e180b647eb27338cb7302aa38ef10c6.tar.bz2 cbt-b143c01a2e180b647eb27338cb7302aa38ef10c6.zip |
Merge pull request #78 from cvogt/chris
Chris
Diffstat (limited to 'stage1/MultiClassLoader.scala')
-rw-r--r-- | stage1/MultiClassLoader.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/stage1/MultiClassLoader.scala b/stage1/MultiClassLoader.scala new file mode 100644 index 0000000..de9bd32 --- /dev/null +++ b/stage1/MultiClassLoader.scala @@ -0,0 +1,24 @@ +/* +package cbt +import java.net._ +import scala.util.Try + +import scala.collection.immutable.Seq + + +class MultiClassLoader(parents: Seq[ClassLoader]) extends ClassLoader { + override def loadClass(name: String) = { + //System.err.println("LOADING CLASS "++name); + val c = parents.toStream.map{ + parent => + Try{ + parent.loadClass(name) + }.map(Option[Class[_]](_)).recover{ + case _:ClassNotFoundException => None + }.get + }.find(_.isDefined).flatten + c.getOrElse( ClassLoader.getSystemClassLoader.loadClass(name) ) + } + override def toString = "MultiClassLoader(" ++ parents.mkString(",") ++ ")" +} +*/ |