Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mono.Android] Make TypeManager a normal Java.Lang.Object (#1537)
Context: https://github.com/xamarin/xamarin-android/projects/1 The idea: use `jnimarshalmethod-gen.exe` to generate *JNI Marshal Methods* at packaging time, so that we can avoid using as much reflection for method registration, and *entirely avoid* using `System.Reflection.Emit` for marshal method registration. The problem: The Java type `mono.android.TypeManager` is Just Like every other `Java.Lang.Object` C# subclass, in that it's a Java `native` method that is registered with a C# delegate via `JNIEnv.RegisterJniNatives()`. *Unlike* every other `Java.Lang.Object` subclass, it wasn't actually a `Java.Lang.Object` subclass. It Just Happened To Work because it `JNIEnv.RegisterJniNatives()` used Reflection to find the registration methods/etc., but it was otherwise "unique". Being unique was fine, but in our desired new `jnimarshalmethod-gen.exe` World Order™, being unique *isn't* fine; it means it won't participate in packaging-time marshal method generation, thus requiring use of `System.Reflection.Emit`, which is undesirable. Add a new internal `Java.Interop.TypeManager.JavaTypeManager` type to use as the C# peer for `mono.android.TypeManager`, make `TypeManager.JavaTypeManager` a normal `Java.Lang.Object` subclass, then update `mono.android.TypeManager` to register `Java.Interop.TypeManager+JavaTypeManager`. This removes the "uniqueness" of `mono.android.TypeManager`, allowing it to be processed normally by `jnimarshalmethod-gen.exe`.
- Loading branch information