Reporting errors from compiler plugins

12 views
Skip to first unread message

Paul Butcher

unread,
May 28, 2011, 12:11:16 PM5/28/11
to scala-user
What is the correct way to set up a compiler plugin to report errors? Whenever I screw anything up in the plugin I'm currently writing, instead of getting an exception report, I get a ClassNotFoundException (full stack trace at the end of this message).

This is making development tougher than it needs to be, but I'll also need to think about what to do later, when I want to give sensible error messages to the end-user too...

Thanks in advance for any help!

Here's an example stack trace:

> java.lang.ClassNotFoundException: Main (args = , classpath = /var/folders/Dv/DvlT4ws6FkiBGx0tgaexok+++TI/-Tmp-/scalascript2075965475272034645.tmp:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar:/opt/local/share/scala-2.9/lib/jline.jar:/opt/local/share/scala-2.9/lib/scala-compiler.jar:/opt/local/share/scala-2.9/lib/scala-dbc.jar:/opt/local/share/scala-2.9/lib/scala-library.jar:/opt/local/share/scala-2.9/lib/scala-swing.jar:/opt/local/share/scala-2.9/lib/scalap.jar:/System/Library/Java/Extensions/AppleScriptEngine.jar:/System/Library/Java/Extensions/dns_sd.jar:/System/Library/Java/Extensions/j3daudio.jar:/System/Library/Java/Extensions/j3dcore.jar:/System/Library/Java/Extensions/j3dutils.jar:/System/Library/Java/Extensions/jai_codec.jar:/System/Library/Java/Extensions/jai_core.jar:/System/Library/Java/Extensions/mlibwrapper_jai.jar:/System/Library/Java/Extensions/MRJToolkit.jar:/System/Library/Java/Extensions/QTJava.zip:/System/Library/Java/Extensions/vecmath.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:/Users/paul/scala/foo/.:/Users/paul/scala/foo/../borachio/library/target/scala_2.9.0/library_2.9.0-1.1.jar)
> at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:103)
> at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
> at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
> at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$runCompiled(ScriptRunner.scala:180)
> at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:197)
> at scala.tools.nsc.ScriptRunner$$anonfun$runScript$1.apply(ScriptRunner.scala:197)
> at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1$$anonfun$apply$mcZ$sp$1.apply(ScriptRunner.scala:166)
> at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1$$anonfun$apply$mcZ$sp$1.apply(ScriptRunner.scala:166)
> at scala.Option.exists(Option.scala:188)
> at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:166)
> at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:140)
> at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:140)
> at scala.tools.nsc.util.package$.waitingForThreads(package.scala:26)
> at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:139)
> at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:197)
> at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:210)
> at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:58)
> at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
> at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
> at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
>


--
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: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

Paul Butcher

unread,
Jun 2, 2011, 7:38:09 AM6/2/11
to scala-user
I'd really appreciate some help with this? There must be a "right" way to report errors from a plugin? If there's an example or any documentation I should look at, I'd greatly appreciate a pointer...

Thanks!

iulian dragos

unread,
Jun 5, 2011, 1:10:01 AM6/5/11
to Paul Butcher, scala-user
On Thu, Jun 2, 2011 at 4:38 AM, Paul Butcher <pa...@paulbutcher.com> wrote:
I'd really appreciate some help with this? There must be a "right" way to report errors from a plugin? If there's an example or any documentation I should look at, I'd greatly appreciate a pointer...

You need to explain better what you're doing, because the explanations and the stack trace have nothing in common. According to the stack trace, class Main is not on the classpath. How are you running the compiler? You don't seem to even get to running any phase, let alone your plugin.

cheers,
iulian



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Paul Butcher

unread,
Jun 6, 2011, 4:54:34 AM6/6/11
to iulian dragos, scala-user
On 5 Jun 2011, at 06:10, iulian dragos wrote:
> You need to explain better what you're doing, because the explanations and the stack trace have nothing in common. According to the stack trace, class Main is not on the classpath. How are you running the compiler? You don't seem to even get to running any phase, let alone your plugin.

I'm not doing anything at all clever. I have a compiler plugin which runs fine and does exactly what I hope it should. But if it ever throws an exception, I get the (very confusing!) stack trace I attached in an earlier message.

I'll see if I can put together a small example to demonstrate the problem so that others can reproduce it.

Reply all
Reply to author
Forward
0 new messages