Sunday, June 14, 2009

No Scala for GWT

I'm working through my buzzword complaint application which naturally includes Cloud computing (Google App Engine), GWT, Scala and the rest of social Web2.0 hyped BS. Wow, that was a keyword loaded sentence ;-)

GWT has a nasty exception to my experience so far that you can replace any Java code with Scala. When you try to have a GWT EntryPoint be implemented in Scala you get this GWT compilation error

Checking rule <generate-with class=''>
Checking if all subconditions are true <all>
<when-assignable class=''>
[ERROR] Unable to find type 'com.newspipes.client.Newspipes'
[ERROR] Hint: Check that the type name 'com.newspipes.client.Newspipes' is really what you meant
[ERROR] Hint: Check that your classpath includes all required source roots
The error is a bit confusing since the class is in the classpath and you can see the compiled *.class under WEB-INF/classes. The GWT compiler compiles Java source directly to Javascript and it check that the sources it compiles are *.java files. So instead of "Unable to find type..." it actually means "Unable to find java source file of type...".


Daniel June 14, 2009 at 4:03 PM  

You could try compiling the Scala and then using a decompiler, such as cavaj, to produce a valid .java.

Eishay Smith June 14, 2009 at 4:14 PM  

Thought about it but I don't think its worth the effort since:
* You must integrate in the tooling workflow (eclipse/ant etc) the scala -> bytecode -> java -> gwt
* Scala creates tons of class files for the closures, not sure how they map to how GWT sees the world.
* There might be lots of Scala cases that the ones who wrote the GWT compilers didn't plan for.
* Debugging it and tracking stack traces in this multi-lang mess will be a nightmare.

Creative Commons License This work by Eishay Smith is licensed under a Creative Commons Attribution 3.0 Unported License.