Commit f45700f
authored
Bump to dotnet/java-interop@9dea87dc; FindClass & TypeManager (#9812)
Changes: dotnet/java-interop@f30e420...9dea87d
* dotnet/java-interop@9dea87dc: [Java.Interop] .GetTypeSignature() supports unsigned types (dotnet/java-interop#1312)
* dotnet/java-interop@1cfb4f4d: [generator] Add support for emitting `[UnsupportedOSPlatform]` (dotnet/java-interop#1307)
Context: #9811
The .NET MAUI template + NativeAOT currently crashes with:
E AndroidRuntime: net.dot.jni.internal.JavaProxyThrowable: System.InvalidProgramException: InvalidProgram_Specific, IntPtr Android.Runtime.JNIEnv.monodroid_typemap_managed_to_java(System.Type, Byte*)
E AndroidRuntime: at Internal.Runtime.TypeLoaderExceptionHelper.CreateInvalidProgramException(ExceptionStringID, String) + 0x4c
E AndroidRuntime: at Android.Runtime.JNIEnv.monodroid_typemap_managed_to_java(Type, Byte*) + 0x18
E AndroidRuntime: at Android.Runtime.JNIEnv.TypemapManagedToJava(Type) + 0x104
E AndroidRuntime: at Android.Runtime.JNIEnv.GetJniName(Type) + 0x1c
E AndroidRuntime: at Android.Runtime.JNIEnv.FindClass(Type) + 0x38
E AndroidRuntime: at Android.Runtime.JNIEnv.NewArray(IJavaObject[]) + 0x28
E AndroidRuntime: at Android.Runtime.JNIEnv.NewArray[T](T[]) + 0x94
E AndroidRuntime: at Android.Graphics.Drawables.LayerDrawable..ctor(Drawable[] layers) + 0xd4
E AndroidRuntime: at Microsoft.Maui.Platform.MauiRippleDrawableExtensions.UpdateMauiRippleDrawableBackground(View, Paint, IButtonStroke, Func`1, Func`1, Action) + 0x2ac
This appears to be related to array usage, such as
`LayerDrawable.ctor(Drawable[])` in this example.
I can reproduce the same crash using a
`ColorStateList.ctor(int[][], int[])` in `samples/NativeAOT`:
E AndroidRuntime: net.dot.jni.internal.JavaProxyThrowable: System.InvalidProgramException: InvalidProgram_Specific, IntPtr Android.Runtime.JNIEnv.monodroid_typemap_managed_to_java(System.Type, Byte*)
E AndroidRuntime: at Internal.Runtime.TypeLoaderExceptionHelper.CreateInvalidProgramException(ExceptionStringID, String) + 0x4c
E AndroidRuntime: at Android.Runtime.JNIEnv.monodroid_typemap_managed_to_java(Type, Byte*) + 0x18
E AndroidRuntime: at Android.Runtime.JNIEnv.TypemapManagedToJava(Type) + 0x104
E AndroidRuntime: at Android.Runtime.JNIEnv.GetJniName(Type) + 0x1c
E AndroidRuntime: at Android.Runtime.JNIEnv.FindClass(Type) + 0x38
E AndroidRuntime: at Android.Runtime.JNIEnv.NewArray[T](T[]) + 0xa8
E AndroidRuntime: at Android.Content.Res.ColorStateList..ctor(Int32[][], Int32[]) + 0xdc
E AndroidRuntime: at NativeAOT.MainActivity.OnCreate(Bundle savedInstanceState) + 0xb8
Update `JNIEnv.FindClass(Type)` to go through `TypeManager` instead
of using `TypemapManagedToJava`. This avoids the P/Invoke which is
causing the crash (f800c1a).
Note that we can't directly use
`JniRuntime.JniTypeManager.GetTypeSignature()`, as the previous use
of `JavaNativeTypeManager.ToJniName(Type)` would default to using
`java/lang/Object` if there was no typemap entry for `type`.
After this change, the sample works and prints a log message
indicating `ColorStateList` is created successfully:
D NativeAOT: MainActivity.OnCreate() ColorStateList: ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[0, 1]]mColors=[0, 1]mDefaultColor=0}1 parent 32c8bf6 commit f45700f
File tree
3 files changed
+16
-2
lines changed- external
- samples/NativeAOT
- src/Mono.Android/Android.Runtime
3 files changed
+16
-2
lines changedSubmodule Java.Interop updated 13 files
- src/Java.Interop/Java.Interop/JniBuiltinMarshalers.cs+4-3
- src/Java.Interop/Java.Interop/JniBuiltinMarshalers.tt+18-14
- src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs+2-2
- tests/Java.Interop-Tests/Java.Interop/JniTypeManagerTests.cs+11-3
- tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs+30
- tests/generator-Tests/Unit-Tests/XmlApiImporterTests.cs+9
- tools/generator/ApiVersionsSupport.cs+1
- tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs+7-1
- tools/generator/Java.Interop.Tools.Generator.ObjectModel/Field.cs+1
- tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs+2
- tools/generator/Java.Interop.Tools.Generator.ObjectModel/MethodBase.cs+1
- tools/generator/SourceWriters/Attributes/UnsupportedOSPlatformAttr.cs+21
- tools/generator/SourceWriters/Extensions/SourceWriterExtensions.cs+15-3
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
260 | 269 | | |
261 | 270 | | |
262 | 271 | | |
| |||
0 commit comments