diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala index a2994966fd..f09787ec4f 100644 --- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala +++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala @@ -46,8 +46,8 @@ trait ScalaClassLoader extends JClassLoader { def create(path: String): AnyRef = tryToInitializeClass[AnyRef](path) map (_.newInstance()) orNull - def constructorsOf[T <: AnyRef : ClassTag]: List[Constructor[T]] = - classTag[T].runtimeClass.getConstructors.toList map (_.asInstanceOf[Constructor[T]]) + // def constructorsOf[T <: AnyRef : ClassTag]: List[Constructor[T]] = + // classTag[T].runtimeClass.getConstructors.toList map (_.asInstanceOf[Constructor[T]]) /** The actual bytes for a class file, or an empty array if it can't be found. */ def classBytes(className: String): Array[Byte] = classAsStream(className) match { @@ -75,10 +75,10 @@ trait ScalaClassLoader extends JClassLoader { /** A list comprised of this classloader followed by all its * (non-null) parent classloaders, if any. */ - def loaderChain: List[ScalaClassLoader] = this :: (getParent match { - case null => Nil - case p => p.loaderChain - }) + // def loaderChain: List[ScalaClassLoader] = this :: (getParent match { + // case null => Nil + // case p => p.loaderChain + // }) } /** Methods for obtaining various classloaders. @@ -99,35 +99,35 @@ object ScalaClassLoader { } def contextLoader = apply(Thread.currentThread.getContextClassLoader) def appLoader = apply(JClassLoader.getSystemClassLoader) - def extLoader = apply(appLoader.getParent) - def bootLoader = apply(null) - def contextChain = loaderChain(contextLoader) + // def extLoader = apply(appLoader.getParent) + // def bootLoader = apply(null) + // def contextChain = loaderChain(contextLoader) - def pathToErasure[T: ClassTag] = pathToClass(classTag[T].runtimeClass) - def pathToClass(clazz: Class[_]) = clazz.getName.replace('.', JFile.separatorChar) + ".class" - def locate[T: ClassTag] = contextLoader getResource pathToErasure[T] + // def pathToErasure[T: ClassTag] = pathToClass(classTag[T].runtimeClass) + // def pathToClass(clazz: Class[_]) = clazz.getName.replace('.', JFile.separatorChar) + ".class" + // def locate[T: ClassTag] = contextLoader getResource pathToErasure[T] /** Tries to guess the classpath by type matching the context classloader * and its parents, looking for any classloaders which will reveal their * classpath elements as urls. It it can't find any, creates a classpath * from the supplied string. */ - def guessClassPathString(default: String = ""): String = { - val classpathURLs = contextChain flatMap { - case x: HasClassPath => x.classPathURLs - case x: JURLClassLoader => x.getURLs.toSeq - case _ => Nil - } - if (classpathURLs.isEmpty) default - else JavaClassPath.fromURLs(classpathURLs).asClasspathString - } - - def loaderChain(head: JClassLoader) = { - def loop(cl: JClassLoader): List[JClassLoader] = - if (cl == null) Nil else cl :: loop(cl.getParent) - - loop(head) - } + // def guessClassPathString(default: String = ""): String = { + // val classpathURLs = contextChain flatMap { + // case x: HasClassPath => x.classPathURLs + // case x: JURLClassLoader => x.getURLs.toSeq + // case _ => Nil + // } + // if (classpathURLs.isEmpty) default + // else JavaClassPath.fromURLs(classpathURLs).asClasspathString + // } + + // def loaderChain(head: JClassLoader) = { + // def loop(cl: JClassLoader): List[JClassLoader] = + // if (cl == null) Nil else cl :: loop(cl.getParent) + + // loop(head) + // } def setContext(cl: JClassLoader) = Thread.currentThread.setContextClassLoader(cl) def savingContextLoader[T](body: => T): T = { @@ -143,14 +143,14 @@ object ScalaClassLoader { private var classloaderURLs: Seq[URL] = urls def classPathURLs: Seq[URL] = classloaderURLs - def classPath: ClassPath[_] = JavaClassPath fromURLs classPathURLs + // def classPath: ClassPath[_] = JavaClassPath fromURLs classPathURLs /** Override to widen to public */ override def addURL(url: URL) = { classloaderURLs :+= url super.addURL(url) } - def toLongString = urls.mkString("URLClassLoader(\n ", "\n ", "\n)\n") + // def toLongString = urls.mkString("URLClassLoader(\n ", "\n ", "\n)\n") } def fromURLs(urls: Seq[URL], parent: ClassLoader = null): URLClassLoader = @@ -161,7 +161,7 @@ object ScalaClassLoader { fromURLs(urls) tryToLoadClass name isDefined /** Finding what jar a clazz or instance came from */ - def origin(x: Any): Option[URL] = originOfClass(x.getClass) + // def origin(x: Any): Option[URL] = originOfClass(x.getClass) def originOfClass(x: Class[_]): Option[URL] = Option(x.getProtectionDomain.getCodeSource) flatMap (x => Option(x.getLocation)) } |