-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10253 from som-snytt/issue/12705-repl-reflective-…
…class-load Avoid name check when loading repl products
- Loading branch information
Showing
3 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
scala> case class Person(name: String) | ||
class Person | ||
|
||
scala> $intp.classLoader.getResource("Person.class") | ||
val res0: java.net.URL = memory:(memory)/Person.class | ||
|
||
scala> $intp.classLoader.loadClass("Person") | ||
val res1: Class[_] = class Person | ||
|
||
scala> :quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
import scala.tools.partest.ReplTest | ||
|
||
object Test extends ReplTest { | ||
def code = | ||
"""|case class Person(name: String) | ||
|$intp.classLoader.getResource("Person.class") | ||
|$intp.classLoader.loadClass("Person")""".stripMargin | ||
//|classOf[Person].getClassLoader.loadClass("Person")""".stripMargin | ||
} | ||
|
||
/* | ||
java.lang.NoClassDefFoundError: Person (wrong name: Person) | ||
at java.base/java.lang.ClassLoader.defineClass1(Native Method) | ||
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013) | ||
at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:77) | ||
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) | ||
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) | ||
... 76 elided | ||
*/ |