summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Interpreter.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-09-07 17:48:09 +0000
committerPaul Phillips <paulp@improving.org>2010-09-07 17:48:09 +0000
commit6dfcae30bfcdc93509755185f814c8e318a64012 (patch)
tree713036c0fa3b3504fd7ca8e9d991f33cc9dbeae0 /src/compiler/scala/tools/nsc/Interpreter.scala
parentb5c20527352085b01457e9104137de7b28eafdff (diff)
downloadscala-6dfcae30bfcdc93509755185f814c8e318a64012.tar.gz
scala-6dfcae30bfcdc93509755185f814c8e318a64012.tar.bz2
scala-6dfcae30bfcdc93509755185f814c8e318a64012.zip
Some modifications to repl classloading to make...
Some modifications to repl classloading to make it usable in managed classloader environments. Contributed by mark harrah. Review by rytz.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Interpreter.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 7dd6d3ba04..3be1b44a4c 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -229,7 +229,9 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
private def methodByName(c: Class[_], name: String): reflect.Method =
c.getMethod(name, classOf[Object])
- protected def parentClassLoader: ClassLoader = this.getClass.getClassLoader()
+ protected def parentClassLoader: ClassLoader =
+ settings.explicitParentLoader.getOrElse( this.getClass.getClassLoader() )
+
def getInterpreterClassLoader() = classLoader
// Set the current Java "context" class loader to this interpreter's class loader
@@ -1267,15 +1269,16 @@ object Interpreter {
}
}
}
- def breakIf(assertion: => Boolean, args: DebugParam[_]*): Unit =
- if (assertion) break(args.toList)
+ // provide the enclosing type T
+ // in order to set up the interpreter's classpath and parent class loader properly
+ def breakIf[T: Manifest](assertion: => Boolean, args: DebugParam[_]*): Unit =
+ if (assertion) break[T](args.toList)
// start a repl, binding supplied args
- def break(args: List[DebugParam[_]]): Unit = {
+ def break[T: Manifest](args: List[DebugParam[_]]): Unit = {
val intLoop = new InterpreterLoop
intLoop.settings = new Settings(Console.println)
- // XXX come back to the dot handling
- intLoop.settings.classpath.value = "."
+ intLoop.settings.embeddedDefaults[T]
intLoop.createInterpreter
intLoop.in = InteractiveReader.createDefault(intLoop.interpreter)