Do not add current directory to "kotlin" classpath
As "java" does, do not include the current directory to the classpath if the explicit classpath is specified. This is more stable than always adding the current directory, and users can easily add the ".:" to the beginning of the explicit classpath themselves #KT-17100 Fixed
This commit is contained in:
@@ -40,8 +40,6 @@ object Main {
|
||||
val arguments = arrayListOf<String>()
|
||||
var noReflect = false
|
||||
|
||||
classpath.addPaths(".")
|
||||
|
||||
var i = 0
|
||||
while (i < args.size) {
|
||||
val arg = args[i]
|
||||
@@ -65,7 +63,9 @@ object Main {
|
||||
printVersionAndExit()
|
||||
}
|
||||
else if ("-classpath" == arg || "-cp" == arg) {
|
||||
classpath.addPaths(next())
|
||||
for (path in next().split(File.pathSeparator).filter(String::isNotEmpty)) {
|
||||
classpath.addPath(path)
|
||||
}
|
||||
}
|
||||
else if ("-expression" == arg || "-e" == arg) {
|
||||
runner = ExpressionRunner(next())
|
||||
@@ -92,10 +92,14 @@ object Main {
|
||||
i++
|
||||
}
|
||||
|
||||
classpath.addPaths(KOTLIN_HOME.toString() + "/lib/kotlin-runtime.jar")
|
||||
if (classpath.isEmpty()) {
|
||||
classpath.addPath(".")
|
||||
}
|
||||
|
||||
classpath.addPath(KOTLIN_HOME.toString() + "/lib/kotlin-runtime.jar")
|
||||
|
||||
if (!noReflect) {
|
||||
classpath.addPaths(KOTLIN_HOME.toString() + "/lib/kotlin-reflect.jar")
|
||||
classpath.addPath(KOTLIN_HOME.toString() + "/lib/kotlin-reflect.jar")
|
||||
}
|
||||
|
||||
if (runner == null) {
|
||||
@@ -105,10 +109,8 @@ object Main {
|
||||
runner.run(classpath, arguments)
|
||||
}
|
||||
|
||||
private fun MutableList<URL>.addPaths(paths: String) {
|
||||
for (path in paths.split(File.pathSeparator)) {
|
||||
add(File(path).absoluteFile.toURI().toURL())
|
||||
}
|
||||
private fun MutableList<URL>.addPath(path: String) {
|
||||
add(File(path).absoluteFile.toURI().toURL())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
Reference in New Issue
Block a user