Permalink
Browse files

Bypass determination of protection domain when resource is not in a jar

  • Loading branch information...
1 parent 426cec5 commit 6ec6f69be2863056c1f10c56406e5a72f2e184cb @rjolly rjolly committed Mar 22, 2013
@@ -8,7 +8,6 @@ package util
import scala.tools.nsc.io.AbstractFile
import java.security.cert.Certificate
import java.security.{ ProtectionDomain, CodeSource }
-import util.ScalaClassLoader
import java.net.{ URL, URLConnection, URLStreamHandler }
import scala.collection.{ mutable, immutable }
@@ -91,10 +90,13 @@ class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader)
lazy val protectionDomain = {
val cl = Thread.currentThread().getContextClassLoader()
val resource = cl.getResource("scala/runtime/package.class")
- if (resource == null) null else {
+ if (resource == null || resource.getProtocol != "jar") null else {
val s = resource.getPath
- val path = s.substring(0, s.lastIndexOf('!'))
- new ProtectionDomain(new CodeSource(new URL(path), null.asInstanceOf[Array[Certificate]]), null, this, null)
+ val n = s.lastIndexOf('!')
+ if (n < 0) null else {
+ val path = s.substring(0, n)
+ new ProtectionDomain(new CodeSource(new URL(path), null.asInstanceOf[Array[Certificate]]), null, this, null)
+ }
}
}
@@ -259,7 +259,11 @@ final class ManifestResources(val url: URL) extends ZipArchive(null) {
}
def name = path
- def path: String = url.getPath() match { case s => s.substring(0, s.lastIndexOf('!')) }
+ def path: String = {
+ val s = url.getPath
+ val n = s.lastIndexOf('!')
+ s.substring(0, n)
+ }
def input = url.openStream()
def lastModified =
try url.openConnection().getLastModified()

0 comments on commit 6ec6f69

Please sign in to comment.