[Mono-bugs] [Bug 636465] Monodroid generates incorrect java for subclasses of generic types.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Sep 7 22:34:42 EDT 2010



--- Comment #1 from Jonathan Pryor <jpryor at novell.com> 2010-09-08 02:34:41 UTC ---
There are two mostly unrelated issues at play here:

1. Generic types which wrap Java types.
2. New generic types provided by user code.

ArrayAdapter<T> is the poster child for (1), and can't be fixed wholly within
monodroid.exe.  Specifically, it needs two sets of functionality:

 a. We need to annotate ArrayAdapter<T> with [Register] for the underlying Java 
    type.  (In fact, we need to do this for EVERY generic wrapper, such as
    Android.Widget.AdapterView<T>, and any generic wrappers we provide in
    the future, because when monodroid generates the proxies it needs to 
    provide the appropriate base class, which is what [Register] does.)

 b. monodroid.exe needs to properly generate delegating constructors.

I say this because even when (a) is fixed, no constructors are emitted.  I'll
need to debug why this occurs.

Scenario (2) is subtly different, in that we don't control it.  The problem is
that EVERY type which subclasses Java.Lang.Object and gets a Java proxy
generated for it, and Java (deep breath) Doesn't Have Real Generics. 
Specifically, nothing stops someone from writing the following (valid) C# code:

    class A<T> : Java.Lang.Object {}
    class A<T1, T2> : Java.Lang.Object {}
    // repeat as desired...

This is valid C#, but Java generics do NOT support "overloading" a generic type
based on the number of generic type parameters.  (At present, we'd probably get
a javac compiler error based on "bad" type names like A`1 and A`2, but even if
we "fixed" that bug to strip off the `N from the type name we'd have...multiple
A types being declared in the same package.  Result: compilation errors

What should be done for Scenario (2)? We can either say Don't Do That (and
generate an error from monodroid when detected), or we could "escape" the '`'
with '_', resulting in A_1 and A_2 Java proxy types.


Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list