@@ -103,6 +103,18 @@ class Interpreter(val settings: Settings, out: PrintWriter)
103
103
}
104
104
}
105
105
106
+ /** whether to bind the lastException variable */
107
+ private var bindLastException = true
108
+
109
+ /** Temporarily stop binding lastException */
110
+ def withoutBindingLastException [T ](operation : => T ): T = {
111
+ val wasBinding = bindLastException
112
+ ultimately(bindLastException = wasBinding) {
113
+ bindLastException = false
114
+ operation
115
+ }
116
+ }
117
+
106
118
/** interpreter settings */
107
119
lazy val isettings = new InterpreterSettings (this )
108
120
@@ -477,10 +489,7 @@ class Interpreter(val settings: Settings, out: PrintWriter)
477
489
val binderObject = loadByName(binderName)
478
490
val setterMethod = methodByName(binderObject, " set" )
479
491
480
- // this roundabout approach is to ensure the value is boxed
481
- var argsHolder : Array [Any ] = null
482
- argsHolder = List (value).toArray
483
- setterMethod.invoke(null , argsHolder.asInstanceOf [Array [AnyRef ]]: _* )
492
+ setterMethod.invoke(null , value.asInstanceOf [AnyRef ])
484
493
interpret(" val %s = %s.value" .format(name, binderName))
485
494
}
486
495
@@ -791,9 +800,13 @@ class Interpreter(val settings: Settings, out: PrintWriter)
791
800
val wrapperExceptions : List [Class [_ <: Throwable ]] =
792
801
List (classOf [InvocationTargetException ], classOf [ExceptionInInitializerError ])
793
802
794
- def onErr : Catcher [(String , Boolean )] = { case t : Throwable =>
795
- quietBind(" lastException" , " java.lang.Throwable" , t)
796
- (stringFrom(t.printStackTrace(_)), false )
803
+ /** We turn off the binding to accomodate ticket #2817 */
804
+ def onErr : Catcher [(String , Boolean )] = {
805
+ case t : Throwable if bindLastException =>
806
+ withoutBindingLastException {
807
+ quietBind(" lastException" , " java.lang.Throwable" , t)
808
+ (stringFrom(t.printStackTrace(_)), false )
809
+ }
797
810
}
798
811
799
812
catching(onErr) {
0 commit comments