Skip to content

Commit 994ed5a

Browse files
committed
Use parent class loader in runner
1 parent 2cc3070 commit 994ed5a

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ object MainGenericRunner {
193193

194194
case ExecuteMode.PossibleRun =>
195195
val newClasspath = (settings.classPath :+ ".").flatMap(_.split(classpathSeparator).filter(_.nonEmpty)).map(File(_).toURI.toURL)
196-
import dotty.tools.runner.RichClassLoader._
197-
val newClassLoader = ScalaClassLoader.fromURLsParallelCapable(newClasspath)
196+
import dotty.tools.runner.RichClassLoader.{getClass as _, *}
197+
val newClassLoader = ScalaClassLoader.fromURLsParallelCapable(newClasspath, getClass.getClassLoader)
198198
val targetToRun = settings.possibleEntryPaths.to(LazyList).find { entryPath =>
199199
newClassLoader.tryToLoadClass(entryPath).orElse {
200200
Option.when(Jar.isJarOrZip(dotty.tools.io.Path(entryPath)))(Jar(entryPath).mainClass).flatten

tests/run-with-compiler/i14541.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
hello raw world
2+
hello rawr world
23
hello run world

tests/run-with-compiler/i14541.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ object Test:
55
val classpath = dotty.tools.dotc.util.ClasspathFromClassloader(getClass.getClassLoader)
66
def main(args: Array[String]): Unit =
77
getClass.getClassLoader.run("echo", List("hello", "raw", "world"))
8+
getClass.getClassLoader.run("dotty.tools.MainGenericRunner", List("echo", "hello", "rawr", "world"))
89
// caution: uses "SCALA_OPTS"
910
dotty.tools.MainGenericRunner.main(Array("--class-path", classpath, "echo", "hello", "run", "world"))
1011

0 commit comments

Comments
 (0)