diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 2984dd298..9c398a219 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -60,6 +60,13 @@ import nsc.{InterpreterResults=>IR} class Interpreter(val settings: Settings, out: PrintWriter) { import symtab.Names + /* If the interpreter is running on pre-jvm-1.5 JVM, + it is necessary to force the target setting to jvm-1.4 */ + val major = System.getProperty("java.class.version").split("\\.")(0) + if (Integer.valueOf(major).intValue < 49) { + this.settings.target.value = "jvm-1.4" + } + /** the compiler to compile expressions with */ val compiler: scala.tools.nsc.Global = newCompiler(settings, reporter) diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index 54d14847a..ab2859f22 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -278,11 +278,6 @@ class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) { def main(settings: Settings) { this.settings = settings - val major = System.getProperty("java.class.version").split("\\.")(0) - if (Integer.valueOf(major).intValue < 49) { - this.settings.target.value = "jvm-1.4" - } - in = in0 match { case Some(in0) => diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 6cd396b00..1be66c6ed 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -271,6 +271,13 @@ object ScriptRunner { : Unit = { import Interpreter.deleteRecursively + + /* If the script is running on pre-jvm-1.5 JVM, + it is necessary to force the target setting to jvm-1.4 */ + val major = System.getProperty("java.class.version").split("\\.")(0) + if (Integer.valueOf(major).intValue < 49) { + settings.target.value = "jvm-1.4" + } /** Compiles the script file, and returns two things: * the directory with the compiled class files, @@ -385,11 +392,6 @@ object ScriptRunner { return } - val major = System.getProperty("java.class.version").split("\\.")(0) - if (Integer.valueOf(major).intValue < 49) { - settings.target.value = "jvm-1.4" - } - withCompiledScript(settings, scriptFile){compiledLocation => runCompiled(settings, compiledLocation, scriptArgs) } @@ -410,11 +412,6 @@ object ScriptRunner { str.close() } - val major = System.getProperty("java.class.version").split("\\.")(0) - if (Integer.valueOf(major).intValue < 49) { - settings.target.value = "jvm-1.4" - } - withCompiledScript(settings, scriptFile.getPath){compiledLocation => scriptFile.delete() runCompiled(settings, compiledLocation, scriptArgs)