diff options
author | Som Snytt <som.snytt@gmail.com> | 2014-10-04 12:33:11 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2014-10-06 08:00:22 -0700 |
commit | 964a197cd90e561d05c9d725cc13895f18b6a6d0 (patch) | |
tree | 51a80e3c486ad12b6b4f97920c696bdf167d54b4 /test/files/run/t8843-repl-xlat.scala | |
parent | 7b2c3cb8bb0f5f96f3182f551eb82cb1c59d460c (diff) | |
download | scala-964a197cd90e561d05c9d725cc13895f18b6a6d0.tar.gz scala-964a197cd90e561d05c9d725cc13895f18b6a6d0.tar.bz2 scala-964a197cd90e561d05c9d725cc13895f18b6a6d0.zip |
SI-8843 AbsFileCL acts like a CL
Let the AbstractFileClassLoader override just the usual suspects.
Normal delegation behavior should ensue.
That's instead of overriding `getResourceAsStream`, which was intended
that "The repl classloader now works more like you'd expect a classloader to."
(Workaround for "Don't know how to construct an URL for something which exists
only in memory.")
Also override `findResources` so that `getResources` does the obvious thing,
namely, return one iff `getResource` does.
The translating class loader for REPL only special-cases `foo.class`: as
a fallback, take `foo` as `$line42.$read$something$foo` and try that class file.
That's the use case for "works like you'd expect it to."
There was a previous fix to ensure `getResource` doesn't take a class name.
The convenience behavior, that `classBytes` takes either a class name or a resource
path ending in ".class", has been promoted to `ScalaClassLoader`.
Diffstat (limited to 'test/files/run/t8843-repl-xlat.scala')
-rw-r--r-- | test/files/run/t8843-repl-xlat.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/files/run/t8843-repl-xlat.scala b/test/files/run/t8843-repl-xlat.scala new file mode 100644 index 0000000000..6426dbe7d4 --- /dev/null +++ b/test/files/run/t8843-repl-xlat.scala @@ -0,0 +1,33 @@ + +import scala.tools.partest.SessionTest + +// Handy hamburger helper for repl resources +object Test extends SessionTest { + def session = +"""Type in expressions to have them evaluated. +Type :help for more information. + +scala> $intp.isettings.unwrapStrings = false +$intp.isettings.unwrapStrings: Boolean = false + +scala> class Bippy +defined class Bippy + +scala> $intp.classLoader getResource "Bippy.class" +res0: java.net.URL = memory:(memory)/$line4/$read$$iw$$iw$Bippy.class + +scala> ($intp.classLoader getResources "Bippy.class").nextElement +res1: java.net.URL = memory:(memory)/$line4/$read$$iw$$iw$Bippy.class + +scala> ($intp.classLoader classBytes "Bippy").nonEmpty +res2: Boolean = true + +scala> ($intp.classLoader classAsStream "Bippy") != null +res3: Boolean = true + +scala> $intp.classLoader getResource "Bippy" +res4: java.net.URL = null + +scala> :quit""" +} + |