Skip to content

Commit

Permalink
provide isolated child classloader to address issue:
Browse files Browse the repository at this point in the history
aspectj tests are not runnable due to wrong classloader setup #42
Conflicts:
	org.scala-ide.sdt.scalatest/src/scala/tools/eclipse/scalatest/launching/ScalaTestLauncher.scala

Conflicts:
	org.scala-ide.sdt.scalatest/src/scala/tools/eclipse/scalatest/launching/ScalaTestLauncher.scala
  • Loading branch information
Andrei-Pozolotin authored and cheeseng committed Nov 12, 2014
1 parent a5a1727 commit e6d5c5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
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,11 @@ 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)

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 All @@ -67,5 +65,4 @@ object ScalaTestLauncher {
argsFile.delete()
}
}

}
}

0 comments on commit e6d5c5b

Please sign in to comment.