Skip to content

Choose the inner-most scalac-plugin.xml resource during plugin resolution#8322

Merged
retronym merged 2 commits intoscala:2.12.xfrom
retronym:topic/11666
Aug 15, 2019
Merged

Choose the inner-most scalac-plugin.xml resource during plugin resolution#8322
retronym merged 2 commits intoscala:2.12.xfrom
retronym:topic/11666

Conversation

@retronym
Copy link
Member

@retronym retronym commented Aug 8, 2019

@retronym
Copy link
Member Author

/nothingtoseehere

(travis build timed out, jenkins is happy)

loader.getResource(PluginXML) match {
case null => Failure(new MissingPluginException(path))
case url =>
loader.getResources(PluginXML).asScala.toList.lastOption match {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a second line of defence, in case a Global subclass overrides findPluginClassloader and doesn't special case parent delegation for plugin.xml as I've done in Plugins.scala.

@smarter
Copy link
Member

smarter commented Aug 12, 2019

Are you planning to write tests that exercise this? This change should be easily portable to do but I'm not comfortable doing that without tests

@retronym
Copy link
Member Author

@smarter I did attempt to replicate the classloader setup in a test case but couldn't find a decent way to do it without creating new test infrastructure.

@retronym retronym merged commit 796bf17 into scala:2.12.x Aug 15, 2019
retronym added a commit to retronym/scala that referenced this pull request Aug 19, 2019
This commit reverts part of the scala#8322

I recently changed to using the last entry from getResources to
avoid parent classloader delegation, but this leads to unwanted
results if the plugin classpath itself contains multiple
`scalac-plugin.xml` resources and wants the compiler to choose
the first.

I have _not_ reverted the other change in scala#8322 which overrides
`getResource` to avoid parent delegation for `scalac-plugin.xml`.
I have documented the `findPluginClassLoader` extension point
with instructions to do the same.
@retronym
Copy link
Member Author

I've had to tweak this in #8345 to cope with plugin classpaths that themselves contain multiple scalac-plugin.xml resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants