[tests] run Java.Interop-Tests on NativeAOT#10496
Merged
jonathanpeppers merged 10 commits intomainfrom Mar 16, 2026
Merged
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.
Member
Author
|
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... :)
Contributor
|
I added the #10502 change to this PR, it should give us better info on which p/invoke was called. |
grendello
added a commit
that referenced
this pull request
Sep 19, 2025
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.
Contributor
|
Comitted the change in #10504 to this PR, it implements |
Member
Author
|
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 |
jonathanpeppers
pushed a commit
that referenced
this pull request
Sep 19, 2025
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.
26 tasks
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
6c349a2
Compare
The 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>
Contributor
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. |
Replace StringBuilder with simple string interpolation. Also removes unused System.Text using. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.