diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index be079b2ec..0e21c55c4 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -88,8 +88,13 @@ class Interpreter(val compiler: Global, output: (String => Unit)) { shadow the old ones, and old code objects to refer to the old definitions. */ - private val classLoader = new java.net.URLClassLoader(Predef.Array(classfilePath.toURL)) - + private val classLoader = { + if (parentClassLoader == null) + new java.net.URLClassLoader(Predef.Array(classfilePath.toURL)) + else + new java.net.URLClassLoader(Predef.Array(classfilePath.toURL), parentClassLoader) + } + protected def parentClassLoader : ClassLoader = null; /** the previous requests this interpreter has processed */ private val prevRequests = new ArrayBuffer[Request]() diff --git a/src/compiler/scala/tools/nsc/MainInterpreter.scala b/src/compiler/scala/tools/nsc/MainInterpreter.scala index 832fb208f..33f890f97 100644 --- a/src/compiler/scala/tools/nsc/MainInterpreter.scala +++ b/src/compiler/scala/tools/nsc/MainInterpreter.scala @@ -108,7 +108,7 @@ class InterpreterLoop(in: BufferedReader, out: PrintWriter) { interpretOne(line) true } - + def parentClassLoader0 : ClassLoader = null; /** process command-line arguments and do as they request */ def main(args: Array[String]): unit = { @@ -121,7 +121,9 @@ class InterpreterLoop(in: BufferedReader, out: PrintWriter) { } val compiler = new Global(command.settings, reporter) - interpreter = new Interpreter(compiler, str=>Console.print(str)) + interpreter = new Interpreter(compiler, out.print) { + override protected def parentClassLoader = parentClassLoader0; + } try { if(!command.files.isEmpty) {