Skip to content

Commit 609720f

Browse files
authored
Check if rt.jar is still necessary (#4206)
Fixes #4164 It's been around since we used to use Ammonite to compile scripts, and IIRC was necessary to make the in-memory Scala compiler work. We no longer go through that code path, so maybe we can get rid of it? AFAIK we now only use the Scala compiler through Zinc which manages this stuff itself
1 parent a3a9457 commit 609720f

File tree

2 files changed

+1
-47
lines changed

2 files changed

+1
-47
lines changed

Diff for: main/api/src/mill/api/ClassLoader.scala

+1-36
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ package mill.api
22

33
import java.net.{URL, URLClassLoader}
44

5-
import java.nio.file.{FileAlreadyExistsException, FileSystemException}
6-
7-
import mill.java9rtexport.Export
8-
import scala.util.Properties
9-
105
/**
116
* Utilities for creating classloaders for running compiled Java/Scala code in
127
* isolated classpaths.
@@ -22,10 +17,7 @@ object ClassLoader {
2217
sharedPrefixes: Seq[String] = Seq(),
2318
logger: Option[mill.api.Logger] = None
2419
)(implicit ctx: Ctx.Home): URLClassLoader = {
25-
new URLClassLoader(
26-
makeUrls(urls).toArray,
27-
refinePlatformParent(parent)
28-
) {
20+
new URLClassLoader(urls.toArray, refinePlatformParent(parent)) {
2921
override def findClass(name: String): Class[?] = {
3022
if (sharedPrefixes.exists(name.startsWith)) {
3123
logger.foreach(
@@ -73,31 +65,4 @@ object ClassLoader {
7365
appClassLoader.getParent()
7466
}
7567
}
76-
77-
private def makeUrls(urls: Seq[URL])(implicit ctx: Ctx.Home): Seq[URL] = {
78-
if (java9OrAbove) {
79-
val java90rtJar = ctx.home / Export.rtJarName
80-
if (!os.exists(java90rtJar)) {
81-
// Time between retries should go from 100 ms to around 10s, which should
82-
// leave plenty of time for another process to write fully this 50+ MB file
83-
val retry = Retry(
84-
count = 7,
85-
backoffMillis = 100,
86-
filter = {
87-
case (_, _: FileSystemException) if Properties.isWin => true
88-
case _ => false
89-
}
90-
)
91-
retry {
92-
try os.copy(os.Path(Export.rt()), java90rtJar, createFolders = true)
93-
catch {
94-
case e: FileAlreadyExistsException => /* someone else already did this */
95-
}
96-
}
97-
}
98-
urls :+ java90rtJar.toIO.toURI().toURL()
99-
} else {
100-
urls
101-
}
102-
}
10368
}

Diff for: runner/src/mill/runner/MillMain.scala

-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import java.nio.file.StandardOpenOption
66
import java.util.Locale
77
import scala.jdk.CollectionConverters.*
88
import scala.util.Properties
9-
import mill.java9rtexport.Export
109
import mill.api.{MillException, SystemStreams, WorkspaceRoot, internal}
1110
import mill.bsp.{BspContext, BspServerResult}
1211
import mill.main.BuildInfo
@@ -195,16 +194,6 @@ object MillMain {
195194

196195
val threadCount = Some(maybeThreadCount.toOption.get)
197196

198-
if (mill.main.client.Util.isJava9OrAbove) {
199-
val rt = config.home / Export.rtJarName
200-
if (!os.exists(rt)) {
201-
streams.err.println(
202-
s"Preparing Java ${System.getProperty("java.version")} runtime; this may take a minute or two ..."
203-
)
204-
Export.rtTo(rt.toIO, false)
205-
}
206-
}
207-
208197
val bspContext =
209198
if (bspMode) Some(new BspContext(streams, bspLog, config.home)) else None
210199

0 commit comments

Comments
 (0)