diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-06 20:19:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-06 20:19:15 +0000 |
commit | 1b2c72aeed98aed042f3f87354a56a612c5f7981 (patch) | |
tree | 9b9d35101983a53764278ddf3601acd519060110 /src | |
parent | 3e43cc04904fbb9fa073954bc7d1623bc535771d (diff) | |
download | scala-1b2c72aeed98aed042f3f87354a56a612c5f7981.tar.gz scala-1b2c72aeed98aed042f3f87354a56a612c5f7981.tar.bz2 scala-1b2c72aeed98aed042f3f87354a56a612c5f7981.zip |
Modified ObjectRunner to use Extension classloa...
Modified ObjectRunner to use Extension classloader as parent rather than
System classloader. Fixes bug #857.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ObjectRunner.scala | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index 7f97e06ca5..58da7b16eb 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -16,10 +16,27 @@ import java.net.{URL, URLClassLoader} * @author Lex Spoon * @version 1.1, 2007/7/13 */ -object ObjectRunner { +object ObjectRunner +{ + // we cannot use the app classloader here or we get what looks to + // be classloader deadlock, but if we pass null we bypass the extension + // classloader and our extensions, so we search the hierarchy to find + // the classloader whose parent is null. Resolves bug #857. + private def findExtClassLoader(): ClassLoader = { + def search(cl: ClassLoader): ClassLoader = { + if (cl == null) null + else if (cl.getParent == null) cl + else search(cl.getParent) + } + + search(Thread.currentThread.getContextClassLoader) + } + /** Create a class loader for the specified class path */ - private def makeClassLoader(classpath: List[URL]) = - new URLClassLoader(classpath.toArray, null) + private def makeClassLoader(classpath: List[URL]): URLClassLoader = + makeClassLoader(classpath, findExtClassLoader()) + private def makeClassLoader(classpath: List[URL], parent: ClassLoader): URLClassLoader = + new URLClassLoader(classpath.toArray, parent) /** Look up a class with a given class path. */ private def findClass(loader: ClassLoader, objectName: String) |