Commit dc07800
authored
[Mono.Android] fix "exception unboxing" for
Context: #10095
After enabling `Java.Interop-Tests.dll` for CoreCLR/NativeAOT,
`Java.InteropTests.JavaExceptionTests.InnerExceptionIsNotAProxy()`
was failing with:
Expected: same as <System.InvalidOperationException: Managed Exception!>
But was: <Java.Interop.JavaProxyThrowable: System.InvalidOperationException: Managed Exception!
This is because `AndroidRuntime.cs` was doing:
if (JNIEnvInit.ValueManager is AndroidValueManager vm) {
return vm.UnboxException (value);
}
And in this case `ManagedValueManager` was being used, and so the
exception would not be "unboxed".
We can fix this by using `JNIEnvInit.ValueManager?.PeekValue()`
instead and the test now passes.
I also noticed that `AndroidValueManager` had code in
`TryUnboxPeerObject()` for:
var proxy = value as Android.Runtime.JavaProxyThrowable;
if (proxy != null) {
result = proxy.InnerException;
return true;
}
return base.TryUnboxPeerObject (value, out result);
While the base class handled `Java.Interop.JavaProxyThrowable`.
This was missing for `ManagedValueManager`, so I added it.ManagedValueManager (#10100)1 parent 463e6da commit dc07800
File tree
2 files changed
+11
-18
lines changed- src/Mono.Android
- Android.Runtime
- Microsoft.Android.Runtime
2 files changed
+11
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | 76 | | |
85 | 77 | | |
86 | 78 | | |
| |||
865 | 857 | | |
866 | 858 | | |
867 | 859 | | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | 860 | | |
878 | 861 | | |
879 | 862 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
287 | 297 | | |
0 commit comments