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