Bug 1521 - Provide an easier way to get a Object[] from Java.Lang.Object
Summary: Provide an easier way to get a Object[] from Java.Lang.Object
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 1.0
Hardware: Macintosh Mac OS
: --- enhancement
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-10-16 16:50 UTC by Chris Hardy [MSFT]
Modified: 2011-11-04 10:25 UTC (History)
2 users (show)

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:

Description Chris Hardy [MSFT] 2011-10-16 16:50:28 UTC
It would be nice to be able to cast out a Object[] from an Java.Lang.Object.

This is useful for when getting an object array for a broadcast receiver for SMS messages.

var pdus = bundle.Get ("pdus");
Java.Lang.Object[] castedPdus = JNIEnv.GetArray<Java.Lang.Object>(pdus.Handle);

if the work around for something that should be simpler like
var pdus = (object[]) bundle.Get ("pdus");

This is used to port over this example: https://gist.github.com/d698d4f309a8c69c288a
Comment 1 Jonathan Pryor 2011-11-04 10:25:47 UTC
Fixed in 3cde304a, though the cast isn't to `object[]` (i.e. System.Object[]), but to Java.Lang.Object[]:

    var pdus = (Java.Lang.Object[]) bundle.Get("pdus");

See also Bug #1521.
Comment 2 Jonathan Pryor 2011-11-04 10:25:57 UTC
Er, bug #1522.