Skip to content

Commit a138664

Browse files
authored
Update AbstractFileClassLoader.scala
1 parent c65bf69 commit a138664

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

repl/src/dotty/tools/repl/AbstractFileClassLoader.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader, inter
6868
val loaded = findLoadedClass(name) // Check if already loaded
6969
if loaded != null then return loaded
7070

71-
name match { // Don't instrument JDK classes or StopRepl
71+
name match {
72+
// Don't instrument JDK classes or StopRepl. These are often restricted to load from a single classloader
73+
// due to the JDK module system, and so instrumenting them and loading the modified copy of the class
74+
// results in runtime exceptions
7275
case s"java.$_" => super.loadClass(name)
7376
case s"javax.$_" => super.loadClass(name)
7477
case s"sun.$_" => super.loadClass(name)
7578
case s"jdk.$_" => super.loadClass(name)
7679
case s"org.xml.sax.$_" => super.loadClass(name) // XML SAX API (part of java.xml module)
7780
case s"org.w3c.dom.$_" => super.loadClass(name) // W3C DOM API (part of java.xml module)
7881
case s"com.sun.org.apache.$_" => super.loadClass(name) // Internal Xerces implementation
82+
// Don't instrument StopRepl, which would otherwise cause infinite recursion
7983
case "dotty.tools.repl.StopRepl" =>
8084
// Load StopRepl bytecode from parent but ensure each classloader gets its own copy
8185
val classFileName = name.replace('.', '/') + ".class"

0 commit comments

Comments
 (0)