diff options
author | Som Snytt <som.snytt@gmail.com> | 2013-05-18 06:01:00 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-05-18 06:01:00 -0700 |
commit | e0bd62c5f24fba233a879f6b97cd61152183c3a0 (patch) | |
tree | 3b99a98f1eb464db373bb6072c09687ef9b5dcee | |
parent | 07ef61a7d759c3944e01a77096346f5d2f1e7c74 (diff) | |
download | scala-e0bd62c5f24fba233a879f6b97cd61152183c3a0.tar.gz scala-e0bd62c5f24fba233a879f6b97cd61152183c3a0.tar.bz2 scala-e0bd62c5f24fba233a879f6b97cd61152183c3a0.zip |
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?
-rw-r--r-- | src/compiler/scala/tools/nsc/plugins/Plugin.scala | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index b0113f7696..a584a4ed5d 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/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 |