Bug 2358 - OverlayItem inherits System.Object rather than Java.Lang.Object
Summary: OverlayItem inherits System.Object rather than Java.Lang.Object
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL: https://github.com/Cheesebaron/MonoDr...
Depends on:
Blocks:
 
Reported: 2011-12-06 06:49 UTC by Tomasz Cielecki
Modified: 2012-01-05 01:26 UTC (History)
3 users (show)

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

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 INVALID

Description Tomasz Cielecki 2011-12-06 06:49:26 UTC
The OverlayItem in Mono for Android 4.0 is implementing System.Object rather than Java.Lang.Object, which the compiler complains about when trying to implement ItemizedOverlay. The CreateItem method in ItemizedOverlay needs to return a Java.Lang.Object.

If you go to the definition of OverlayItem in VS2010, then you can see that there is a using statement:

using Java.Lang;

and

public class OverlayItem : Object

Object in this case is not Java.Lang.Object but System.Object.



I am using a workaround in my ItemizedOverlay right now, which seems to work fine:

protected override Java.Lang.Object CreateItem(int index)
Comment 1 Tomasz Cielecki 2011-12-06 08:53:58 UTC
You can see a small test project here:
https://github.com/Cheesebaron/MonoDroid.TestOverlayItem
Comment 2 Jonathan Pobst 2011-12-06 10:32:11 UTC
It looks like it may be a generator problem.

ItemizedOverlay has an abstract method "CreateItem(int)" and we don't seem to have that method in our assembly.

monodroid.testoverlayitem.MyItemizedOverlay is not abstract and does not override abstract method createItem(int) in com.google.android.maps.ItemizedOverlay [C:\Users\Jonathan\Desktop\Cheesebaron-MonoDroid.TestOverlayItem-4a801fe\MonoDroid.TestOverlayItem\MonoDroid.TestOverlayItem.csproj]
Comment 3 Tomasz Cielecki 2011-12-06 12:03:07 UTC
In Mono for Android 1.9.2 OverlayItem was explicitly implementing Java.Lang.Object.

Looks like this if you browse the definition of the class: 

    public class OverlayItem : Java.Lang.Object

In 4.0 this changed to

    public class OverlayItem : Object

But because of

    using System;
    using Java.Lang;

in the definition the compiler gets confused.

    CreateItem(int)

does indeed exist in ItemizedOverlay and expects Java.Lang.Object being returned. At least if you look at the definition of ItemizedOverlay you can find:

    [Register("createItem", "(I)Lcom/google/android/maps/OverlayItem;", "GetCreateItem_IHandler")]
    protected abstract Object CreateItem(int i);

So if you ask me the problem is OverlayItem is implementing the wrong Object.
Comment 4 Atsushi Eno 2012-01-05 01:26:24 UTC
There was a duplicate discussion on the mailing list. http://mono-for-android.1047100.n5.nabble.com/New-Mono-for-Android-release-does-not-work-with-some-samples-on-GitHub-td5049372.html

OverlayItem indeed derives from Java.Lang.Object. To avoid confusion between two Object types, see the mailing list discussion above. Maybe using Object = Java.Lang.Object is easier. (But also note that this does not affect our already-compiled Mono.Android.GoogleMaps.dll.)