I make an Android demo app to explain how to develop Android apps in Fantom.
Wow, that looks brilliant! :)
I see you've added a name mangling patch to fan-1.0 to work around the invokespecial problem - good work!
@go4, awesome work! So was that name mangling of private fields the only fix you needed to compiler/emitter to get Fantom to work on Andriod? If so then maybe should work to get that integrated into core. Would make for uglier stack traces, but might be able to fix that to make them pretty in our code.
Thanks for reply.
The name mangling is an easy way to get it work. As brian said, there are three strategies.
Name mangling and CallVirtual are all needed.
Ticket promoted to #2391 and assigned to brian
I'm actually thinking it might be better to leave the compiler alone as is and try and handle this strictly in the Java emitter. Because private methods by definition can't be dispatched virtually, I think we can actually generate all private methods as static methods and dispatch using invokestatic. Then we don't need name mangling or wrapper methods. When I have some free time I am going to investigate that approach (if anyone wants to try that out please email me and I will work with you).
Really cool! Thanks for doing this go4!
I push another patch for Android 5.0 and update the apk.
Android 5.0 take a new runtime called ART(ahead-of-time compilation) to replace Dalvik VM. It reject a abstract class with factory constructor that generated by fantom.
Awesome work Go4!
Thanks go4, it sounds like the problem is that I was relying on on the JVM to raise an InstantiationError if I called the constructor of an abstract class. But now that is a verification/compile-time error instead of a runtime error. Not sure I like these subtle differences in Andriod. But that is a much easier fix than the name mangling.
I think the proper fix is to go ahead and generate the static factory method so its there, but just have it raise an exception. I pushed a patch which implements this new behavior in the Java bytecode emitter:
Can you try that out and see if it resolves your problem? Thanks!
Yes, It works!
Wow, this is exciting stuff. I'm going to have to try it out! Might revolutionize Android app development.
Thanks, I just do some experimental works. Hope someone can build a real product in Fantom. The IDE support is another gap. If you want to compile from source, I added some doc
Login or Signup to reply.