From: Arno P. <ar...@pu...> - 2010-06-23 08:11:51
|
that is a known deficiency of XMLVM. Currently, we cross-compile Java to Objective-C making use of Objective-C's object model. Unfortunately, Objective-C does not permit to re-define a member variable in derived classes. That means, you cannot write a Java program that does that (although we name mangle the member's type into its name so at least we support same member name with different types along an inheritance path). Ordinarily you can easily avoid this by simply refactoring your program. Until I saw your message, I didn't know that javac itself creates this pattern. Unfortunately there is no easy solution. To add proper member lookup in Objective-C would incur a major runtime overhead. That is one of the reasons I want to change XMLVM's backend to C because here we are in control of how to implement Java's object model and don't try to map a statically object model to a dynamically typed one. Sorry for the long-winded explanation. For now, I suggest you don't use inner classes the way you do and way until we have the new C backend (which will take a while to complete). Arno On 6/22/10 1:29 PM, Markus Heberling wrote: > Hi, > > Converting the following class from java to objc generates wrong objc code. > > public class Main extends UIApplication { > > public void applicationDidFinishLaunching(UIApplication app) { > //... > } > > public static void main(String[] args) { > UIApplication.main(args, Main.class); > } > > public abstract class AbstractTest{ > > } > > public class Test1 extends AbstractTest{ > > } > > public class Test2 extends AbstractTest{ > } > } > > I get this in the Objc .h file for AbstractTest > @interface mylib_Main_AbstractTest : MyObject > { > @public mylib_Main* this_0_mylib_Main; > > } > > this for Test1 > @interface mylib_Main_Test1 : mylib_Main_AbstractTest > { > @public mylib_Main* this_0_mylib_Main; > > } > > and this for Test2 > @interface mylib_Main_Test2 : mylib_Main_AbstractTest > { > @public mylib_Main* this_0_mylib_Main; > > } > > So the reference back to the enclosing class is generated in each of > this @interface declarations. This gives compile errors in both > mylib_Main_Test1 and mylib_Main_Test2: > /Users/markus/Documents/workspace/xmlvm/test/src/xcode/trim/mylib_Main_Test1.h:15:0 > /Users/markus/Documents/workspace/xmlvm/test/src/xcode/trim/mylib_Main_Test1.h:15: > error: duplicate member 'this_0_mylib_Main' > > Is it possible to fix xmlvm to generate better code for such java > constructs? > > Regards, > Markus > > > > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > > > > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users |