Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created March 23, 2012 17:04
Show Gist options
  • Save kumpera/2172800 to your computer and use it in GitHub Desktop.
Save kumpera/2172800 to your computer and use it in GitHub Desktop.
What makes a bridge object?
A bridge object is a bridge class with a non-null handle.
What makes a bridge class?
A bridge class must respect the follow rules:
-Be a subclass of Java.Lang.Object; and
-The Java side has a monodroidAddReference method.
In which cases a bridge class can be ignored as been one?
-It only have value type (eg int) fields; or
-It doesn't have a non-mirrored field that could transitively point to another bridge object.
A mirrored field is a field that exists both in C# and Java and is kept in sync between the two.
Actually, I don't know for sure if we have those.
The transitively points to another bridge object means that another bridge object can be reached
directly or indirectly through that field. Eg, System.Object and Java.Lang.Object do, System.String
doesn't.
@jonpryor
Copy link

"Subclass of Java.Lang.Object" and "has monodroidAddReference method" means "has an Android Callable Wrapper" (ACW): http://docs.xamarin.com/android/advanced_topics/architecture/android_callable_wrappers

For the most part, ACWs are stupid. No field mirroring is performed, no checking of class fields is performed. All the ACW generation mechanism cares about is constructors and methods. This will be changing to partially include fields, via [ExportField]. However, [ExportField does not keep the Java & C# fields in sync; it's an init-only mechanism, in which the Java field is initialized with a C# value. If the C# value changes, the Java value will not.

Thus, in the absence of [ExportField], there will be no bridge classes which have non-mirrored fields. With [ExportField], I believe there still won't be any such classes, as the fields aren't kept in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment