Bug 20812 - Inheriting from ArrayAdapter<__numeric_type-(int, long, short)__> fails to compile
Summary: Inheriting from ArrayAdapter<__numeric_type-(int, long, short)__> fails to co...
Status: RESOLVED FEATURE
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.14.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2014-06-23 08:45 UTC by Dimitar Dobrev
Modified: 2014-06-25 05:53 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
The generated Java code that fails to compile (6.00 KB, text/x-java)
2014-06-23 08:45 UTC, Dimitar Dobrev
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Dimitar Dobrev 2014-06-23 08:45:14 UTC
Created attachment 7152 [details]
The generated Java code that fails to compile

private class DurationAdapter : ArrayAdapter<int>
        {
            public DurationAdapter(Context context, int textViewResourceId, int[] objects) : base(context, textViewResourceId, objects)
            {
            }
        }

fails with:

Error	43	 cannot find symbol
symbol  : constructor ArrayAdapter(android.content.Context,int,int[])
location: class android.widget.ArrayAdapter
		super (p0, p1, p2);
...\SettingsActivity_DurationAdapter.java	66	3


The whole SettingsActivity_DurationAdapter.java is attached.
Comment 1 Udham Singh 2014-06-23 11:44:10 UTC
I have checked this issue and  observed the same behavior mentioned in bug description. To reproduce this issue I have created a simple android application and implemented the code provided in bug description.

Screencast : http://www.screencast.com/t/UQW4GyWEkWO

Environment Info :

Windows 8.1
Xamarin.Android : 4.12.5 and 4.12.4
VS 2013
XS 5.0.1.3
Comment 2 Dimitar Dobrev 2014-06-23 13:40:13 UTC
Can be worked around by replacing int[] with IList<int>.
Comment 3 Atsushi Eno 2014-06-25 05:53:34 UTC
So far it is due to Java Generics related limitation (last one at http://developer.xamarin.com/guides/android/advanced_topics/limitations/ )

Android.Widget.ArrayAdapter<T> is not really a true binding for android.widget.ArrayAdapter<T>. The true binding is Android.Widget.ArrayAdapter, and it basically maps T to Java.Lang.Object. ArrayAdapter<T> is just a workaround to bring some generic ease of use. By its nature, this T has to be either Java.Lang.Object (so that it can be mapped to java.lang.Object as ArrayAdapter's ACW [*1] is defined so) or some special things like collections. Primitive Java types cannot be directly converted to java.lang.Object, hence that Java compiler error is expected.)

Apart from using IList<int>, the more valid-looking way is to use Java.Lang.Integer instead of int.

[*1] http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/android_callable_wrappers/

We may visit this issue later on, but that could bring breaking API changes and we may need to wait for not near future versions.