Bug 6085 - Unify Java.Lang.Object and System.Object
Summary: Unify Java.Lang.Object and System.Object
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.2.x
Hardware: PC Mac OS
: Low enhancement
Target Milestone: master
Assignee: Jonathan Pryor
Depends on:
Reported: 2012-07-11 16:26 UTC by Jonathan Pryor
Modified: 2016-09-02 21:11 UTC (History)
4 users (show)

Tags: XATriaged
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 for Bug 6085 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Jonathan Pryor 2012-07-11 16:26:48 UTC
Context: http://mono-for-android.1047100.n5.nabble.com/Type-systems-java-lang-Object-and-System-Object-tp5710827.html

Scenario: Many people want to use the Android.Views.View.Tag property to tie the UI to a "model" object, and the "model" object shouldn't be tied to the implementation framework. That is, instead of the current:

    public Java.Lang.Object Tag {get; set;}

they want:

    public object Tag {get; set;}

Most/all method return values and parameters could make use of similar treatment: use System.Object instead of Java.Lang.Object.

The reason this previously wasn't done was because it was felt that it would be beneficial making gref creation explicit, so that the gref count can be more easily reasoned about. In practice, this is bunk, as we provide a variety of methods which will happily implicitly wrap non-Java.Lang.Object types into an internal Java.Lang.Object wrapper:

    var items = new JavaList<object> ();
    items.Add (new List<int> {1, 2, 3, 4}); // implicitly wraps!

The proper solution for tracking grefs is twofold:

1. Provide better tooling for tracking them. gref logging is a start:


2. (Long-term) Rework the GC system so that grefs aren't as widely used, making gref lifetime less problematic.

NOTE: the s/Java.Lang.Object/object/g change described here would be a (large!) API break. It will not happen before 5.0 or later (some major version change). The 4.x series WILL maintain backward compatibility.