diff options
author | Paul Phillips <paulp@improving.org> | 2010-02-23 00:27:39 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-02-23 00:27:39 +0000 |
commit | df94b3c5b831e78a056f7b0b5334b1fb8d3c3bd5 (patch) | |
tree | 6be1d68b93045d6a568ac165126d4ed8e11e3fd7 | |
parent | 8d74992310fe60a1da32606949c96531691754e9 (diff) | |
download | scala-df94b3c5b831e78a056f7b0b5334b1fb8d3c3bd5.tar.gz scala-df94b3c5b831e78a056f7b0b5334b1fb8d3c3bd5.tar.bz2 scala-df94b3c5b831e78a056f7b0b5334b1fb8d3c3bd5.zip |
Some much needed housecleaning regarding system...
Some much needed housecleaning regarding system properties. If you can
possibly resist the temptation, it'd be great if people could try to
go through the properties classes to get and set them, and also to set
property values somewhere fixed rather than using strings directly.
Review by community.
27 files changed, 310 insertions, 298 deletions
diff --git a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala index c34cc83df6..c96dd6d8d3 100644 --- a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala +++ b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala @@ -11,6 +11,8 @@ package scala.actors package scheduler +import util.Properties.{ javaVersion, javaVmVendor, isJavaAtLeast, propIsSetTo, propOrNone } + /** * @author Erik Engbrecht * @author Philipp Haller @@ -19,15 +21,9 @@ object ThreadPoolConfig { private val rt = Runtime.getRuntime() private val minNumThreads = 4 - private def getIntegerProp(propName: String): Option[Int] = { - try { - val prop = System.getProperty(propName) - Some(Integer.parseInt(prop)) - } catch { - case se: SecurityException => None - case nfe: NumberFormatException => None - } - } + private def getIntegerProp(propName: String): Option[Int] = + try propOrNone(propName) map (_.toInt) + catch { case _: SecurityException | _: NumberFormatException => None } val corePoolSize = getIntegerProp("actors.corePoolSize") match { case Some(i) if i > 0 => i @@ -38,30 +34,19 @@ object ThreadPoolConfig { } val maxPoolSize = { - val preMaxSize = getIntegerProp("actors.maxPoolSize") match { - case Some(i) => i - case _ => 256 - } + val preMaxSize = getIntegerProp("actors.maxPoolSize") getOrElse 256 if (preMaxSize >= corePoolSize) preMaxSize else corePoolSize } private[actors] def useForkJoin: Boolean = - try { - val fjProp = System.getProperty("actors.enableForkJoin") - if (fjProp != null) - fjProp.equals("true") - else { - val javaVersion = System.getProperty("java.version") - val jvmVendor = System.getProperty("java.vm.vendor") - Debug.info(this+": java.version = "+javaVersion) - Debug.info(this+": java.vm.vendor = "+jvmVendor) - (javaVersion.indexOf("1.6") != -1 || - javaVersion.indexOf("1.7") != -1) && - // on IBM J9 1.6 do not use ForkJoinPool - (jvmVendor.indexOf("Sun") != -1) - } - } catch { - case se: SecurityException => false - } + try propIsSetTo("actors.enableForkJoin", "true") || { + Debug.info(this+": java.version = "+javaVersion) + Debug.info(this+": java.vm.vendor = "+javaVmVendor) + // on IBM J9 1.6 do not use ForkJoinPool + isJavaAtLeast(1.6) && (javaVmVendor contains "Sun") + } + catch { + case _: SecurityException => false + } } diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 305c4e211d..8d599c6c96 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -23,13 +23,12 @@ class CompileSocket { /** The prefix of the port identification file, which is followed * by the port number. */ - protected def dirName = "scalac-compile-server-port" //todo: lazy val - - protected def cmdName = Properties.cmdName //todo: lazy val + protected lazy val dirName = "scalac-compile-server-port" + protected lazy val cmdName = Properties.scalaCmd /** The vm part of the command to start a new scala compile server */ protected val vmCommand = Properties.scalaHome match { - case null => cmdName + case "" => cmdName case dirname => val trial = File(dirname) / "bin" / cmdName if (trial.canRead) trial.path diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index a805da1fcc..dd581e0878 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -26,7 +26,8 @@ class CompilerCommand( lazy val fileEndings = Properties.fileEndings /** The name of the command */ - val cmdName = "scalac" + def cmdName = "scalac" + private def isFsc = cmdName == "fsc" private val helpSyntaxColumnWidth: Int = (settings.visibleSettings map (_.helpSyntax.length)) max @@ -53,8 +54,7 @@ class CompilerCommand( // an informative message of some sort should be printed instead. // (note: do not add "files.isEmpty" do this list) val stopSettings = List[(() => Boolean, (Global) => String)]( - ((() => (settings.help.value _)() && (cmdName == "fsc")), - fscUsageMsg + _.pluginOptionsHelp), + ((() => (settings.help.value _)() && isFsc), fscUsageMsg + _.pluginOptionsHelp), (settings.help.value _, usageMsg + _.pluginOptionsHelp), (settings.Xhelp.value _, _ => xusageMsg), (settings.Yhelp.value _, _ => yusageMsg), diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index b8e25c4bd4..1ef249735f 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -555,10 +555,8 @@ class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) { in = in0 match { case Some(in0) => new SimpleReader(in0, out, true) case None => - val emacsShell = System.getProperty("env.emacs", "") != "" - // the interpreter is passed as an argument to expose tab completion info - if (settings.Xnojline.value || emacsShell) new SimpleReader + if (settings.Xnojline.value || Properties.isEmacsShell) new SimpleReader else if (settings.noCompletion.value) InteractiveReader.createDefault() else InteractiveReader.createDefault(interpreter) } diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index 577439990d..4f945733fd 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -7,6 +7,7 @@ package scala.tools.nsc import java.io.File +import File.pathSeparator import scala.concurrent.SyncVar @@ -14,6 +15,7 @@ import scala.tools.nsc.interactive.{ RefinedBuildManager, SimpleBuildManager } import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} import scala.tools.nsc.util.{ BatchSourceFile, FakePos } //{Position} +import Properties.{ versionString, copyrightString, residentPromptString, msilLibPath } /** The main class for NSC, a compiler for the programming * language Scala. @@ -21,10 +23,10 @@ import scala.tools.nsc.util.{ BatchSourceFile, FakePos } //{Position} object Main extends AnyRef with EvalLoop { val versionMsg = "Scala compiler " + - Properties.versionString + " -- " + - Properties.copyrightString + versionString + " -- " + + copyrightString - val prompt = Properties.residentPromptString + val prompt = residentPromptString var reporter: ConsoleReporter = _ @@ -82,12 +84,9 @@ object Main extends AnyRef with EvalLoop { buildManager.update(fileSet(command.files), Set.empty) } } else { - if (command.settings.target.value == "msil") { - val libpath = System.getProperty("msil.libpath") - if (libpath != null) - command.settings.assemrefs.value = - command.settings.assemrefs.value + File.pathSeparator + libpath - } + if (command.settings.target.value == "msil") + msilLibPath foreach (x => command.settings.assemrefs.value += (pathSeparator + x)) + try { val compiler = if (command.settings.Yrangepos.value) new interactive.Global(command.settings, reporter) else new Global(command.settings, reporter) diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala index 8b30929092..346f5947cd 100644 --- a/src/compiler/scala/tools/nsc/Properties.scala +++ b/src/compiler/scala/tools/nsc/Properties.scala @@ -13,11 +13,14 @@ object Properties extends scala.util.PropertiesTrait { protected def pickJarBasedOn = classOf[Global] // settings based on jar properties - def fileEndingString = prop("file.ending", ".scala|.java") - def residentPromptString = prop("resident.prompt", "\nnsc> ") - def shellPromptString = prop("shell.prompt", "\nscala> ") + def fileEndingString = scalaPropOrElse("file.ending", ".scala|.java") + def residentPromptString = scalaPropOrElse("resident.prompt", "\nnsc> ") + def shellPromptString = scalaPropOrElse("shell.prompt", "\nscala> ") + + // settings based on system properties + def msilLibPath = propOrNone("msil.libpath") // derived values - def cmdName = if (isWin) "scala.bat" else "scala" + def isEmacsShell = propIsSet("env.emacs") def fileEndings = fileEndingString.split("""\|""").toList } diff --git a/src/compiler/scala/tools/nsc/ScalaDoc.scala b/src/compiler/scala/tools/nsc/ScalaDoc.scala index f3c7c686a0..4a9bbe8fd3 100644 --- a/src/compiler/scala/tools/nsc/ScalaDoc.scala +++ b/src/compiler/scala/tools/nsc/ScalaDoc.scala @@ -11,7 +11,8 @@ import java.io.File import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} import scala.tools.nsc.util.FakePos //{Position} - +import Properties.msilLibPath +import File.pathSeparator /** The main class for scaladoc, a front-end for the Scala compiler * that generates documentation from source files. @@ -56,11 +57,8 @@ object ScalaDoc { reporter.warning(null, "Phases are restricted when using Scaladoc") else try { - if (docSettings.target.value == "msil") { - val libpath = System.getProperty("msil.libpath") - if (libpath != null) - docSettings.assemrefs.value = docSettings.assemrefs.value + File.pathSeparator + libpath - } + if (docSettings.target.value == "msil") + msilLibPath foreach (x => docSettings.assemrefs.value += (pathSeparator + x)) val docProcessor = new scala.tools.nsc.doc.DocFactory(reporter, docSettings) docProcessor.document(command.files) diff --git a/src/compiler/scala/tools/nsc/interpreter/History.scala b/src/compiler/scala/tools/nsc/interpreter/History.scala index 519d17f9d2..7bd4e89095 100644 --- a/src/compiler/scala/tools/nsc/interpreter/History.scala +++ b/src/compiler/scala/tools/nsc/interpreter/History.scala @@ -9,6 +9,7 @@ package interpreter import java.io.File import jline.{ ConsoleReader, History => JHistory } import scala.collection.JavaConversions.asBuffer +import Properties.userHome /** Primarily, a wrapper for JLine's History. */ @@ -22,14 +23,13 @@ class History(val jhistory: JHistory) { object History { val ScalaHistoryFile = ".scala_history" - def homeDir = System.getProperty("user.home") def apply(reader: ConsoleReader): History = if (reader == null) apply() else new History(reader.getHistory) def apply(): History = new History( - try new JHistory(new File(homeDir, ScalaHistoryFile)) + try new JHistory(new File(userHome, ScalaHistoryFile)) // do not store history if error catch { case _: Exception => new JHistory() } ) diff --git a/src/compiler/scala/tools/nsc/io/Directory.scala b/src/compiler/scala/tools/nsc/io/Directory.scala index 6a4e78560d..709ffdc1e0 100644 --- a/src/compiler/scala/tools/nsc/io/Directory.scala +++ b/src/compiler/scala/tools/nsc/io/Directory.scala @@ -14,11 +14,11 @@ import collection.Traversable object Directory { - import scala.util.Properties.{ tmpDir, homeDir, currentDir } + import scala.util.Properties.{ tmpDir, userHome, userDir } private def normalizePath(s: String) = Some(apply(Path(s).normalize)) - def Current: Option[Directory] = if (currentDir == "") None else normalizePath(currentDir) - def Home: Option[Directory] = if (homeDir == "") None else normalizePath(homeDir) + def Current: Option[Directory] = if (userDir == "") None else normalizePath(userDir) + def Home: Option[Directory] = if (userHome == "") None else normalizePath(userHome) def TmpDir: Option[Directory] = if (tmpDir == "") None else normalizePath(tmpDir) def apply(path: Path) = path.toDirectory diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 1a7c121d56..5c6bd2c884 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -7,6 +7,7 @@ package scala.tools package util import java.net.{ URL, MalformedURLException } +import scala.util.Properties._ import nsc.{ Settings, GenericRunnerSettings } import nsc.util.{ ClassPath, JavaClassPath, ScalaClassLoader } import nsc.io.{ File, Directory, Path } @@ -17,8 +18,6 @@ import PartialFunction.condOpt // https://lampsvn.epfl.ch/trac/scala/wiki/Classpath object PathResolver { - def propOrElse(name: String, alt: String) = System.getProperty(name, alt) - def envOrElse(name: String, alt: String) = Option(System getenv name) getOrElse alt def firstNonEmpty(xs: String*) = xs find (_ != "") getOrElse "" private def fileOpt(f: Path): Option[String] = f ifFile (_.path) @@ -53,27 +52,26 @@ object PathResolver { def sourcePathEnv = envOrElse("SOURCEPATH", "") // not used def scalaHomeEnv = envOrElse("SCALA_HOME", "") // not used def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath) - def javaUserClassPath = propOrElse("java.class.path", "") def javaExtDirs = propOrElse("java.ext.dirs", "") - def userHome = propOrElse("user.home", "") - def scalaHome = System.getProperty("scala.home") // keep null so we know when it's unset + def javaUserClassPath = propOrElse("java.class.path", classPathEnv) def scalaExtDirs = propOrElse("scala.ext.dirs", "") - def scalaHomeGuessed = searchForScalaHome + + def scalaHome = propOrElse("scala.home", null) def scalaHomeIsSet = scalaHome != null + def scalaAutodetect = propIsSet("scala.auto") && !propIsSet("scala.noauto") override def toString = """ |object Environment { + | scalaHome = %s (autodetect = %s) | javaBootClassPath = <%d chars> - | javaUserClassPath = %s | javaExtDirs = %s - | userHome = %s - | scalaHome = %s + | javaUserClassPath = %s | scalaExtDirs = %s |}""".trim.stripMargin.format( + scalaHome, scalaAutodetect, javaBootClassPath.length, - ppcp(javaUserClassPath), ppcp(javaExtDirs), - userHome, scalaHome, + ppcp(javaUserClassPath), ppcp(scalaExtDirs) ) } @@ -116,15 +114,16 @@ object PathResolver { override def toString = """ |object Defaults { - | javaBootClassPath = %s | scalaHome = %s + | javaBootClassPath = %s | scalaLibDirFound = %s | scalaLibFound = %s | scalaBootClassPath = %s | scalaPluginPath = %s |}""".trim.stripMargin.format( + scalaHome, ppcp(javaBootClassPath), - scalaHome, scalaLibDirFound, scalaLibFound, + scalaLibDirFound, scalaLibFound, ppcp(scalaBootClassPath), ppcp(scalaPluginPath) ) } @@ -207,17 +206,17 @@ class PathResolver(settings: Settings, context: JavaContext) { |object Calculated { | scalaHome = %s | javaBootClassPath = %s + | javaExtDirs = %s | javaUserClassPath = %s | scalaBootClassPath = %s - | javaExtDirs = %s | scalaExtDirs = %s | userClassPath = %s | sourcePath = %s |}""".trim.stripMargin.format( scalaHome, - ppcp(javaBootClassPath), ppcp(javaUserClassPath), ppcp(scalaBootClassPath), - ppcp(javaExtDirs), ppcp(scalaExtDirs), - ppcp(userClassPath), ppcp(sourcePath) + ppcp(javaBootClassPath), ppcp(javaExtDirs), ppcp(javaUserClassPath), + ppcp(scalaBootClassPath), ppcp(scalaExtDirs), ppcp(userClassPath), + ppcp(sourcePath) ) } diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala index e9b97b5356..fdb122f5bf 100644 --- a/src/library/scala/Application.scala +++ b/src/library/scala/Application.scala @@ -11,7 +11,6 @@ package scala -import java.lang.System.getProperty import scala.compat.Platform.currentTime /** <p> @@ -84,7 +83,7 @@ trait Application { * @param args the arguments passed to the main method */ def main(args: Array[String]) { - if (getProperty("scala.time") ne null) { + if (util.Properties.propIsSet("scala.time")) { val total = currentTime - executionStart Console.println("[total " + total + "ms]") } diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala index f7f5070699..7580d2cc0e 100644 --- a/src/library/scala/compat/Platform.scala +++ b/src/library/scala/compat/Platform.scala @@ -47,7 +47,7 @@ object Platform { @inline def getClassForName(name: String): Class[_] = java.lang.Class.forName(name) - val EOL = System.getProperty("line.separator", "\n") + val EOL = util.Properties.lineSeparator @inline def currentTime: Long = System.currentTimeMillis() diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala index ee3e68ed76..d61a834555 100644 --- a/src/library/scala/util/Properties.scala +++ b/src/library/scala/util/Properties.scala @@ -8,12 +8,18 @@ // $Id$ - package scala.util +import java.io.{ IOException, PrintWriter } + +/** Loads library.properties from the jar. */ +object Properties extends PropertiesTrait { + protected def propCategory = "library" + protected def pickJarBasedOn = classOf[ScalaObject] +} + private[scala] trait PropertiesTrait { - import java.io.{ IOException, PrintWriter } protected def propCategory: String // specializes the remainder of the values protected def pickJarBasedOn: Class[_] // props file comes from jar containing this @@ -21,7 +27,7 @@ private[scala] trait PropertiesTrait protected val propFilename = "/" + propCategory + ".properties" /** The loaded properties */ - protected lazy val props: java.util.Properties = { + protected lazy val scalaProps: java.util.Properties = { val props = new java.util.Properties val stream = pickJarBasedOn getResourceAsStream propFilename if (stream ne null) @@ -37,53 +43,76 @@ private[scala] trait PropertiesTrait catch { case _: IOException => } } - // for values based on system properties - def sysprop(name: String): String = sysprop(name, "") - def sysprop(name: String, default: String): String = System.getProperty(name, default) - def syspropset(name: String, value: String) = System.setProperty(name, value) + def propIsSet(name: String) = System.getProperty(name) != null + def propIsSetTo(name: String, value: String) = propOrNull(name) == value + def propOrElse(name: String, alt: String) = System.getProperty(name, alt) + def propOrEmpty(name: String) = propOrElse(name, "") + def propOrNull(name: String) = propOrElse(name, null) + def propOrNone(name: String) = Option(propOrNull(name)) + def setProp(name: String, value: String) = System.setProperty(name, value) + def clearProp(name: String) = System.clearProperty(name) + + def envOrElse(name: String, alt: String) = Option(System getenv name) getOrElse alt // for values based on propFilename - def prop(name: String): String = props.getProperty(name, "") - def prop(name: String, default: String): String = props.getProperty(name, default) + def scalaPropOrElse(name: String, alt: String): String = scalaProps.getProperty(name, alt) + def scalaPropOrEmpty(name: String): String = scalaPropOrElse(name, "") /** The version number of the jar this was loaded from plus "version " prefix, * or "version (unknown)" if it cannot be determined. */ - val versionString = "version " + prop("version.number", "(unknown)") - val copyrightString = prop("copyright.string", "(c) 2002-2010 LAMP/EPFL") + val versionString = "version " + scalaPropOrElse("version.number", "(unknown)") + val copyrightString = scalaPropOrElse("copyright.string", "(c) 2002-2010 LAMP/EPFL") /** This is the encoding to use reading in source files, overridden with -encoding * Note that it uses "prop" i.e. looks in the scala jar, not the system properties. */ - def sourceEncoding = prop("file.encoding", "UTF-8") + def sourceEncoding = scalaPropOrElse("file.encoding", "UTF-8") /** This is the default text encoding, overridden (unreliably) with * JAVA_OPTS="-Dfile.encoding=Foo" */ - def encodingString = sysprop("file.encoding", "UTF-8") - - def isWin = sysprop("os.name") startsWith "Windows" - def isMac = sysprop("java.vendor") startsWith "Apple" - def javaClassPath = sysprop("java.class.path") - def javaHome = sysprop("java.home") - def javaVmName = sysprop("java.vm.name") - def javaVmVersion = sysprop("java.vm.version") - def javaVmInfo = sysprop("java.vm.info") - def javaVersion = sysprop("java.version") - def tmpDir = sysprop("java.io.tmpdir") - def homeDir = sysprop("user.home") - def currentDir = sysprop("user.dir") - def userName = sysprop("user.name") - def scalaHome = sysprop("scala.home", null) // XXX places do null checks... + def encodingString = propOrElse("file.encoding", "UTF-8") + + /** The default end of line character. + */ + def lineSeparator = propOrElse("line.separator", "\n") + + /** Various well-known properties. + */ + def javaClassPath = propOrEmpty("java.class.path") + def javaHome = propOrEmpty("java.home") + def javaVendor = propOrEmpty("java.vendor") + def javaVersion = propOrEmpty("java.version") + def javaVmInfo = propOrEmpty("java.vm.info") + def javaVmName = propOrEmpty("java.vm.name") + def javaVmVendor = propOrEmpty("java.vm.vendor") + def javaVmVersion = propOrEmpty("java.vm.version") + def osName = propOrEmpty("os.name") + def scalaHome = propOrEmpty("scala.home") + def tmpDir = propOrEmpty("java.io.tmpdir") + def userDir = propOrEmpty("user.dir") + def userHome = propOrEmpty("user.home") + def userName = propOrEmpty("user.name") + + /** Some derived values. + */ + def isWin = osName startsWith "Windows" + def isMac = javaVendor startsWith "Apple" - // provide a main method so version info can be obtained by running this - private val writer = new java.io.PrintWriter(Console.err, true) def versionMsg = "Scala %s %s -- %s".format(propCategory, versionString, copyrightString) - def main(args: Array[String]) { writer println versionMsg } -} + def scalaCmd = if (isWin) "scala.bat" else "scala" + def scalacCmd = if (isWin) "scalac.bat" else "scalac" -/** Loads library.properties from the jar. */ -object Properties extends PropertiesTrait { - protected def propCategory = "library" - protected def pickJarBasedOn = classOf[Application] + /** Can the java version be determined to be at least as high as the argument? + */ + def isJavaAtLeast(version: Double) = + try javaVersion.toDouble >= version + catch { case _: NumberFormatException => false } + + // provide a main method so version info can be obtained by running this + def main(args: Array[String]) { + val writer = new PrintWriter(Console.err, true) + writer println versionMsg + } } diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala index 45f1ebc2f1..65858d16ea 100644 --- a/src/partest/scala/tools/partest/PartestTask.scala +++ b/src/partest/scala/tools/partest/PartestTask.scala @@ -11,6 +11,7 @@ package scala.tools.partest import scala.actors.Actor._ +import util.Properties.setProp import java.io.File import java.net.URLClassLoader @@ -166,7 +167,7 @@ class PartestTask extends Task { override def execute() { if (isPartestDebug) - System.setProperty("partest.debug", "true") + setProp("partest.debug", "true") if (classpath.isEmpty) error("Mandatory attribute 'classpath' is not set.") diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index 63acf654e2..517620e958 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -141,36 +141,36 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler { } } -class ReflectiveCompiler(val fileManager: ConsoleFileManager) extends SimpleCompiler { - import fileManager.{latestCompFile, latestPartestFile} - - val sepUrls = Array(latestCompFile.toURI.toURL, latestPartestFile.toURI.toURL) - //NestUI.verbose("constructing URLClassLoader from URLs "+latestCompFile+" and "+latestPartestFile) - - val sepLoader = new java.net.URLClassLoader(sepUrls, null) - - val sepCompilerClass = - sepLoader.loadClass("scala.tools.partest.nest.DirectCompiler") - val sepCompiler = sepCompilerClass.newInstance() - - // needed for reflective invocation - val fileClass = Class.forName("java.io.File") - val stringClass = Class.forName("java.lang.String") - val sepCompileMethod = - sepCompilerClass.getMethod("compile", fileClass, stringClass) - val sepCompileMethod2 = - sepCompilerClass.getMethod("compile", fileClass, stringClass, fileClass) - - /* This method throws java.lang.reflect.InvocationTargetException - * if the compiler crashes. - * This exception is handled in the shouldCompile and shouldFailCompile - * methods of class CompileManager. - */ - def compile(out: Option[File], files: List[File], kind: String, log: File): Boolean = { - val res = sepCompileMethod2.invoke(sepCompiler, out, files, kind, log).asInstanceOf[java.lang.Boolean] - res.booleanValue() - } -} +// class ReflectiveCompiler(val fileManager: ConsoleFileManager) extends SimpleCompiler { +// import fileManager.{latestCompFile, latestPartestFile} +// +// val sepUrls = Array(latestCompFile.toURI.toURL, latestPartestFile.toURI.toURL) +// //NestUI.verbose("constructing URLClassLoader from URLs "+latestCompFile+" and "+latestPartestFile) +// +// val sepLoader = new java.net.URLClassLoader(sepUrls, null) +// +// val sepCompilerClass = +// sepLoader.loadClass("scala.tools.partest.nest.DirectCompiler") +// val sepCompiler = sepCompilerClass.newInstance() +// +// // needed for reflective invocation +// val fileClass = Class.forName("java.io.File") +// val stringClass = Class.forName("java.lang.String") +// val sepCompileMethod = +// sepCompilerClass.getMethod("compile", fileClass, stringClass) +// val sepCompileMethod2 = +// sepCompilerClass.getMethod("compile", fileClass, stringClass, fileClass) +// +// /* This method throws java.lang.reflect.InvocationTargetException +// * if the compiler crashes. +// * This exception is handled in the shouldCompile and shouldFailCompile +// * methods of class CompileManager. +// */ +// def compile(out: Option[File], files: List[File], kind: String, log: File): Boolean = { +// val res = sepCompileMethod2.invoke(sepCompiler, out, files, kind, log).asInstanceOf[java.lang.Boolean] +// res.booleanValue() +// } +// } class CompileManager(val fileManager: FileManager) { var compiler: SimpleCompiler = new /*ReflectiveCompiler*/ DirectCompiler(fileManager) diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 258651e0ce..c5d67fb4e2 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -10,16 +10,27 @@ package nest import java.io.{ File, FilenameFilter, IOException, StringWriter } import java.net.URI +import scala.util.Properties.{ propOrElse, scalaCmd, scalacCmd } import scala.tools.util.PathResolver -import scala.tools.nsc.io +import scala.tools.nsc.{ Settings } +import scala.tools.nsc.{ io, util } +import util.{ ClassPath } import io.{ Path, Directory } import File.pathSeparator -import PathResolver.{ propOrElse } +import ClassPath.{ join } +import PathResolver.{ Environment, Defaults } +import RunnerUtils._ + +object ConsoleFileManager { + def testRootPropDir = Option(propOrElse("scalatest.root", null)) map (x => Directory(x)) +} +import ConsoleFileManager._ class ConsoleFileManager extends FileManager { - implicit private def tempPathConversion(x: Path): File = x.jfile + implicit private def temporaryPath2File(x: Path): File = x.jfile + implicit private def temporaryFile2Path(x: File): Path = Path(x) - var testBuild: Option[String] = Option(System.getProperty("scalatest.build")) + var testBuild: Option[String] = PartestDefaults.testBuild def testBuildFile = testBuild map (testParent / _) var testClasses: Option[String] = None @@ -44,15 +55,15 @@ class ConsoleFileManager extends FileManager { SCALAC_OPTS = SCALAC_OPTS+" "+moreOpts } - var CLASSPATH = PathResolver.Environment.javaUserClassPath + var CLASSPATH = PartestDefaults.classPath + var JAVACMD = PartestDefaults.javaCmd + var JAVAC_CMD = PartestDefaults.javacCmd NestUI.verbose("CLASSPATH: "+CLASSPATH) - var JAVACMD = propOrElse("scalatest.javacmd", "java") - var JAVAC_CMD = propOrElse("scalatest.javac_cmd", "javac") - - val prefixDir = Directory.Current map (_.normalize.toDirectory) getOrElse error("user.dir property not set") - val PREFIX = prefixDir.toAbsolute.path + val prefixDir = PartestDefaults.prefixDir getOrElse error("user.dir property not set") + val srcDirName = PartestDefaults.srcDirName + val PREFIX = prefixDir.toAbsolute.path /* if [ -d "$PREFIX/test" ]; then @@ -64,11 +75,10 @@ else */ val testRootDir = { - val testRootProp = Option(propOrElse("scalatest.root", null)) map (x => Directory(x)) def isTestDir(d: Directory) = d.name == "test" && (d / "files" isDirectory) ( - testRootProp orElse ( + testRootPropDir orElse ( if (isTestDir(prefixDir)) Some(prefixDir) else None // cwd is `test` ) orElse ( (prefixDir / "test") ifDirectory (x => x) // cwd is `test/..` @@ -83,19 +93,14 @@ else def testParent = testRootDir.parent - var srcDirName: String = "" + val srcDir = (testRootDir / srcDirName).toDirectory - val srcDir: io.Directory = { - srcDirName = Option(System.getProperty("partest.srcdir")) getOrElse "files" - val src = testRootDir / srcDirName - - if (src.isDirectory) src.toDirectory - else { - NestUI.failure("Source directory \"" + src.path + "\" not found") - exit(1) - } + if (!srcDir.isDirectory) { + NestUI.failure("Source directory \"" + srcDir.path + "\" not found") + exit(1) } + LIB_DIR = (testParent / "lib").normalize.toAbsolute.path CLASSPATH = { @@ -195,13 +200,8 @@ else LATEST_COMP = latestCompFile.getAbsolutePath LATEST_PARTEST = latestPartestFile.getAbsolutePath - import util.Properties.isWin - - val scalaCommand = if (isWin) "scala.bat" else "scala" - val scalacCommand = if (isWin) "scalac.bat" else "scalac" - - SCALA = (new File(latestFile, scalaCommand)).getAbsolutePath - SCALAC_CMD = (new File(latestFile, scalacCommand)).getAbsolutePath + SCALA = (latestFile / scalaCmd).toAbsolute.path + SCALAC_CMD = (latestFile / scalacCmd).toAbsolute.path } var BIN_DIR: String = "" diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 9e582bb1cd..8542e08071 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -11,13 +11,14 @@ package nest import java.io.{File, PrintStream, FileOutputStream, BufferedReader, InputStreamReader, StringWriter, PrintWriter} import utils.Properties._ -import scala.tools.nsc.Properties.versionMsg +import RunnerUtils._ +import scala.tools.nsc.Properties.{ versionMsg, setProp } import scala.tools.nsc.util.CommandLineParser import scala.tools.nsc.io import scala.tools.nsc.interpreter.returning import io.{ Path } -class ConsoleRunner extends DirectRunner with RunnerUtils { +class ConsoleRunner extends DirectRunner { case class TestSet(loc: String, filter: Option[(String, Boolean)], @@ -45,8 +46,7 @@ class ConsoleRunner extends DirectRunner with RunnerUtils { var fileManager: ConsoleFileManager = _ private var testFiles: List[File] = List() - private val errors = - Integer.parseInt(System.getProperty("scalatest.errors", "0")) + private val errors = PartestDefaults.errorCount private val testSetArgMap = testSets map (x => ("--" + x.loc) -> x) toMap private val testSetArgs = testSets map ("--" + _.loc) @@ -75,7 +75,7 @@ class ConsoleRunner extends DirectRunner with RunnerUtils { return NestUI.usage() } - parsed get "--srcpath" foreach (x => System.setProperty("partest.srcdir", x)) + parsed get "--srcpath" foreach (x => setProp("partest.srcdir", x)) fileManager = if (parsed isSet "--buildpath") new ConsoleFileManager(parsed("--buildpath")) diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index 3778a927df..1dd0d5a9aa 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -11,6 +11,7 @@ package nest import java.io.{File, PrintStream, FileOutputStream, BufferedReader, InputStreamReader, StringWriter, PrintWriter} import java.util.StringTokenizer +import scala.util.Properties.{ setProp } import scala.tools.nsc.io.Directory import scala.actors.Actor._ @@ -20,20 +21,14 @@ trait DirectRunner { def fileManager: FileManager - private val numActors = Integer.parseInt(System.getProperty("scalatest.actors", "8")) + import PartestDefaults.numActors if (isPartestDebug) scala.actors.Debug.level = 3 - private val coreProp = try { - System.getProperty("actors.corePoolSize") - } catch { - case ace: java.security.AccessControlException => - null - } - if (coreProp == null) { + if (PartestDefaults.poolSize.isEmpty) { scala.actors.Debug.info("actors.corePoolSize not defined") - System.setProperty("actors.corePoolSize", "16") + setProp("actors.corePoolSize", "16") } def runTestsForFiles(kindFiles: List[File], kind: String): scala.collection.immutable.Map[String, Int] = { diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index ffeba6bbe3..b8f0770f3a 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -55,10 +55,9 @@ trait FileManager { var showLog = false var failed = false - var SCALAC_OPTS = System.getProperty("scalatest.scalac_opts", "-deprecation") - var JAVA_OPTS = System.getProperty("scalatest.java_opts", "") - - var timeout = "1200000" + var SCALAC_OPTS = PartestDefaults.scalacOpts + var JAVA_OPTS = PartestDefaults.javaOpts + var timeout = PartestDefaults.timeout def getLogFile(dir: File, fileBase: String, kind: String): LogFile = new LogFile(dir, fileBase + "-" + kind + ".log") diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index 2063d51b71..b3f199a3d6 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -8,9 +8,12 @@ package scala.tools.partest package nest +import scala.tools.nsc.Properties.{ setProp, propOrEmpty } import scala.tools.nsc.util.ClassPath import scala.tools.nsc.io import io.Path +import RunnerUtils._ +import java.net.URLClassLoader /* This class is used to load an instance of DirectRunner using * a custom class loader. @@ -19,14 +22,10 @@ import io.Path * the main NestRunner can be started merely by putting its * class on the classpath (ideally). */ -class ReflectiveRunner extends RunnerUtils { +class ReflectiveRunner { // TODO: we might also use fileManager.CLASSPATH // to use the same classes as used by `scala` that // was used to start the runner. - - import java.net.URLClassLoader - import utils.Properties.{ sysprop, syspropset } - val sepRunnerClassName = "scala.tools.partest.nest.ConsoleRunner" def main(args: String) { @@ -65,12 +64,12 @@ class ReflectiveRunner extends RunnerUtils { } val newClasspath = ClassPath.join(paths: _*) - syspropset("java.class.path", newClasspath) - syspropset("scala.home", "") + setProp("java.class.path", newClasspath) + setProp("scala.home", "") if (isPartestDebug) for (prop <- List("java.class.path", "sun.boot.class.path", "java.ext.dirs")) - println(prop + ": " + sysprop(prop)) + println(prop + ": " + propOrEmpty(prop)) try { val sepRunnerClass = sepLoader loadClass sepRunnerClassName diff --git a/src/partest/scala/tools/partest/nest/RunnerUtils.scala b/src/partest/scala/tools/partest/nest/RunnerUtils.scala index 4e41d00bf1..24445bb545 100644 --- a/src/partest/scala/tools/partest/nest/RunnerUtils.scala +++ b/src/partest/scala/tools/partest/nest/RunnerUtils.scala @@ -8,35 +8,22 @@ package scala.tools.partest package nest -trait RunnerUtils { +object RunnerUtils { + def splitArgs(str: String) = str split "\\s" filterNot (_ == "") toList - def searchPath(option: String, as: List[String]): Option[String] = { - val Option = option - as match { - case Option :: r :: rs => Some(r) - case other :: rest => searchPath(option, rest) - case List() => None - } + def searchPath(option: String, as: List[String]): Option[String] = as match { + case `option` :: r :: _ => Some(r) + case _ :: rest => searchPath(option, rest) + case Nil => None } - def searchAndRemovePath(option: String, as: List[String]): (Option[String], List[String]) = { - val Option = option - def search(before: List[String], after: List[String]): (Option[String], List[String]) = after match { - case Option :: r :: rs => (Some(r), before ::: rs) - case other :: rest => search(before ::: List(other), rest) - case List() => (None, before) - } - search(List(), as) + def searchAndRemovePath(option: String, as: List[String]) = (as indexOf option) match { + case -1 => (None, as) + case idx => (Some(as(idx + 1)), (as take idx) ::: (as drop (idx + 2))) } - def searchAndRemoveOption(option: String, as: List[String]): (Boolean, List[String]) = { - val Option = option - def search(before: List[String], after: List[String]): (Boolean, List[String]) = after match { - case Option :: rest => (true, before ::: rest) - case other :: rest => search(before ::: List(other), rest) - case List() => (false, before) - } - search(List(), as) + def searchAndRemoveOption(option: String, as: List[String]) = (as indexOf option) match { + case -1 => (false, as) + case idx => (true, (as take idx) ::: (as drop (idx + 1))) } - } diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala index 7a947b3298..4bbd34766c 100644 --- a/src/partest/scala/tools/partest/nest/Worker.scala +++ b/src/partest/scala/tools/partest/nest/Worker.scala @@ -12,6 +12,7 @@ import java.io._ import java.net.{URLClassLoader, URL} import java.util.{Timer, TimerTask} +import scala.util.Properties.osName import scala.tools.nsc.{ ObjectRunner, Settings, CompilerCommand, Global } import scala.tools.nsc.io.{ AbstractFile, PlainFile, Path, Directory, File => SFile } import scala.tools.nsc.reporters.ConsoleReporter @@ -121,48 +122,48 @@ class Worker(val fileManager: FileManager) extends Actor { } /* Note: not yet used/tested. */ - def execTestObjectRunner(file: File, outDir: File, logFile: File) { - val consFM = new ConsoleFileManager - - val classpath: List[URL] = { - import consFM.{ latestCompFile, latestLibFile, latestPartestFile } - val units = ( - List(outDir, latestCompFile, latestLibFile, latestPartestFile) ::: - ((CLASSPATH split File.pathSeparatorChar).toList map (x => new File(x))) - ) - units map (_.toURI.toURL) - } - - NestUI.verbose("ObjectRunner classpath: "+classpath) - - try { - // configure input/output files - val logOut = new FileOutputStream(logFile) - val logWriter = new PrintStream(logOut) - - // grab global lock - fileManager.synchronized { - withOutputRedirected(logWriter) { - System.setProperty("java.library.path", logFile.getParentFile.getCanonicalFile.getAbsolutePath) - System.setProperty("scalatest.output", outDir.getCanonicalFile.getAbsolutePath) - System.setProperty("scalatest.lib", LATEST_LIB) - System.setProperty("scalatest.cwd", outDir.getParent) - ObjectRunner.run(classpath, "Test", List("jvm")) - } - } - - /*val out = new FileOutputStream(logFile, true) - Console.withOut(new PrintStream(out)) { - ObjectRunner.run(classpath, "Test", List("jvm")) - } - out.flush - out.close*/ - } catch { - case e: Exception => - NestUI.verbose(e+" ("+file.getPath+")") - e.printStackTrace() - } - } + // def execTestObjectRunner(file: File, outDir: File, logFile: File) { + // val consFM = new ConsoleFileManager + // + // val classpath: List[URL] = { + // import consFM.{ latestCompFile, latestLibFile, latestPartestFile } + // val units = ( + // List(outDir, latestCompFile, latestLibFile, latestPartestFile) ::: + // ((CLASSPATH split File.pathSeparatorChar).toList map (x => new File(x))) + // ) + // units map (_.toURI.toURL) + // } + // + // NestUI.verbose("ObjectRunner classpath: "+classpath) + // + // try { + // // configure input/output files + // val logOut = new FileOutputStream(logFile) + // val logWriter = new PrintStream(logOut) + // + // // grab global lock + // fileManager.synchronized { + // withOutputRedirected(logWriter) { + // System.setProperty("java.library.path", logFile.getParentFile.getCanonicalFile.getAbsolutePath) + // System.setProperty("scalatest.output", outDir.getCanonicalFile.getAbsolutePath) + // System.setProperty("scalatest.lib", LATEST_LIB) + // System.setProperty("scalatest.cwd", outDir.getParent) + // ObjectRunner.run(classpath, "Test", List("jvm")) + // } + // } + // + // /*val out = new FileOutputStream(logFile, true) + // Console.withOut(new PrintStream(out)) { + // ObjectRunner.run(classpath, "Test", List("jvm")) + // } + // out.flush + // out.close*/ + // } catch { + // case e: Exception => + // NestUI.verbose(e+" ("+file.getPath+")") + // e.printStackTrace() + // } + // } def javac(outDir: File, files: List[File], output: File): Boolean = { // compile using command-line javac compiler @@ -412,13 +413,14 @@ class Worker(val fileManager: FileManager) extends Actor { val dir = file.getParentFile //TODO: detect whether we have to use Runtime.exec - val useRuntime = true - - if (useRuntime) - execTest(outDir, logFile, fileBase) - else - execTestObjectRunner(file, outDir, logFile) - // NestUI.verbose(this+" finished running "+fileBase) + // val useRuntime = true + // + // if (useRuntime) + // execTest(outDir, logFile, fileBase) + // else + // execTestObjectRunner(file, outDir, logFile) + // // NestUI.verbose(this+" finished running "+fileBase) + execTest(outDir, logFile, fileBase) diff = compareOutput(dir, fileBase, kind, logFile) if (!diff.equals("")) { @@ -492,10 +494,7 @@ class Worker(val fileManager: FileManager) extends Actor { } }) - case "run" => - runJvmTest(file, kind) - - case "jvm" => + case "run" | "jvm" => runJvmTest(file, kind) case "buildmanager" => @@ -809,12 +808,15 @@ class Worker(val fileManager: FileManager) extends Actor { // -------- run test -------- //TODO: detect whether we have to use Runtime.exec - val useRuntime = true + // val useRuntime = true + // + // if (useRuntime) + // execTest(outDir, logFile, fileBase) + // else + // execTestObjectRunner(file, outDir, logFile) + + execTest(outDir, logFile, fileBase) - if (useRuntime) - execTest(outDir, logFile, fileBase) - else - execTestObjectRunner(file, outDir, logFile) NestUI.verbose(this+" finished running "+fileBase) } // successful compile } catch { // *catch-all* @@ -892,7 +894,6 @@ class Worker(val fileManager: FileManager) extends Actor { } case "script" => { - val osName = System.getProperty("os.name", "") // when option "--failed" is provided // execute test only if log file is present // (which means it failed before) diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index d814fc4fc7..9337d78ef4 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -4,9 +4,35 @@ package scala.tools +import nsc.io.{ Directory } +import util.{ PathResolver } +import nsc.Properties.{ propOrElse, propOrNone, propOrEmpty } + package object partest { import nest.NestUI + object PartestDefaults { + import nsc.Properties._ + private def wrapAccessControl[T](body: => Option[T]): Option[T] = + try body catch { case _: java.security.AccessControlException => None } + + def prefixDir = Directory.Current map (_.normalize.toDirectory) + def srcDirName = propOrElse("partest.srcdir", "files") + def classPath = PathResolver.Environment.javaUserClassPath // XXX + + def javaCmd = propOrElse("scalatest.javacmd", "java") + def javacCmd = propOrElse("scalatest.javac_cmd", "javac") + def javaOpts = propOrElse("scalatest.java_opts", "") + def scalacOpts = propOrElse("scalatest.scalac_opts", "-deprecation") + + def testBuild = propOrNone("scalatest.build") + def errorCount = propOrElse("scalatest.errors", "0").toInt + def numActors = propOrElse("scalatest.actors", "8").toInt + def poolSize = wrapAccessControl(propOrNone("actors.corePoolSize")) + + def timeout = "1200000" + } + def vmArgString = { import scala.tools.nsc.io.Process @@ -24,8 +50,5 @@ package object partest { NestUI.verbose(allPropertiesString) } - def isPartestDebug = { - (System.getProperty("partest.debug") == "true") || - (System.getProperty("scalatest.debug") == "true") - } + def isPartestDebug = List("partest.debug", "scalatest.debug") map propOrEmpty contains "true" }
\ No newline at end of file diff --git a/src/scalap/scala/tools/scalap/Properties.scala b/src/scalap/scala/tools/scalap/Properties.scala index 72a4513b8b..315b81cb3e 100644 --- a/src/scalap/scala/tools/scalap/Properties.scala +++ b/src/scalap/scala/tools/scalap/Properties.scala @@ -14,5 +14,4 @@ object Properties extends scala.util.PropertiesTrait { protected def propCategory = "decoder" protected def pickJarBasedOn = classOf[Classfile] - def cmdName = scala.tools.nsc.Properties.cmdName } diff --git a/src/swing/scala/swing/SimpleGUIApplication.scala b/src/swing/scala/swing/SimpleGUIApplication.scala index c09fdfb246..79eb3cd2b4 100644 --- a/src/swing/scala/swing/SimpleGUIApplication.scala +++ b/src/swing/scala/swing/SimpleGUIApplication.scala @@ -44,5 +44,5 @@ import javax.swing._ this.getClass.getResource(path) def resourceFromUserDirectory(path: String): java.io.File = - new java.io.File(System.getProperty("user.dir"), path) + new java.io.File(util.Properties.userDir, path) } diff --git a/src/swing/scala/swing/SimpleSwingApplication.scala b/src/swing/scala/swing/SimpleSwingApplication.scala index 9f66cc5be5..6a4d7e8775 100644 --- a/src/swing/scala/swing/SimpleSwingApplication.scala +++ b/src/swing/scala/swing/SimpleSwingApplication.scala @@ -13,5 +13,5 @@ abstract class SimpleSwingApplication extends SwingApplication { this.getClass.getResource(path) def resourceFromUserDirectory(path: String): java.io.File = - new java.io.File(System.getProperty("user.dir"), path) + new java.io.File(util.Properties.userDir, path) } diff --git a/src/swing/scala/swing/test/SimpleApplet.scala b/src/swing/scala/swing/test/SimpleApplet.scala index 090f4cde8d..d5f17f8a40 100644 --- a/src/swing/scala/swing/test/SimpleApplet.scala +++ b/src/swing/scala/swing/test/SimpleApplet.scala @@ -7,8 +7,7 @@ class SimpleApplet extends Applet { object ui extends UI with Reactor { def init() = { val button = new Button("Press here!") - val text = new TextArea("Java Version: " + - System.getProperty("java.version")+"\n") + val text = new TextArea("Java Version: " + util.Properties.javaVersion + "\n") listenTo(button) reactions += { case ButtonClicked(_) => text.text += "Button Pressed!\n" |