Skip to content

Commit a8ef78c

Browse files
smarterOlivierBlanvillain
authored andcommitted
Get .tasty files from the correct jar
1. If we don't give a parent to the URLClassLoader constructor, it will use the system ClassLoader by default, which includes the jars in the JVM classpath. 2. `getResourceAsStream` will first look for the resource in a parent ClassLoader. 3. The reference compiler is in the JVM classpath. So if the reference compiler is Dotty-compiled, we might pick up .tasty files from it instead of the current compiler. Using `null` as the parent ClassLoader avoids this problem.
1 parent f06a249 commit a8ef78c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ class ClassfileParser(
804804
ctx.error("Could not load TASTY from .tasty for virtual file " + classfile)
805805
Array.empty
806806
case Some(jar: ZipArchive) => // We are in a jar
807-
val cl = new URLClassLoader(Array(jar.jpath.toUri.toURL))
807+
val cl = new URLClassLoader(Array(jar.jpath.toUri.toURL), /*parent =*/ null)
808808
val path = classfile.path.stripSuffix(".class") + ".tasty"
809809
val stream = cl.getResourceAsStream(path)
810810
if (stream != null) {

0 commit comments

Comments
 (0)