diff options
author | michelou <michelou@epfl.ch> | 2009-09-22 15:27:34 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2009-09-22 15:27:34 +0000 |
commit | 35f61f4fa2c277d7c459b148ab0cf633b2800386 (patch) | |
tree | 1a9152a212af781c0c881aad314808350bbb8ef3 /src/compiler/scala/tools/nsc/plugins/Plugin.scala | |
parent | 4466e36c4dd278b2d25f7611fc84655d0728966a (diff) | |
download | scala-35f61f4fa2c277d7c459b148ab0cf633b2800386.tar.gz scala-35f61f4fa2c277d7c459b148ab0cf633b2800386.tar.bz2 scala-35f61f4fa2c277d7c459b148ab0cf633b2800386.zip |
fixed doArgs (Settings.scala) and loadFrom (Plu...
fixed doArgs (Settings.scala) and loadFrom (Plugin.scala)
Diffstat (limited to 'src/compiler/scala/tools/nsc/plugins/Plugin.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/plugins/Plugin.scala | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 2b61724c49..50bd52d3fa 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -63,8 +63,8 @@ abstract class Plugin { * @author Lex Spoon * @version 1.0, 2007-5-21 */ -object Plugin -{ +object Plugin { + private val PluginXML = "scalac-plugin.xml" /** Create a class loader with the specified file plus @@ -78,7 +78,8 @@ object Plugin } /** Try to load a plugin description from the specified - * file, returning None if it does not work. */ + * file, returning <code>None</code> if it does not work. + */ private def loadDescription(jarfile: Path): Option[PluginDescription] = // XXX Return to this once we have some ARM support if (!jarfile.exists) None @@ -86,9 +87,9 @@ object Plugin val jar = new JarFile(jarfile.jfile) try { - (jar getEntry PluginXML) match { - case null => None - case entry => + jar getEntry PluginXML match { + case null => None + case entry => val in = jar getInputStream entry val packXML = XML load in in.close() @@ -104,19 +105,21 @@ object Plugin type AnyClass = Class[_] - /** Loads a plugin class from the named jar file. Returns None - * if the jar file has no plugin in it or if the plugin - * is badly formed. - */ - def loadFrom(jarfile: Path, loader: ClassLoader): Option[AnyClass] = { - val pluginInfo = loadDescription(jarfile).get + /** Loads a plugin class from the named jar file. - try Some(loader loadClass pluginInfo.classname) catch { - case _: ClassNotFoundException => - println("Warning: class not found for plugin in %s (%s)".format(jarfile, pluginInfo.classname)) - None + * @return <code>None</code> if the jar file has no plugin in it or + * if the plugin is badly formed. + */ + def loadFrom(jarfile: Path, loader: ClassLoader): Option[AnyClass] = + loadDescription(jarfile) match { + case None => None + case Some(pdesc) => + try Some(loader loadClass pdesc.classname) catch { + case _: Exception => + println("Warning: class not found for plugin in %s (%s)".format(jarfile, pdesc.classname)) + None + } } - } /** Load all plugins found in the argument list, both in the * jar files explicitly listed, and in the jar files in the |