Skip to content

Commit 5c89528

Browse files
committed
.
1 parent 65b75b6 commit 5c89528

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

compiler/src/dotty/tools/dotc/quoted/Interpreter.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Interpreter(pos: SrcPos, classLoader0: ClassLoader)(using Context):
3535

3636
val classLoader =
3737
if ctx.owner.topLevelClass.name.startsWith(str.REPL_SESSION_LINE) then
38-
new AbstractFileClassLoader(ctx.settings.outputDir.value, classLoader0)
38+
new AbstractFileClassLoader(ctx.settings.outputDir.value, classLoader0, false)
3939
else classLoader0
4040

4141
/** Local variable environment */
@@ -204,7 +204,11 @@ class Interpreter(pos: SrcPos, classLoader0: ClassLoader)(using Context):
204204
}
205205

206206
private def loadReplLineClass(moduleClass: Symbol): Class[?] = {
207-
val lineClassloader = new AbstractFileClassLoader(ctx.settings.outputDir.value, classLoader)
207+
val lineClassloader = new AbstractFileClassLoader(
208+
ctx.settings.outputDir.value,
209+
classLoader,
210+
false
211+
)
208212
lineClassloader.loadClass(moduleClass.name.firstPart.toString)
209213
}
210214

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import dotty.tools.repl.ReplBytecodeInstrumentation
2121
import java.net.{URL, URLConnection, URLStreamHandler}
2222
import java.util.Collections
2323

24-
class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader, instrumentBytecode: Boolean = true) extends ClassLoader(parent):
24+
class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader, instrumentBytecode: Boolean) extends ClassLoader(parent):
2525
private def findAbstractFile(name: String) = root.lookupPath(name.split('/').toIndexedSeq, directory = false)
2626

2727
// on JDK 20 the URL constructor we're using is deprecated,

compiler/src/dotty/tools/repl/Rendering.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
7272
new java.net.URLClassLoader(compilerClasspath.toArray, baseClassLoader)
7373
}
7474

75-
val instrumentBytecode = !ctx.settings.XreplDisableBytecodeInstrumentation.value
76-
myClassLoader = new AbstractFileClassLoader(ctx.settings.outputDir.value, parent, instrumentBytecode)
75+
myClassLoader = new AbstractFileClassLoader(
76+
ctx.settings.outputDir.value,
77+
parent,
78+
!ctx.settings.XreplDisableBytecodeInstrumentation.value
79+
)
7780
myClassLoader
7881
}
7982

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,11 @@ class ReplDriver(settings: Array[String],
599599
val prevClassLoader = rendering.classLoader()
600600
val jarClassLoader = fromURLsParallelCapable(
601601
jarClassPath.asURLs, prevClassLoader)
602-
val instrumentBytecode = !ctx.settings.XreplDisableBytecodeInstrumentation.value
603602
rendering.myClassLoader = new AbstractFileClassLoader(
604-
prevOutputDir, jarClassLoader, instrumentBytecode)
603+
prevOutputDir,
604+
jarClassLoader,
605+
!ctx.settings.XreplDisableBytecodeInstrumentation.value
606+
)
605607

606608
out.println(s"Added '$path' to classpath.")
607609
} catch {

compiler/test/dotty/tools/repl/AbstractFileClassLoaderTest.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ class AbstractFileClassLoaderTest:
5050
@Test def afclGetsParent(): Unit =
5151
val p = new URLClassLoader(Array.empty[URL])
5252
val d = new VirtualDirectory("vd", None)
53-
val x = new AbstractFileClassLoader(d, p)
53+
val x = new AbstractFileClassLoader(d, p, false)
5454
assertSame(p, x.getParent)
5555

5656
@Test def afclGetsResource(): Unit =
5757
val (fuzz, booz) = fuzzBuzzBooz
5858
booz.writeContent("hello, world")
59-
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader)
59+
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
6060
val res = sut.getResource("buzz/booz.class")
6161
assertNotNull("Find buzz/booz.class", res)
6262
assertEquals("hello, world", slurp(res))
@@ -66,8 +66,8 @@ class AbstractFileClassLoaderTest:
6666
val (fuzz_, booz_) = fuzzBuzzBooz
6767
booz.writeContent("hello, world")
6868
booz_.writeContent("hello, world_")
69-
val p = new AbstractFileClassLoader(fuzz, NoClassLoader)
70-
val sut = new AbstractFileClassLoader(fuzz_, p)
69+
val p = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
70+
val sut = new AbstractFileClassLoader(fuzz_, p, false)
7171
val res = sut.getResource("buzz/booz.class")
7272
assertNotNull("Find buzz/booz.class", res)
7373
assertEquals("hello, world", slurp(res))
@@ -78,7 +78,7 @@ class AbstractFileClassLoaderTest:
7878
val bass = fuzz.fileNamed("bass")
7979
booz.writeContent("hello, world")
8080
bass.writeContent("lo tone")
81-
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader)
81+
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
8282
val res = sut.getResource("booz.class")
8383
assertNotNull(res)
8484
assertEquals("hello, world", slurp(res))
@@ -88,7 +88,7 @@ class AbstractFileClassLoaderTest:
8888
@Test def afclGetsResources(): Unit =
8989
val (fuzz, booz) = fuzzBuzzBooz
9090
booz.writeContent("hello, world")
91-
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader)
91+
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
9292
val e = sut.getResources("buzz/booz.class")
9393
assertTrue("At least one buzz/booz.class", e.hasMoreElements)
9494
assertEquals("hello, world", slurp(e.nextElement))
@@ -99,8 +99,8 @@ class AbstractFileClassLoaderTest:
9999
val (fuzz_, booz_) = fuzzBuzzBooz
100100
booz.writeContent("hello, world")
101101
booz_.writeContent("hello, world_")
102-
val p = new AbstractFileClassLoader(fuzz, NoClassLoader)
103-
val x = new AbstractFileClassLoader(fuzz_, p)
102+
val p = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
103+
val x = new AbstractFileClassLoader(fuzz_, p, false)
104104
val e = x.getResources("buzz/booz.class")
105105
assertTrue(e.hasMoreElements)
106106
assertEquals("hello, world", slurp(e.nextElement))
@@ -111,15 +111,15 @@ class AbstractFileClassLoaderTest:
111111
@Test def afclGetsResourceAsStream(): Unit =
112112
val (fuzz, booz) = fuzzBuzzBooz
113113
booz.writeContent("hello, world")
114-
val x = new AbstractFileClassLoader(fuzz, NoClassLoader)
114+
val x = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
115115
val r = x.getResourceAsStream("buzz/booz.class")
116116
assertNotNull(r)
117117
assertEquals("hello, world", closing(r)(is => Source.fromInputStream(is).mkString))
118118

119119
@Test def afclGetsClassBytes(): Unit =
120120
val (fuzz, booz) = fuzzBuzzBooz
121121
booz.writeContent("hello, world")
122-
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader)
122+
val sut = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
123123
val b = sut.classBytes("buzz/booz.class")
124124
assertEquals("hello, world", new String(b, UTF8.charSet))
125125

@@ -129,8 +129,8 @@ class AbstractFileClassLoaderTest:
129129
booz.writeContent("hello, world")
130130
booz_.writeContent("hello, world_")
131131

132-
val p = new AbstractFileClassLoader(fuzz, NoClassLoader)
133-
val sut = new AbstractFileClassLoader(fuzz_, p)
132+
val p = new AbstractFileClassLoader(fuzz, NoClassLoader, false)
133+
val sut = new AbstractFileClassLoader(fuzz_, p, false)
134134
val b = sut.classBytes("buzz/booz.class")
135135
assertEquals("hello, world", new String(b, UTF8.charSet))
136136
end AbstractFileClassLoaderTest

staging/src/scala/quoted/staging/QuoteDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private class QuoteDriver(appClassloader: ClassLoader) extends Driver:
6161
case Left(classname) =>
6262
assert(!ctx.reporter.hasErrors)
6363

64-
val classLoader = new AbstractFileClassLoader(outDir, appClassloader)
64+
val classLoader = new AbstractFileClassLoader(outDir, appClassloader, false)
6565

6666
val clazz = classLoader.loadClass(classname)
6767
val method = clazz.getMethod("apply")

0 commit comments

Comments
 (0)