Skip to content

Fix #3279 #3297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions compiler/src/dotty/tools/repl/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ import dotc.core.StdNames.str
* `Rendering` is no longer valid.
*/
private[repl] class Rendering(compiler: ReplCompiler,
private var currentClassLoader: Option[ClassLoader] = None) {
parentClassLoader: Option[ClassLoader] = None) {

private def classLoader()(implicit ctx: Context) =
currentClassLoader.getOrElse {
import java.net.{URL, URLClassLoader}
private[this] var myClassLoader: ClassLoader = _

/** the compiler's classpath, as URL's */
val compilerClasspath: Seq[URL] = ctx.platform.classPath(ctx).asURLs
/** Class loader used to load compiled code */
private[this] def classLoader()(implicit ctx: Context) =
if (myClassLoader != null) myClassLoader
else {
val parent = parentClassLoader.getOrElse {
// the compiler's classpath, as URL's
val compilerClasspath = ctx.platform.classPath(ctx).asURLs
new java.net.URLClassLoader(compilerClasspath.toArray, classOf[ReplDriver].getClassLoader)
}

def parent = new URLClassLoader(compilerClasspath.toArray,
classOf[ReplDriver].getClassLoader)

val newClsLoader = new AbstractFileClassLoader(compiler.directory,
currentClassLoader.getOrElse(parent))

Thread.currentThread.setContextClassLoader(newClsLoader)
currentClassLoader = Some(newClsLoader)
newClsLoader
myClassLoader = new AbstractFileClassLoader(compiler.directory, parent)
// Set the current Java "context" class loader to this rendering class loader
Thread.currentThread.setContextClassLoader(myClassLoader)
myClassLoader
}

/** Load the value of the symbol using reflection
Expand Down
2 changes: 2 additions & 0 deletions sbt-dotty/sbt-test/sbt-dotty/example-project/test
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
> run
> 'set initialCommands := "1 + 1" '
> console