diff options
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) |