This page is no longer maintained — Please continue to the home page at www.scala-lang.org

newbie compiler plugin help

2 replies
George Chapman
Joined: 2011-11-28,
User offline. Last seen 42 years 45 weeks ago.

I have followed the instructions on the scala-lang page about scalac
plugins (http://www.scala-lang.org/node/140) but cannot even get the
example they give to work. I receive the following error when trying
to run the plugin wrapped in a jar using the Xplugin: option as
detailed towards the end of the page:

Warning: class not found for plugin in divbyzero.jar
(localhost.DivByZero)

any help would be greatly appreciated,

George

paulbutcher
Joined: 2010-03-08,
User offline. Last seen 10 weeks 6 days ago.
Re: newbie compiler plugin help

On 27 Nov 2011, at 23:29, George Chapman wrote:
> I have followed the instructions on the scala-lang page about scalac
> plugins (http://www.scala-lang.org/node/140) but cannot even get the
> example they give to work. I receive the following error when trying
> to run the plugin wrapped in a jar using the Xplugin: option as
> detailed towards the end of the page:
>
> Warning: class not found for plugin in divbyzero.jar
> (localhost.DivByZero)
>
> any help would be greatly appreciated,

That sounds very much as though the classname you specified in your scalac-plugin.xml isn't correct. Have you misspelled it? Or is the class not actually in the .jar file for some reason?

--
paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: paul@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

Miguel Garcia 2
Joined: 2011-01-30,
User offline. Last seen 42 years 45 weeks ago.
Re: newbie compiler plugin help

There's another introduction to compiler plugins at:
  http://suereth.blogspot.com/2009/02/levaraging-annotations-in-scala-part-2.html

Not sure whether you want to step in debug mode through the compiler right away (should help when authoring compiler plugins, anyway). The snippet below shows where that error message comes from:

  /** Loads a plugin class from the named jar file.
   *
   *  @return `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] =


Miguel
http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland