Test trimmable typemap behavior at runtime - #12512
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e194d3-06ac-4880-be33-40e8b6c266b3
The on-device constructor activation suite covers parameterless, primitive, object, array, and mixed Java-to-managed constructor dispatch under both trimmable runtimes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e194d3-06ac-4880-be33-40e8b6c266b3
Exercise modern boolean callback returns and constructed generic base callbacks through Java and JNI instead of inspecting emitted member references. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e194d3-06ac-4880-be33-40e8b6c266b3
Cover static exports and primitive and object ExportField initialization at runtime, and rely on existing device tests for instance export dispatch and exception routing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e194d3-06ac-4880-be33-40e8b6c266b3
Exercise generated alias groups with Java-created ArrayList handles and verify Java.Interop-style activation through a Java-owned peer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e194d3-06ac-4880-be33-40e8b6c266b3
Keep focused coverage for constructed generic callback references and instance ExportField Java generation, which runtime tests cannot establish. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e194d3-06ac-4880-be33-40e8b6c266b3
c6a55be to
7be5748
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the trimmable typemap test strategy by shifting from build-time IL/metadata inspection toward end-to-end device/runtime coverage where JNI/Java↔managed behavior is directly observable, while retaining focused generator/scanner/model contract tests.
Changes:
- Adds new device/runtime tests for boolean callback ABI (
OnLongClick), static[Export]dispatch, static[ExportField]visibility, alias-group target-hint selection, and Java.Interop-style activation. - Extends an existing
AbsListViewJNI invocation test to coverAdapterView.setSelectionoverriding behavior. - Simplifies and refocuses generator tests by removing proxy/activation/export IL-shape assertions and keeping targeted signature/contract checks.
Show a summary per file
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/java/net/dot/android/test/TrimmableRuntimeJavaInteropPeer.java | Adds a Java-side peer used for Java-created handle activation coverage. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapRuntimeCoverageTests.cs | Adds runtime coverage for long-click boolean ABI, alias groups, and Java.Interop-style activation. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ExportTests.cs | Adds runtime tests for static [Export] invocation and static [ExportField] visibility via JNI. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Android.Widget/AdapterTests.cs | Extends JNI-based adapter test to exercise setSelection virtual dispatch into managed override. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TypeMapAssemblyGeneratorTests.cs | Removes broad proxy/activation/export IL inspections; keeps narrower generic callback signature assertions. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/RootTypeMapAssemblyGeneratorTests.cs | Removes a now-redundant PE validity test. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/ExportFieldTests.cs | Narrows generator coverage to scanner/model + instance field generation contract assertions. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
✅ LGTM
No blocking issues found. The runtime tests cover the observable behavior formerly checked through emitted IL/metadata, while focused generator contracts remain in place.
Findings: 0 errors · 0 warnings · 1 suggestion
CI is green: all 44 checks passed, including Azure DevOps dotnet-android build #1567349.
Generated by Android PR Reviewer for #12512 · gpt56 · 196.5 AIC · ⌖ 19.4 AIC · ⊞ 25.7K
Comment /review to run again
| var method = JNIEnv.GetMethodID (listener.Class.Handle, "onLongClick", "(Landroid/view/View;)Z"); | ||
| var handled = JNIEnv.CallBooleanMethod (listener.Handle, method, new JValue (view.Handle)); | ||
|
|
||
| Assert.IsTrue (handled); |
There was a problem hiding this comment.
🤖 💡 Testing — Please exercise both true and false return values here. This runtime test replaces the removed generator-level boolean ABI assertion, but the hard-coded true path would not catch a callback that incorrectly marshals every result as JNI true. Parameterizing the listener's return value would verify both directions of the managed bool → JNI jboolean conversion.
Summary
ExportFieldvalues, alias groups, and Java.Interop-style activationExportFieldJava generationMigration
Constructors
The existing
ConstructorActivationTestsandJnienvTestdevice tests already cover parameterless, primitive, string, object, array, nested-array, and mixed Java-to-managed constructor activation under both CoreCLRTrimmable and NativeAOT. The corresponding emitted-IL assertions were removed.Callbacks
View.IOnLongClickListener.OnLongClickfrom Java to cover the modern JNI boolean ABIAbsListViewruntime test to invokeAdapterView.setSelectionMemberRefencodingExports
[Export]throughGetStaticMethodIDandCallStaticIntMethod[ExportField]values through JNIExportFieldJava generationProxy resolution
java/util/ArrayListalias group contains bothJavaListandJavaList<>ArrayListhandles using generic and non-generic target hints(ref JniObjectReference, JniObjectReferenceOptions)constructorResult
Fact/Theorymethods remain in the standalone project for build-time behavior that runtime tests cannot establishTest plan
dotnet test tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.csproj -v minimalMono.Android.NET-Testsdevice lanes should exercise the new runtime tests in CI