diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-23 04:17:59 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-23 04:17:59 +0000 |
commit | ae8c065594aa605734b66c11693e5e584feaeddd (patch) | |
tree | 3c93cdc9a3d25ce9260bc7e7322b4f41c0c6e8d2 /src | |
parent | 88aab1cf8e06f98ccd18437974c09162ee54149f (diff) | |
download | scala-ae8c065594aa605734b66c11693e5e584feaeddd.tar.gz scala-ae8c065594aa605734b66c11693e5e584feaeddd.tar.bz2 scala-ae8c065594aa605734b66c11693e5e584feaeddd.zip |
Went ahead and implemented classpaths as descri...
Went ahead and implemented classpaths as described in email to
scala-internals on the theory that at this point I must know what I'm
doing.
** PUBLIC SERVICE ANNOUNCEMENT **
If your code of whatever kind stopped working with this commit (most
likely the error is something like "object scala not found") you can get
it working again with either of:
passing -usejavacp on the command line
set system property "scala.usejavacp" to "true"
Either of these will alert scala that you want the java application
classpath to be utilized by scala as well.
Review by community.
Diffstat (limited to 'src')
9 files changed, 17 insertions, 35 deletions
diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index 1e5d3c2b66..5b64369a2f 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -71,10 +71,7 @@ class ScalacFork extends MatchingTask with ScalacShared with TaskArgs { settings.d = destinationDir compTarget foreach (settings.target = _) - compilationPath foreach { x => - settings.classpath = x - settings.javaignorecp = true // ensures java classpath will not be used - } + compilationPath foreach (settings.classpath = _) sourcePath foreach (settings.sourcepath = _) params foreach (settings.more = _) diff --git a/src/compiler/scala/tools/ant/sabbus/Settings.scala b/src/compiler/scala/tools/ant/sabbus/Settings.scala index 45c1b20052..2719196095 100644 --- a/src/compiler/scala/tools/ant/sabbus/Settings.scala +++ b/src/compiler/scala/tools/ant/sabbus/Settings.scala @@ -64,12 +64,9 @@ class Settings { def more = moreBf.get def more_=(s: String): this.type = { moreBf = Some(s); this } - var javaignorecp: Boolean = false - def toArgs: List[String] = (if (!gBf.isEmpty) "-g:"+g :: Nil else Nil) ::: (if (uncheckedBf) "-unchecked" :: Nil else Nil) ::: - (if (javaignorecp) "-javaignorecp" :: Nil else Nil) ::: (if (!classpathBf.isEmpty) "-classpath" :: classpath.toString :: Nil else Nil) ::: (if (!sourcepathBf.isEmpty) "-sourcepath" :: sourcepath.toString :: Nil else Nil) ::: (if (!sourcedirBf.isEmpty) "-Xsourcedir" :: sourcedir.toString :: Nil else Nil) ::: diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index 3ce5e43af9..44ab9c6062 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -184,10 +184,8 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal val prepend = new StringSetting(name + "/p", "", "", "") with InternalSetting val append = new StringSetting(name + "/a", "", "", "") with InternalSetting - /** Not flipping this part on just yet. add[StringSetting](prepend) add[StringSetting](append) - */ add(new PathSetting(name, arg, descr, default, prepend, append)) } diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 0de60672ac..84ede32504 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -30,6 +30,7 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings { * Temporary Settings */ val suppressVTWarn = BooleanSetting ("-Ysuppress-vt-typer-warnings", "Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!") + val javaignorecp = BooleanSetting ("-javaignorecp", "Does nothing - is being removed.") // !!! marked for death, but need new starr. /** * Standard settings diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala index 74e69b82e6..12ae5c9d0e 100644 --- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala @@ -17,7 +17,6 @@ trait StandardScalaSettings { self: AbsScalaSettings => /** Path related settings. - * !!! javaignorecp is temporary while I try to get an iron grip on the classpath. */ val bootclasspath = PathSetting ("-bootclasspath", "path", "Override location of bootstrap class files", Defaults.scalaBootClassPath) val classpath: PathSetting // is mutated directly in various places (thus inspiring this very effort) @@ -25,7 +24,6 @@ trait StandardScalaSettings { val extdirs = PathSetting ("-extdirs", "dirs", "Override location of installed extensions", Defaults.scalaExtDirs) val javabootclasspath = PathSetting ("-javabootclasspath", "path", "Override java boot classpath.", Defaults.javaBootClassPath) val javaextdirs = PathSetting ("-javaextdirs", "path", "Override java extdirs classpath.", Defaults.javaExtDirs) - val javaignorecp = BooleanSetting ("-javaignorecp", "scala will not use java's -classpath no matter what.") val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", "") /** Other settings. @@ -44,6 +42,7 @@ trait StandardScalaSettings { val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "msil"), "jvm-1.5") val unchecked = BooleanSetting ("-unchecked", "Enable detailed unchecked warnings") val uniqid = BooleanSetting ("-uniqid", "Print identifiers with unique names for debugging") + val usejavacp = BooleanSetting ("-usejavacp", "Utilize the java.class.path in classpath resolution.") val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing") val version = BooleanSetting ("-version", "Print product version and exit") diff --git a/src/compiler/scala/tools/util/ClassPathSettings.scala b/src/compiler/scala/tools/util/ClassPathSettings.scala index bb838f1e66..ec2e1c3c5a 100644 --- a/src/compiler/scala/tools/util/ClassPathSettings.scala +++ b/src/compiler/scala/tools/util/ClassPathSettings.scala @@ -8,10 +8,7 @@ package util trait ClassPathSettings { def javabootclasspath: String // -javabootclasspath - def javabootPrepend: String // -javabootclasspath/p - def javabootAppend: String // -javabootclasspath/a def javaextdirs: String // -javaextdirs - def bootclasspath: String // -bootclasspath def extdirs: String // -extdirs def classpath: String // -classpath diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 58ac3bfa56..3f5b7c4d62 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -48,29 +48,20 @@ object PathResolver { File(url.getFile).parent.path } getOrElse "" - def classPathEnv = envOrElse("CLASSPATH", "") - def sourcePathEnv = envOrElse("SOURCEPATH", "") // not used - def scalaHomeEnv = envOrElse("SCALA_HOME", "") // not used + // No environment variables are used. It's for the best. + // + // def classPathEnv = envOrElse("CLASSPATH", "") + // def sourcePathEnv = envOrElse("SOURCEPATH", "") + // def scalaHomeEnv = envOrElse("SCALA_HOME", "") + def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath) def javaExtDirs = propOrEmpty("java.ext.dirs") - def javaUserClassPath = propOrElse("java.class.path", classPathEnv) - def scalaExtDirs = propOrEmpty("scala.ext.dirs") - def scalaHome = propOrEmpty("scala.home") + def scalaExtDirs = propOrEmpty("scala.ext.dirs") - /** I have distilled everyone's classpath hopes and dreams into the - * question of how to resolve this boolean. Right at this moment if I - * do anything but default to true right here, partest chokes. I'm - * steadily reworking all the places partest gets its hands on the - * classpath so eventually I'll be able to remedy that, at which point - * my current plan is to have this default to false unless some - * property or command line option is supplied. This is negotiable, - * but at this point I can say with confidence that less magic and - * less autodetection is more better. - */ - def useJavaClassPath = true - // hypothetically: - // def useJavaClassPath = propIsSet("scala.classpath.guess") + /** The java classpath and whether to use it. */ + def javaUserClassPath = propOrElse("java.class.path", "") + def useJavaClassPath = propOrFalse("scala.usejavacp") override def toString = """ |object Environment { @@ -95,6 +86,7 @@ object PathResolver { def javaBootClassPath = Environment.javaBootClassPath def javaUserClassPath = Environment.javaUserClassPath def javaExtDirs = Environment.javaExtDirs + def useJavaClassPath = Environment.useJavaClassPath def scalaHome = Environment.scalaHome def scalaHomeDir = Directory(scalaHome) @@ -186,13 +178,12 @@ class PathResolver(settings: Settings, context: JavaContext) { case "sourcepath" => settings.sourcepath.value } - private def useJavaClassPath = !settings.javaignorecp.value && Environment.useJavaClassPath - /** Calculated values based on any given command line options, falling back on * those in Defaults. */ object Calculated { def scalaHome = Defaults.scalaHome + def useJavaClassPath = settings.usejavacp.value || Defaults.useJavaClassPath def javaBootClassPath = cmdLineOrElse("javabootclasspath", Defaults.javaBootClassPath) def javaExtDirs = cmdLineOrElse("javaextdirs", Defaults.javaExtDirs) def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else "" diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index f6746a8e3c..b030d14622 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -40,6 +40,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler { def newSettings(out: Option[String]) = { val settings = new TestSettings(fileManager) + settings.usejavacp.value = true settings.deprecation.value = true settings.nowarnings.value = false settings.encoding.value = "ISO-8859-1" // XXX why? diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala index 992ceba99f..213123f711 100644 --- a/src/partest/scala/tools/partest/nest/Worker.scala +++ b/src/partest/scala/tools/partest/nest/Worker.scala @@ -257,6 +257,7 @@ class Worker(val fileManager: FileManager) extends Actor { "-classpath " + join(outDir.toString, CLASSPATH) ) ::: propertyOptions ::: List( "scala.tools.nsc.MainGenericRunner", + "-usejavacp", "Test", "jvm" ) |