Attacked classpaths to get "." off of it when it's not actually
specified. The commit makes me nervous, but there's no invisible way to fix something like this. ** Attention, this commit changes classpath handling ** We desperately need some way of testing that the classpath has certain qualities and does not have others; partest is not that way. Closes SI-4857, no review. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25452 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
db704c4865
commit
ed090c3b42
|
@ -154,7 +154,7 @@ fi
|
|||
$JAVA_OPTS \
|
||||
"${java_args[@@]}" \
|
||||
${CPSELECT}${TOOL_CLASSPATH} \
|
||||
-Dscala.usejavacp=true \
|
||||
-Dscala.usejavacp=false \
|
||||
-Dscala.home="$SCALA_HOME" \
|
||||
-Denv.emacs="$EMACS" \
|
||||
$CYGWIN_JLINE_TERMINAL \
|
||||
|
|
|
@ -35,7 +35,10 @@ extends CompilerCommand(args, settings) {
|
|||
else {
|
||||
val f = io.File(target)
|
||||
if (!f.hasExtension("class", "jar", "zip") && f.canRead) AsScript
|
||||
else sys.error("Cannot figure out how to run target: " + target)
|
||||
else {
|
||||
Console.err.println("No such file or class on classpath: " + target)
|
||||
Error
|
||||
}
|
||||
}
|
||||
}
|
||||
/** String with either the jar file, class name, or script file name. */
|
||||
|
|
|
@ -25,7 +25,7 @@ class MainGenericRunner {
|
|||
false
|
||||
}
|
||||
def errorFn(str: String): Boolean = {
|
||||
Console println str
|
||||
Console.err println str
|
||||
false
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,8 @@ class MainGenericRunner {
|
|||
new io.Jar(thingToRun).mainClass getOrElse sys.error("Cannot find main class for jar: " + thingToRun),
|
||||
command.arguments
|
||||
)
|
||||
case Error =>
|
||||
Right(false)
|
||||
case _ =>
|
||||
// We start the repl when no arguments are given.
|
||||
Right(new ILoop process settings)
|
||||
|
|
|
@ -17,11 +17,19 @@ trait ScalaSettings extends AbsScalaSettings
|
|||
with Warnings {
|
||||
self: MutableSettings =>
|
||||
|
||||
import Defaults.scalaUserClassPath
|
||||
|
||||
/** Set of settings */
|
||||
protected lazy val allSettings = mutable.HashSet[Setting]()
|
||||
|
||||
/** Against my better judgment, giving in to martin here and allowing
|
||||
* CLASSPATH to be used automatically. So for the user-specified part
|
||||
* of the classpath:
|
||||
*
|
||||
* - If -classpath or -cp is given, it is that
|
||||
* - Otherwise, if CLASSPATH is set, it is that
|
||||
* - If neither of those, then "." is used.
|
||||
*/
|
||||
protected def defaultClasspath = Option(sys.props("CLASSPATH")) getOrElse "."
|
||||
|
||||
/** Disable a setting */
|
||||
def disable(s: Setting) = allSettings -= s
|
||||
|
||||
|
@ -35,7 +43,7 @@ trait ScalaSettings extends AbsScalaSettings
|
|||
*/
|
||||
// argfiles is only for the help message
|
||||
val argfiles = BooleanSetting ("@<file>", "A text file containing compiler arguments (options and source files)")
|
||||
val classpath = PathSetting ("-classpath", "Specify where to find user class files.", scalaUserClassPath) .
|
||||
val classpath = PathSetting ("-classpath", "Specify where to find user class files.", defaultClasspath) .
|
||||
withAbbreviation ("-cp")
|
||||
val d = OutputSetting (outputDirs, ".")
|
||||
val optimise = BooleanSetting ("-optimise", "Generates faster bytecode by applying optimisations to the program") .
|
||||
|
|
|
@ -74,13 +74,7 @@ object PathResolver {
|
|||
* to the path resolution specification.
|
||||
*/
|
||||
object Defaults {
|
||||
/* Against my better judgment, giving in to martin here and allowing
|
||||
* CLASSPATH as the default if no -cp is given. Only if there is no
|
||||
* command line option or environment variable is "." used.
|
||||
*/
|
||||
def scalaUserClassPath = firstNonEmpty(Environment.classPathEnv, ".")
|
||||
def scalaSourcePath = Environment.sourcePathEnv
|
||||
|
||||
def javaBootClassPath = Environment.javaBootClassPath
|
||||
def javaUserClassPath = Environment.javaUserClassPath
|
||||
def javaExtDirs = Environment.javaExtDirs
|
||||
|
@ -195,9 +189,25 @@ class PathResolver(settings: Settings, context: JavaContext) {
|
|||
def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else ""
|
||||
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
|
||||
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
|
||||
def userClassPath = cmdLineOrElse("classpath", Defaults.scalaUserClassPath)
|
||||
def sourcePath = cmdLineOrElse("sourcepath", Defaults.scalaSourcePath)
|
||||
|
||||
/** Against my better judgment, giving in to martin here and allowing
|
||||
* CLASSPATH to be used automatically. So for the user-specified part
|
||||
* of the classpath:
|
||||
*
|
||||
* - If -classpath or -cp is given, it is that
|
||||
* - Otherwise, if CLASSPATH is set, it is that
|
||||
* - If neither of those, then "." is used.
|
||||
*/
|
||||
def userClassPath = (
|
||||
if (!settings.classpath.isDefault)
|
||||
settings.classpath.value
|
||||
else sys.props("CLASSPATH") match {
|
||||
case null => "."
|
||||
case cp => cp
|
||||
}
|
||||
)
|
||||
|
||||
import context._
|
||||
|
||||
// Assemble the elements!
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
-Ylog-classpath
|
|
@ -0,0 +1,3 @@
|
|||
package foo {
|
||||
class Bippy
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
class A {
|
||||
def f = new foo.Bippy
|
||||
}
|
Loading…
Reference in New Issue