-Ymacro-classpath / Global.close() / Reference counted FileBasedCache#29
-Ymacro-classpath / Global.close() / Reference counted FileBasedCache#29
Conversation
For better cacheability
An extension point analagous to `findMacroClassLoader`
634c001 to
e2a829f
Compare
| } | ||
| case None => | ||
| Failure(new MissingPluginException(path)) | ||
| } |
There was a problem hiding this comment.
@som-snytt I'm thinking of making this change to read scalac-plugin.xml from a classloader, rather than by looking through JARs and directories. The motivation is to let customized Global-s provide the classloader, to do things like manage the lifecycle of the classloader + open file handles with extra knowledge of multi-project builds.
Seems to me like a logical extension of the groundwork you laid in scala#3169. WDYT?
There was a problem hiding this comment.
Sounds good. I don't remember why the old logic looks so labored. Please indulge my alliteration.
By coincidence, at the day job I just asked to switch some legacy config from a command line option to a class loader resource.
I read the related tickets around class loader caching.
| case (j, Success(pd)) => Success((pd, findPluginClassloader(Seq(j)))) | ||
| val fromLoaders = paths.map {path => | ||
| val loader = findPluginClassloader(path) | ||
| val list: Option[URL] = loader.getResources(PluginXML).asScala.take(1).toList.headOption |
There was a problem hiding this comment.
Option(loader.getResource(PluginXML)) or is there a mysterious gotcha? Besides they're going to rename it to Option.ofNullable?
There was a problem hiding this comment.
@som-snytt Oh yeah, that sounds better. I got too attached to the existing loops.
This lets customized Global's deliver this file, and offloads the scanning logic.
171ad8e to
deb10d4
Compare
| case pathString => | ||
| import java.nio.file._ | ||
| val path = Paths.get(pathString) | ||
| Files.write(path, argsFile.getBytes(Charset.forName("UTF-8"))) |
There was a problem hiding this comment.
This decade there is StandardCharsets.
d8bb552 to
deb10d4
Compare
Close Global-scoped JARs and ClassLoaders. Entries of FileBasedCache that have a lifetime that exceeds any single Global instance are reference counted. When the count hits zero, it is closed if no references appear after a delay.
deb10d4 to
30c372a
Compare
Co-Authored-By: retronym <jzaugg@gmail.com>
|
Submitted as scala#7366 |
No description provided.