-
Notifications
You must be signed in to change notification settings - Fork 63
[Java.Interop-Tests] Allow consumption by Xamarin.Android #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context: TODO
Allow the Java.Interop unit tests to be consumed by Xamarin.Android.
In particular, this means:
* "Proper" exceptions such as `Java.Lang.ClassNotFoundException` are
thrown, not "based" `JavaException` types.
* `Xamarin.Android.NUnitLite.dll` doesn't provide
`[OneTimeSetUpAttribute]`/etc., so use
`[TestFixtureSetUpAttribute]` instead.
* Xamarin.Android doesn't currently support
`Java.Interop.MarshalMemberBuilder`, so any tests which require it
will not work. "Hide" those behind
`#if !NO_MARSHAL_MEMBER_BUILDER_SUPPORT`.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Jul 26, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * Merge dotnet/java-interop#454 and stop using the jonpryor/Java.Interop/jonp-xa-integration branch. * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Sep 6, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Sep 7, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Sep 9, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Sep 9, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Sep 10, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Sep 11, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Oct 31, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Nov 10, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Nov 13, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Nov 20, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Nov 22, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Nov 27, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Dec 12, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Dec 16, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Dec 17, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
jonpryor
added a commit
to jonpryor/xamarin-android
that referenced
this pull request
Dec 20, 2019
Context: dotnet/java-interop#454 Context: https://github.com/xamarin/monodroid/commit/e318861e Context: dotnet@7d32ef3e6 Context: dotnet@1a2eb95 When use of `Java.Interop.dll` was originally added in xamarin/monodroid@e318861e, it didn't implement the "full" `JniRuntime` abstraction, which meant that until dotnet/android@1a2eb953, trying to instantiate a `JavaInt32Array` instance would result in a `NotImplementedException`, because `Android.Runtime.AndroidValueManager.AddPeer()` threw a `NotImplementedException`. Commit dotnet/android@1a2eb953 removed the exception but didn't *implement* `JniRuntime.JniValueManager.AddPeer()`, meaning even though a `JavaInt32Array` could be *instantiated*, it wouldn't *work* "properly", e.g. `JniRuntime.JniValueManager.PeekPeer()` wouldn't *find* the `JavaInt32Array` when given the same handle. This in turn "happened" because `Mono.Android-Tests.dll` never *executed* the unit tests for `Java.Interop.dll`, which it *couldn't* do, because it didn't fully support the semantics. Add the `Java.Interop.dll` unit tests to `Mono.Android-Tests.dll`, and fix `Mono.Android.dll` and company so that they can actually *pass*: * Add a new `Java.Interop-Tests.csproj` project to "host" the Java.Interop unit tests in a MonoAndroid-profile project. * Add `java-interop.jar` to the `javac` command line generated by `Jar.targets`, so that e.g. `com.xamarin.java_interop.ManagedPeer` can be used. * Update `Mono.Android.dll` so that the Java.Interop unit tests work. This includes "migrating" the (jobject => instance) mapping previously accessible via `Java.Lang.Object.GetObject<T>()` into `Android.Runtime.AndroidValueManager`. * `AndroidRuntime.GetExceptionForThrowable()` will now "unwrap" a `Java.Interop.JavaProxyThrowable` instance. * `AndroidTypeManager.GetSimpleReferences()` can't use `JNIEnv.GetJniName()` because that always returns `java/lang/Object`, even if a type can't be found, which breaks several Java.Interop unit tests. Use `JNIEnv.monodroid_typemap_managed_to_java()` instead. * `AndroidTypeManager.RegisterNativeMembers()` will now invoke `JniRuntime.JniTypeManager.RegisterNativeMembers()` when `methods` is empty, so that classes can handle their own registration. This was needed so that `Java.InteropTests.CallVirtualFromConstructorDerived` could actually be properly instantiated and participate in tests. * `Java.Interop.TypeManager.CreateProxy()` now supports Java.Interop-style `(ref JniObjectReference, JniObjectReferenceOptions)` constructors. * `Java.Interop.JavaObject` and `Java.Interop.JavaException` are now bridgeable types, and can participate in GC's. This means that e.g. `JavaInt32Array` instances won't be prematurely collected. TODO: * `Java.Lang.Object` should be updated to inherit from `Java.Interop.JavaObject` * `Java.Lang.Throwable` should be updated to inherit from `Java.Interop.JavaException` * `generator` needs to be updated to begin *avoiding* the `JNIEnv` methods, so that non-`Java.Lang.*`-inheriting types can be used.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: dotnet/android#3393
Allow the Java.Interop unit tests to be consumed by Xamarin.Android.
In particular, this means:
"Proper" exceptions such as
Java.Lang.ClassNotFoundExceptionarethrown, not "based"
JavaExceptiontypes.Xamarin.Android.NUnitLite.dlldoesn't provide[OneTimeSetUpAttribute]/etc., so use[TestFixtureSetUpAttribute]instead.Xamarin.Android doesn't currently support
Java.Interop.MarshalMemberBuilder, so any tests which require itwill not work. "Hide" those behind
#if !NO_MARSHAL_MEMBER_BUILDER_SUPPORT.