Uh oh!
There was an error while loading. Please reload this page.
[tests] run Java.Interop-Tests on NativeAOT - #10496
Conversation
In 32fcc8b, I enabled tests related to the "GC Bridge" on NativeAOT, but discovered we still weren't running dotnet/java-interop's tests. Let's enable them. We can also remove `$(DefineConstants)` for `CORECLR` and `NATIVEAOT` as there is nothing using these.
jonathanpeppers
commented
Sep 18, 2025
This one crashes with: |
Context: 869b0e0 The `pinvoke_unreachable` function, when invoked, would log its own source location instead of that of the call site. That's a bit useless in diagnosing issues, so let's improve it by logging the call site location... :)
grendello
commented
Sep 19, 2025
I added the #10502 change to this PR, it should give us better info on which p/invoke was called. |
Context: #10496 (comment) Context: 869b0e0 The `_monodroid_weak_gref_delete` p/invoke wasn't implemented in 869b0e0 as it was thought to be unused. However, the test failure in #10496 shows that it's not true. Bring the `_monodroid_weak_gref_delete` implementation to NativeAOT host from the CoreCLR host.
Context: #10496 (comment) Context: 869b0e0 The `_monodroid_weak_gref_delete` p/invoke wasn't implemented in 869b0e0 as it was thought to be unused. However, the test failure in #10496 shows that it's not true. Bring the `_monodroid_weak_gref_delete` implementation to NativeAOT host from the CoreCLR host.
grendello
commented
Sep 19, 2025
Comitted the change in #10504 to this PR, it implements |
jonathanpeppers
commented
Sep 19, 2025
Now we are beyond the crash, there are test failures that are probably bugs: Seems like some package name or text is missing before the |
Context: #10496 (comment) Context: 869b0e0 The `_monodroid_weak_gref_delete` p/invoke wasn't implemented in 869b0e0 as it was thought to be unused. However, the test failure in #10496 shows that it's not true. Bring the `_monodroid_weak_gref_delete` implementation to NativeAOT host from the CoreCLR host.
Resolve 3 merge conflicts: - internal-pinvokes-clr.cc: accept main's removal of _monodroid_timezone_get_default_id (moved elsewhere) - internal-pinvoke-stubs.cc: accept main's removal of _monodroid_timezone_get_default_id stub - Mono.Android.NET-Tests.csproj: keep PR's removal of CORECLR/NATIVEAOT DefineConstants Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39e3ff3 to
6c349a2CompareThe function already exists with [[maybe_unused]] on from_writable and correctly calls OSBridge with 5 args. The duplicate caused: - redefinition error (same C++ signature) - wrong arg count (OSBridge only takes 5 args, not 6) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Three changes to ManagedTypeManager (the NativeAOT type manager):
1. Add GetStaticMethodFallbackTypesCore override - returns Desugar{name}
and {name}$-CC fallback types for desugared interface static methods.
Fixes: DesugarInterfaceStaticMethod test.
2. Reorder GetTypesForSimpleReference to yield base class results first.
The base JniTypeManager has built-in mappings (java/lang/String to
System.String, java/lang/Float to float?, etc.) that must take priority
over ManagedTypeMapping (which returns Java.Lang.String).
Fixes: GetType, GetTypeSignature, and JavaObjectArray equality tests.
3. Call base.RegisterNativeMembers when methods string is empty, so the
base class can find and invoke [JniAddNativeMethodRegistrationAttribute]
methods. Previously ManagedTypeManager returned early, skipping this.
Fixes: InvokeVirtualFromConstructorTests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>The fallback type must include the \ suffix to match the actual desugared companion class name (e.g. DesugarAndroidInterface\). This matches the pattern used by the Java.Interop test fixture. Fixes DesugarInterfaceStaticMethod test on NativeAOT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds [Category("NativeAOTIgnore")] to InvokeVirtualFromConstructorTests.
Tracking: #10950
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>There was a problem hiding this comment.
Pull request overview
Enables running dotnet/java-interop tests (Java.Interop-Tests) under NativeAOT and adjusts runtime type resolution behavior to support those tests, while simplifying test project build constants.
Changes:
- Always include
Java.Interop-Testsin the runtime test assembly list (removes the NativeAOT exclusion). - Remove now-unneeded
CORECLR/NATIVEAOTDefineConstantsfrom the test project. - Update
ManagedTypeManagertype mapping priority and add fallback type name generation for desugared static methods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs | Runs Java.Interop-Tests on NativeAOT by always including the assembly in instrumentation. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj | Removes unused conditional compilation constants for CORECLR/NATIVEAOT. |
| src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs | Adjusts type-mapping precedence and adds fallback type-name logic for desugared static method resolution. |
| external/Java.Interop | Updates the Java.Interop submodule revision, likely containing fixes needed for NativeAOT test execution. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Replace StringBuilder with simple string interpolation. Also removes unused System.Text using. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In 32fcc8b, I enabled tests related to the "GC Bridge" on NativeAOT, but discovered we still weren't running dotnet/java-interop's tests. Let's enable them.
We can also remove
$(DefineConstants)forCORECLRandNATIVEAOTas there is nothing using these.