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

Scala Interpreter classloader - getResources() returns empty collection. #8843

Closed
scabug opened this issue Sep 12, 2014 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Sep 12, 2014

Interpreter's classloader returns empty enumeration when requested using getResources (same code executed as application returns single entry)

  import collection.JavaConverters._
  class MyClass
  val cl = classOf[MyClass].getClassLoader
  val resName = classOf[MyClass].getName.replace(".","/")+".class"

  println(s"getResource: ${cl.getResource(resName)}")
  println(s"getResourceAsStream: ${cl.getResourceAsStream(resName)}")
  println(s"getResources: ${cl.getResources(resName).asScala.mkString}")
@scabug
Copy link
Author

scabug commented Sep 12, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8843?orig=1
Reporter: Marcin Kielar (zorba128)
Affected Versions: 2.11.2
See #6026

@scabug
Copy link
Author

scabug commented Sep 12, 2014

@som-snytt said:
For those who can't remember which java "replace" method takes a regex:

scala> class X
defined class X

scala> classOf[X].getClassLoader getResource classOf[X].getName.replace(".","/")+".class"
res0: java.net.URL = repldir:(memory)/X.class

scala> classOf[X].getClassLoader getResources classOf[X].getName.replace(".","/")+".class"
res1: java.util.Enumeration[java.net.URL] = sun.misc.CompoundEnumeration@73a8dfcc

scala> .hasMoreElements
res2: Boolean = false

@scabug
Copy link
Author

scabug commented Oct 5, 2014

@som-snytt said:
scala/scala#4030

@scabug scabug closed this as completed Oct 7, 2014
@scabug scabug added the repl label Apr 7, 2017
@scabug scabug added this to the 2.11.3 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants