summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-01-13 16:02:41 +0000
committerPaul Phillips <paulp@improving.org>2010-01-13 16:02:41 +0000
commitf181a9be2af25ae20f89ab983018f34e6884d415 (patch)
treed41713b87d1617c6677ef43ed7ba8062a87d2cdb /src
parent28c75a82ea610fb5a61e53c0a031c2d64a399af5 (diff)
downloadscala-f181a9be2af25ae20f89ab983018f34e6884d415.tar.gz
scala-f181a9be2af25ae20f89ab983018f34e6884d415.tar.bz2
scala-f181a9be2af25ae20f89ab983018f34e6884d415.zip
Fix for #2817. Review by mharrah.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 06a364e4a4..f1d050de03 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -103,6 +103,18 @@ class Interpreter(val settings: Settings, out: PrintWriter)
}
}
+ /** whether to bind the lastException variable */
+ private var bindLastException = true
+
+ /** Temporarily stop binding lastException */
+ def withoutBindingLastException[T](operation: => T): T = {
+ val wasBinding = bindLastException
+ ultimately(bindLastException = wasBinding) {
+ bindLastException = false
+ operation
+ }
+ }
+
/** interpreter settings */
lazy val isettings = new InterpreterSettings(this)
@@ -477,10 +489,7 @@ class Interpreter(val settings: Settings, out: PrintWriter)
val binderObject = loadByName(binderName)
val setterMethod = methodByName(binderObject, "set")
- // this roundabout approach is to ensure the value is boxed
- var argsHolder: Array[Any] = null
- argsHolder = List(value).toArray
- setterMethod.invoke(null, argsHolder.asInstanceOf[Array[AnyRef]]: _*)
+ setterMethod.invoke(null, value.asInstanceOf[AnyRef])
interpret("val %s = %s.value".format(name, binderName))
}
@@ -791,9 +800,13 @@ class Interpreter(val settings: Settings, out: PrintWriter)
val wrapperExceptions: List[Class[_ <: Throwable]] =
List(classOf[InvocationTargetException], classOf[ExceptionInInitializerError])
- def onErr: Catcher[(String, Boolean)] = { case t: Throwable =>
- quietBind("lastException", "java.lang.Throwable", t)
- (stringFrom(t.printStackTrace(_)), false)
+ /** We turn off the binding to accomodate ticket #2817 */
+ def onErr: Catcher[(String, Boolean)] = {
+ case t: Throwable if bindLastException =>
+ withoutBindingLastException {
+ quietBind("lastException", "java.lang.Throwable", t)
+ (stringFrom(t.printStackTrace(_)), false)
+ }
}
catching(onErr) {