---------- Forwarded message ----------
From: Matt Hellige
Date: Nov 13, 2007 12:09 PM
Subject: [scala-lounge] Re: [scala] Scalandroid
On Nov 13, 2007 1:02 PM, David Pollak <
> The Android VM reads JVM bytecode and converts it into DEX format.
> There's no reason that Android can't run any JVM language unless that
> language is dynamically creating bytecode at runtime (this is a
> questionmark.) There's a discussion of this issue on the JVM Languages list
> right now.
(moving to the lounge...)
I've actually just tried this. The short answer is that it's going to
take at least a little work, and maybe a lot.
I generated the sample activity using the Android scaffolding scripts,
hacked up the build.xml a little bit and ported the main Activity
class to Scala. Everything compiled fine and installed to the
emulator, but I got denied : NoClassDefFoundError. I figured this is
likely a missing scala-library.jar, so I extracted just
scala.ScalaObject and scala.ScalaObject$class and packaged them up
with my own classes. This fixed the NoClassDefFoundError, but now I
get something worse. The onCreate() method of each activity must call
super.onCreate(). The phone checks for this and throws an exception
otherwise. But if I try to call super.onCreate() in my Scala code, I
get a NoClassDefFoundError. Of course the same code works fine in
Java. The bytecode looks similar from javap, but clearly there's
something going on.
It might be as simple as writing some wrapper code in Java and then
delegating to Scala, but this makes me worry that the dx compiler does
depend in subtle ways on the bytecode. Unfortunately, I don't have any
more time to play with this today. I'd love to learn that it's
Matt Hellige / ma...@immute.net