> It looks like it has problems with invokespecial and super. The
> following will work:
>
> Java:
>
> public class MyActivity extends Activity
> {
> /** Called with the activity is first created. */
> @Override
> public void onCreate(Bundle icicle)
> {
> super.onCreate(icicle);
> new Sub().f(this);
> }
> }
>
> Scala:
>
> class Foo {
> def g(a: Activity) {
> val tv = new TextView(a)
> tv.setText("Hello Android. Cheers, Scala")
> a.setContentView(tv)
> }
> }
>
> class Sub extends Foo {
> def f(a: Activity) { g(a) }
> }
>
> If I replace the call to g with an explicit super reference, i.e.,
>
> class Sub extends Foo {
> def f(a: Activity) { super.g(a) }
> }
>
> I get a NoSuchMethodError at runtime:
>
> E/AndroidRuntime(545): Caused by: java.lang.NoSuchMethodError: g
> E/AndroidRuntime(545): at my.test.Sub.f(MyActivity.scala:26)
> E/AndroidRuntime(545): at my.test.MyActivity.onCreate(MyActivity.java:14)
> E/AndroidRuntime(545): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:786)
> E/AndroidRuntime(545): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1367)
> E/AndroidRuntime(545): ... 11 more
>
>
> The only difference of the generated bytecode I can see from javap's
> output is a different constant pool and that it uses invokespecial
> instead of invokevirtual in f. Invokespecial is also used if I move g to
> Sub and make it private, but it works that way.
>
> Just wanted to share my results. Anyone else playing with it?
>
> Ingo
>
>
> Matt Hellige wrote:
>> On Nov 13, 2007 2:52 PM, martin odersky <
odersky@...> wrote:
>>> Matt,
>>>
>>>> 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.
>>> It would be good to find out more about this. Certainly, Android would
>>> be a great target for Scala programs if we could get it to work. Can
>>> you give more details about the error your encountered? Which class
>>> was not found?
>>
>> Sorry, that was a typo. I meant to say that I get a NoSuchMethodError,
>> trying to call the superclass definition of onCreate(). (I realize
>> that that's not especially helpful.) If I have time, I will try to get
>> back to this later and find out more info. I think getting details
>> will require setting up the Android debugging environment a little
>> more carefully.
>>
>> m
>>
>