@@ -27,7 +27,7 @@ import scala.reflect.internal.util.ScalaClassLoader.URLClassLoader
2727import scala .tools .nsc .io .{AbstractFile , VirtualDirectory }
2828import scala .tools .nsc .reporters ._
2929import scala .tools .nsc .{Global , Settings }
30- import scala .util .Try
30+ import scala .util .{ Failure , Success , Try }
3131import scala .util .control .NonFatal
3232
3333class Evaluator [F [_]: Sync ](timeout : FiniteDuration = 20 .seconds)(
@@ -463,14 +463,21 @@ class ${className} extends (() => Any) with java.io.Serializable {
463463 val currentClassPath = classPath.head
464464
465465 // if there's just one thing in the classpath, and it's a jar, assume an executable jar.
466- currentClassPath ::: (if (currentClassPath.size == 1 && currentClassPath( 0 )
466+ currentClassPath ::: (if (currentClassPath.size == 1 && currentClassPath.head
467467 .endsWith(" .jar" )) {
468- val jarFile = currentClassPath( 0 )
468+ val jarFile = currentClassPath.head
469469 val relativeRoot =
470- new File (jarFile).getParentFile()
471- val nestedClassPath =
472- new JarFile (jarFile).getManifest.getMainAttributes
473- .getValue(" Class-Path" )
470+ new File (jarFile).getParentFile
471+ val nestedClassPath = Try {
472+ val jar = new JarFile (jarFile)
473+ val CP = jar.getManifest.getMainAttributes.getValue(" Class-Path" )
474+ jar.close()
475+ CP
476+ } match {
477+ case Success (classPath) => classPath
478+ case Failure (throwable) =>
479+ throw new CompilerException (List (List (throwable.getMessage)))
480+ }
474481 if (nestedClassPath eq null ) {
475482 Nil
476483 } else {
0 commit comments