From: Arno P. <ar...@pu...> - 2011-07-07 15:02:38
|
that would be a viable solution for the ObjC backend. Arno On 7/7/11 4:29 PM, Panayotis Katsaloulis wrote: > What do you think about the solution for this specific problem? > > Use the following code for the selector applicationDidFinishLaunching of > UIApplicationDelegate > > > - (void) applicationDidFinishLaunching: (UIApplication*) app > { > SELselector = > NSSelectorFromString([NSStringstringWithFormat:@"__init_%s__", > class_getName([selfclass])]); > [self performSelector:selector]; > > > [selfapplicationDidFinishLaunching___org_xmlvm_iphone_UIApplication: app]; > } > > As a side note, probably we should do the same for the UIApplication > object as well (if it is an instance of org_xmlvm_iphone_UIApplication) > > > > > On 11 Νοε 2010, at 6:56 μ.μ., Arno Puder wrote: > >> >> that is a known issue. The code that XMLVM generates is correct. The >> problem is that certain classes (such as UIAppication*) are instantiated >> by Cocoa and Cocoa doesn't know about the __init__*() constructors that >> were generated by XMLVM. The initialization of 'test' in your example >> will end up in the default constructor for class Main and since Cocoa >> doesn't call it, it won't get initialized. >> >> This will work perfectly fine for any other class (that is handled by >> XMLVM). It is just this special case when Cocoa instantiates a Java >> object. Back then I couldn't think of a solution for this. I'll revisit >> this with the C backend. Here we might have more hooks to solve this >> problem. >> >> Arno >> >> >> On 11/11/10 7:08 AM, Panayotis Katsaloulis wrote: >>> there is something missing when variables are initialized outsize the >>> constructor. >>> >>> As a minium program to display this error, have a look at this: >>> instead of printing "hello", it prints "null", since this is not >>> initialized. >>> >>> >>> >>> >>> package my.testmem; >>> >>> import org.xmlvm.iphone.UIApplication; >>> import org.xmlvm.iphone.UIApplicationDelegate; >>> >>> public class Main extends UIApplicationDelegate { >>> >>> String test = "hello"; >>> >>> @Override >>> public void applicationDidFinishLaunching(UIApplication app) { >>> System.out.println(test); >>> } >>> >>> public static void main(String[] args) { >>> UIApplication.main(args, null, Main.class); >>> } >>> } > > > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security > threats, fraudulent activity, and more. Splunk takes this data and makes > sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > > > > _______________________________________________ > Xmlvm-developers mailing list > Xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-developers |