@@ -514,9 +514,8 @@ class ReplDriver(settings: Array[String],
514
514
}
515
515
516
516
case Require (path) =>
517
- val f = new JFile (path)
518
517
val jarFile = AbstractFile .getDirectory(path)
519
- if (! f.exists || jarFile == null )
518
+ if (jarFile == null )
520
519
out.println(s """ Cannot add " $path" to classpath. """ )
521
520
state
522
521
else
@@ -542,15 +541,17 @@ class ReplDriver(settings: Array[String],
542
541
543
542
val existingClass = entries.filter(_.ext.isClass).find(tryClassLoad(_).isDefined)
544
543
if (existingClass.nonEmpty)
545
- out.println(s " The path ' $f ' cannot be loaded, it contains a classfile that already exists on the classpath: ${existingClass.get}" )
544
+ out.println(s " The path ' $path ' cannot be loaded, it contains a classfile that already exists on the classpath: ${existingClass.get}" )
546
545
state
547
546
else
548
- val cp = state.context.platform.classPath(using state.context).asClassPathString
549
- val newCP = s " $cp ${JFile .pathSeparator}$path"
547
+ val prevClassPath = state.context.platform.classPath(using state.context).asClassPathString
548
+ val newClassPath = s " $prevClassPath ${JFile .pathSeparator}$path"
550
549
551
550
// add to compiler class path
552
551
val prevOutputDir = rootCtx.settings.outputDir.valueIn(rootCtx.settingsState)
553
- val ctxToUse = initCtx.fresh.setSetting(rootCtx.settings.classpath, newCP)
552
+ val ctxToUse = initCtx.fresh
553
+ .setSetting(rootCtx.settings.classpath, newClassPath)
554
+ .setSetting(rootCtx.settings.outputDir, prevOutputDir) // reuse virtual output directory
554
555
rootCtx = setupRootCtx(
555
556
Array (),
556
557
ctxToUse,
@@ -562,10 +563,11 @@ class ReplDriver(settings: Array[String],
562
563
val prevClassLoader = rendering.classLoader()(using state.context)
563
564
val jarClassLoader = fromURLsParallelCapable(
564
565
ClassPathFactory .newClassPath(jarFile)(using rootCtx).asURLs, prevClassLoader)
565
- val replOutputClassLoader = new AbstractFileClassLoader (
566
- prevOutputDir, jarClassLoader)
566
+ // val replOutputClassLoader = new AbstractFileClassLoader(
567
+ // prevOutputDir, jarClassLoader)
567
568
rendering.myClassLoader = new AbstractFileClassLoader (
568
- rootCtx.settings.outputDir.valueIn(rootCtx.settingsState), replOutputClassLoader)
569
+ rootCtx.settings.outputDir.valueIn(rootCtx.settingsState), jarClassLoader) // replOutputClassLoader)
570
+ println(s " new classpath: ${s.context.platform.classPath(using s.context)}" )
569
571
out.println(s " Added ' $path' to classpath. " )
570
572
s
571
573
0 commit comments