You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: dotnet/android#8751
Context: 56b7eeb
Context: 67c079cdotnet/android#8751 attempts to figure out how Java.Interop
broke xamarin-android. That investigation eventually resulted in
67c079c, which allowed xamarin-android to *build* again, and
uncovered a unit test failure.
[`JnienvTest.NewObjectArrayWithNonJavaTypeAndEmptyArray()`][0]:
[Test]
public void NewObjectArrayWithNonJavaTypeAndEmptyArray ()
{
//empty array gives the right type
var array = JNIEnv.NewObjectArray<Type> (new Type [0]);
…
}
started failing:
Java.Lang.ClassNotFoundException : crc64d04135c992393d83.Type
----> Java.Lang.ClassNotFoundException : Didn't find class "crc64d04135c992393d83.Type" on path: DexPathList[[zip file "/data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/base.apk", zip file "/data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/split_config.x86_64.apk", zip file "/data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/lib/x86_64, /data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/base.apk!/lib/x86_64, /data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/split_config.x86_64.apk!/lib/x86_64, /data/app/Mono.Android.NET_Tests-VrfrXDHT2r32zDG95kFOiw==/split_config.xxhdpi.apk!/lib/x86_64, /system/lib64, /system/product/lib64]]
It turns out, this type is completely wrong? It should be looking
for `java/lang/Object` instead?
In 56b7eeb, we lost an important detail from the expression:
// 56b7eeb^
if (!type.GetInterfaces ().Any (t => t.FullName == "Android.Runtime.IJavaObject")) …
// 56b7eeb equivalent:
if (type.GetInterfaces ().Any (t => t.FullName == "Java.Interop.IJavaPeerable")) …
We are missing the `!` !!!
I was able to reproduce this behavior in a test:
[Test]
[TestCase (typeof (System.Type), "java/lang/Object")]
public void ToJniName (Type type, string expected)
{
string actual = JavaNativeTypeManager.ToJniName (type);
Assert.AreEqual (expected, actual);
}
Where `ToJniName()` was returning `crc64d04135c992393d83/Type` instead
of `java/lang/Object`!
After fixing the problem, the test passes.
[0]: https://github.com/xamarin/xamarin-android/blob/0665f449948c43675ec8706a5a2807b5d3f599f7/tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs#L178-L186
Copy file name to clipboardExpand all lines: tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/JavaNativeTypeManagerTests.cs
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -55,5 +55,14 @@ public void LowercaseWithAssemblyName ()
0 commit comments