Permalink
Browse files

SI-7494 Each plugin must only be instantiated once.

The old behavior was that Plugin.loadAllFrom took a distinct
list of plugin locations.

The broken behavior incorrectly punted to the pruning
algorithm in Plugins.loadPlugins$pick.

The new behavior is to distinctify the list of class names
to load.

This is more robust; under the old scheme, specifying the
continuations.jar under two file names would fail as
described in the ticket.

Pruning a plugin by disabling (-Xplugin-disable) or because
it steps on someone else's phase name suffers the same
defect. There is no way to tell the plugin it has been
benched. And you know that global I gave you?  Can I
have it back?
  • Loading branch information...
1 parent 07ef61a commit e0bd62c5f24fba233a879f6b97cd61152183c3a0 @som-snytt som-snytt committed May 18, 2013
Showing with 4 additions and 7 deletions.
  1. +4 −7 src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -93,15 +93,13 @@ object Plugin {
type AnyClass = Class[_]
/** Use a class loader to load the plugin class.
- *
- * @return `None` on failure
*/
- def load(pd: PluginDescription, loader: ClassLoader): Try[AnyClass] = {
+ def load(classname: String, loader: ClassLoader): Try[AnyClass] = {
Try[AnyClass] {
- loader loadClass pd.classname
+ loader loadClass classname
} recoverWith {
case _: Exception =>
- Failure(new RuntimeException(s"Warning: class not found: ${pd.classname}"))
+ Failure(new RuntimeException(s"Warning: class not found: ${classname}"))
}
}
@@ -137,9 +135,8 @@ object Plugin {
case _ => false
}
val (locs, pds) = ((explicit ::: exploded ::: included) filterNot ignored).unzip
-
val loader = loaderFor(locs.distinct)
- pds filter (_.isSuccess) map (_.get) map (Plugin load (_, loader))
+ (pds filter (_.isSuccess) map (_.get.classname)).distinct map (Plugin load (_, loader))
}
/** Instantiate a plugin class, given the class and

0 comments on commit e0bd62c

Please sign in to comment.