From e0bd62c5f24fba233a879f6b97cd61152183c3a0 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 18 May 2013 06:01:00 -0700 Subject: 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? --- src/compiler/scala/tools/nsc/plugins/Plugin.scala | 11 ++++------- 1 file 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 -- cgit v1.2.3