Skip to content
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

provide isolated child classloader to address issue: #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

.project
.settings/
.classpath
bin/

Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ object ScalaTestLauncher {
try {
val cpFilePath = args(0)
val classpath = Source.fromFile(args(0)).getLines()
val loader = ClassLoader.getSystemClassLoader
val method= classOf[URLClassLoader].getDeclaredMethod("addURL", classOf[URL]); //$NON-NLS-1$
method.setAccessible(true);
classpath.foreach(cp => method.invoke(loader, new File(cp.toString).toURI.toURL))

val runnerClass = Class.forName("org.scalatest.tools.Runner")

val urls = classpath.map { cp => new File(cp.toString).toURI.toURL }.toArray
val loader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader)

Thread.currentThread().setContextClassLoader(loader)
val runnerClass = loader.loadClass("org.scalatest.tools.Runner")
val mainMethod = runnerClass.getMethod("main", args.getClass()) //$NON-NLS-1$
mainMethod.setAccessible(true)
mainMethod.invoke(null, Source.fromFile(args(1)).getLines().toArray)
Expand Down