Commit 7acf328
authored
Bump to dotnet/java-interop@d62008d1 (#9768)
Changes: dotnet/java-interop@57f7bc8...d62008d
* dotnet/java-interop@d62008d1: [Java.Interop] GetSimpleReferences(): fallback for GetTypeSignatures() (dotnet/java-interop#1305)
Context: 25d1f00
If you have a Debug build of .NET for Android, and you enable
assembly logging:
% adb shell setprop debug.mono.log default,assembly
then `adb logcat` will contain messages such as:
I monodroid-assembly: typemap: unable to find mapping to a Java type from managed type 'Java.Interop.ManagedPeer, Java.Interop'
W monodroid: typemap: failed to map managed type to Java type: Java.Interop.ManagedPeer, Java.Interop, Version=10.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 (Module ID
W monodroid-assembly: typemap: called from
W monodroid-assembly: at Android.Runtime.JNIEnv.TypemapManagedToJava(Type type)
W monodroid-assembly: at Android.Runtime.AndroidTypeManager.GetSimpleReference(Type type)
W monodroid-assembly: at Java.Interop.JniRuntime.JniTypeManager.GetTypeSignature(Type type)
W monodroid-assembly: at Java.Interop.JniPeerMembers..ctor(String jniPeerTypeName, Type managedPeerType, Boolean checkManagedPeerType, Boolean isInterface)
W monodroid-assembly: at Java.Interop.JniPeerMembers..ctor(String jniPeerTypeName, Type managedPeerType)
W monodroid-assembly: at Java.Interop.ManagedPeer..cctor()
W monodroid-assembly: at Java.Interop.JniRuntime..ctor(CreationOptions options)
W monodroid-assembly: at Android.Runtime.AndroidRuntime..ctor(IntPtr jnienv, IntPtr vm, IntPtr classLoader, IntPtr classLoader_loadClass, Boolean jniAddNativeMethodRegistrationAttributePresent)
W monodroid-assembly: at Android.Runtime.JNIEnvInit.Initialize(JnienvInitializeArgs* args)
…
I monodroid-assembly: typemap: unable to find mapping to a Java type from managed type 'Java.Interop.JavaObject, Java.Interop'
W monodroid: typemap: failed to map managed type to Java type: Java.Interop.JavaObject, Java.Interop, Version=10.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 (Module ID: 90427bf1-700a-4676-b23a-fb68e2e2e9da; Type token: 33554439)
W monodroid-assembly: typemap: called from
W monodroid-assembly: at Android.Runtime.JNIEnv.TypemapManagedToJava(Type type)
W monodroid-assembly: at Android.Runtime.AndroidTypeManager.GetSimpleReference(Type type)
W monodroid-assembly: at Java.Interop.JniRuntime.JniTypeManager.GetTypeSignature(Type type)
W monodroid-assembly: at Java.Interop.JniPeerMembers..ctor(String jniPeerTypeName, Type managedPeerType, Boolean checkManagedPeerType, Boolean isInterface)
W monodroid-assembly: at Java.Interop.JniPeerMembers..ctor(String jniPeerTypeName, Type managedPeerType)
W monodroid-assembly: at Java.Interop.JavaObject..cctor()
W monodroid-assembly: at Java.Interop.TypeManager.Activate(IntPtr jobject, ConstructorInfo cinfo, Object[] parms)
W monodroid-assembly: at Java.Interop.TypeManager.n_Activate(IntPtr jnienv, IntPtr jclass, IntPtr typename_ptr, IntPtr signature_ptr, IntPtr jobject, IntPtr parameters_ptr)
W monodroid-assembly: at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLLL_V(_JniMarshal_PPLLLL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2, IntPtr p3)
`ManagedPeer` and `JavaObject` are types within `Java.Interop.dll`
which uses `JniPeerMembers`, and [Debug builds of `JniPeerMembers`][0]
try to verify that the typemap entry is consistent:
partial class JniPeerMembers {
JniPeerMembers string jniPeerTypeName, Type managedPeerType, bool checkManagedPeerType, bool isInterface = false)
{
// …
#if DEBUG
var signatureFromType = JniEnvironment.Runtime.TypeManager.GetTypeSignature (managedPeerType);
if (signatureFromType.SimpleReference != jniPeerTypeName) {
Debug.WriteLine ("WARNING-Java.Interop: ManagedPeerType <=> JniTypeName Mismatch! javaVM.GetJniTypeInfoForType(typeof({0})).JniTypeName=\"{1}\" != \"{2}\"",
managedPeerType.FullName,
signatureFromType.SimpleReference,
jniPeerTypeName);
Debug.WriteLine (new System.Diagnostics.StackTrace (true));
}
#endif // DEBUG
}
}
However, `Java.Interop.dll` is not considered to be a .NET for Android
assembly, as it's built with e.g. `$(TargetFramework)=net9.0` and not
`$(TargetFramework)=net9.0-android`. As such, it is skipped during
typemap processing.
Update `XAJavaTypeScanner.SpecialAssemblies` so that `Java.Interop.dll`
is explicitly processed. This will ensure that there is a typemap
entry for `ManagedPeer` and that the `JniPeerMembers` checks pass.
This allows typemap entries for `JavaObject` and `ManagedPeer` to be
created, removing the above warning messages.
This also requires updating `XAJavaTypeScanner.GetJavaTypes()` so
that in Debug builds, `Mono.Android.dll` is processed *before* any
other assemblies, ensuring that `java/lang/Object` is typemap'd to
`Java.Lang.Object, Mono.Android.dll`. See also 25d1f00, which did
the same thing for *Release* builds.
Add a new `ObjectTest.java_lang_Object_Is_Java_Lang_Object()` unit
test which explicitly verifies the mapping for `java/lang/Object`.
[0]: https://github.com/dotnet/java-interop/blob/6bc87e8b55bc00ae1423a5ae92cf5db573fc76ed/src/Java.Interop/Java.Interop/JniPeerMembers.cs#L45-L541 parent c7f9f5c commit 7acf328
File tree
4 files changed
+35
-20
lines changed- external
- src/Xamarin.Android.Build.Tasks
- Tests/Xamarin.ProjectTools/Resources/Base
- Utilities
- tests/Mono.Android-Tests/Java.Lang
4 files changed
+35
-20
lines changedLines changed: 13 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
86 | 96 | | |
87 | 97 | | |
88 | 98 | | |
| |||
0 commit comments