-
Notifications
You must be signed in to change notification settings - Fork 1
-Ymacro-classpath / Global.close() / Reference counted FileBasedCache #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For better cacheability
An extension point analagous to `findMacroClassLoader`
634c001
to
e2a829f
Compare
inputStream.close() | ||
} | ||
case None => | ||
Failure(new MissingPluginException(path)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Submitted as scala#7366 |
No description provided.