https://bugzilla.novell.com/show_bug.cgi?id=655342
https://bugzilla.novell.com/show_bug.cgi?id=655342#c7 Jonathan Pryor <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |WONTFIX --- Comment #7 from Jonathan Pryor <[email protected]> 2010-12-08 21:09:48 UTC --- This, in general, is currently unsolvable in the general case: 1. Java constructors can't be `native`. 2. Consequently, monodroid MUST generate _something_ for the Java proxy constructor body. 3. javac requires an implicit or explicit super() call 4. When no default base constructor is present, super() is required. As a result of 1-4, the Java Proxy for MyIntentService (comment 5) would need to be: public MyIntentService () { super(???); if (getClass () == MyIntentService.class) mono.android.TypeManager.Activate (...); } Now tell me, what should `???` be? In this case, `null` is the obvious answer, and it would actually work. However consider android.accounts.Account: // C# public class MyAccount : Android.Accounts.Account { public MyAccount () : base ("name", "type") {} } // Java Proxy ... public MyAccount () { super (null); // ... } IIF Android creates a MyAccount instance, then the MyAccount constructor will pass null to the Account(Parcel) constructor, which will result in a java.lang.NullPointerException: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/accounts/Account.java;h=7b83a3076db336d53bb8d3eef65eb799ed96ff39;hb=HEAD#l57 Oops. Not that using the Account(String,String) constructor would be any better; that just results in an InvalidArgumentException. The result is that, for SOME types, if Android creates them via the default constructor then construction will FAIL and the C# constructor will never be invoked. Just to make things inconsistent, creating MyAccount from C# would be perfectly fine; it's only if the instance is created from Android/Java that things will break. (Sounds like a great debugging excursion, doesn't it?) There is only one way to sanely make this work -- and monodroid can't do it -- is to write custom Java code which subclasses e.g. Account and provides a default constructor, which can provide the appropriate (Java-side) parameters. Then it becomes a matter of getting your C# code to reference your Java code, which something we need to better flesh out and document. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
