Remove legacy native typemap runtime support - #12890
simonrozsival wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved callable-wrapper, benchmark/AOT profile, and runtime-linking test issues remain.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
This pull request removes legacy CLR native typemap and marshal-method runtime support, making the managed trimmable typemap the CoreCLR/NativeAOT path.
Changes:
- Removes legacy typemap, reflection activation, Java activation, and native build support.
- Updates startup, configuration, runtime linking, packaging, tests, and documentation.
- Retains trimmable typemap registration and runtime bookkeeping.
| File | Summary |
|---|---|
tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/TestInstrumentation.cs |
Updates runtime test exclusions. |
tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.Net/TrustManagerMarshallingTests.cs |
Removes legacy feature gating. |
tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj |
Removes obsolete activation tests. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapTypeManagerTests.cs |
Makes trimmable typemap tests unconditional. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapRuntimeCoverageTests.cs |
Removes obsolete feature checks. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ManagedObjectProxyTests.cs |
Retains trimmable proxy behavior. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs |
Updates activation documentation. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JavaConvertTest.cs |
Removes obsolete typemap gating. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/InvokerActivationTests.cs |
Removes legacy gating. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ExportTests.cs |
Removes legacy export-path gating. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ConstructorActivationTests.cs |
Removes reflection activation tests. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ActivationConstructorCacheTests.cs |
Deletes obsolete cache tests. |
tests/Mono.Android-Tests/Mono.Android-Tests/Android.Runtime/JnienvArrayMarshaling.cs |
Removes legacy path assumptions. |
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets |
Replaces marshal-method wiring with runtime-linking generation. |
src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsNativeAssemblyGenerator.cs |
Deletes the obsolete generator. |
src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs |
Removes obsolete configuration fields. |
src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs |
Updates application configuration layout. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs |
Updates configuration parsing expectations. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LlvmIrGeneratorTests.cs |
Removes obsolete generator coverage. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/GenerateNativeApplicationConfigSourcesTests.cs |
Verifies removed configuration symbols. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs |
Removes legacy typemap assertions. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs |
Removes obsolete timestamp checks. |
src/Xamarin.Android.Build.Tasks/Tasks/PrepareAbiItems.cs |
Removes marshal-method handling. |
src/Xamarin.Android.Build.Tasks/Tasks/GenerateNativeRuntimeLinkingSources.cs |
Adds dedicated P/Invoke preservation generation. Nit (1 vote): add focused output coverage. |
src/Xamarin.Android.Build.Tasks/Tasks/GenerateNativeMarshalMethodSources.cs |
Deletes the obsolete task. |
src/Xamarin.Android.Build.Tasks/Tasks/GenerateNativeApplicationConfigSources.cs |
Removes obsolete startup tokens. |
src/Xamarin.Android.Build.Tasks/Tasks/GenerateEmptyTypemapStub.cs |
Deletes native typemap stub generation. |
src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs |
Removes legacy typemap bundle handling. |
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets |
Removes native typemap target wiring. |
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets |
Removes the obsolete runtime switch. |
src/native/nativeaot/include/runtime-base/internal-pinvokes.hh |
Removes legacy typemap exports. |
src/native/nativeaot/host/internal-pinvoke-stubs.cc |
Deletes legacy typemap stubs. |
src/native/common/runtime-base/timing-internal.cc |
Removes typemap timing counters. |
src/native/common/include/managed-interface.hh |
Updates startup arguments. |
src/native/clr/xamarin-app-stub/application_dso_stub.cc |
Removes legacy app-DSO symbols. |
src/native/clr/pinvoke-override/precompiled.cc |
Removes obsolete symbol resolution. |
src/native/clr/include/xamarin-app.hh |
Updates native configuration declarations. |
src/native/clr/include/runtime-base/internal-pinvokes.hh |
Removes legacy declarations. |
src/native/clr/include/host/typemap.hh |
Deletes the legacy typemap interface. |
src/native/clr/include/host/host.hh |
Removes obsolete registration state. |
src/native/clr/host/typemap.cc |
Deletes the native typemap implementation. |
src/native/clr/host/internal-pinvokes-shared.cc |
Removes the typemap include. |
src/native/clr/host/internal-pinvokes-clr.cc |
Removes typemap P/Invoke implementations. |
src/native/clr/host/host.cc |
Simplifies startup and registration. |
src/native/clr/host/CMakeLists.txt |
Removes typemap compilation. |
src/Mono.Android/Mono.Android.csproj |
Removes the reflection value manager. Critical (1 vote): the default XAJavaInterop1 callable-wrapper path still references mono.android.TypeManager.Activate. |
src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapValueManager.cs |
Updates trimmable activation errors. |
src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMap.cs |
Simplifies initialization diagnostics. |
src/Mono.Android/Microsoft.Android.Runtime/RuntimeFeature.cs |
Removes obsolete feature switches. |
src/Mono.Android/Microsoft.Android.Runtime/JavaMarshalValueManager.cs |
Deletes reflection-backed value management. |
src/Mono.Android/java/mono/android/TypeManager.java |
Deletes legacy Java activation registration. |
src/Mono.Android/Java.Interop/TypeManager.cs |
Removes legacy activation and native typemap lookup. Moderate (1 vote): update or remove the benchmark resolving deleted CreateProxy; regenerate and commit both default AOT profile artifacts containing stale legacy entries. |
src/Mono.Android/Java.Interop/JavaConvert.cs |
Makes trimmable conversion paths unconditional. |
src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs |
Removes legacy typemap P/Invokes. |
src/Mono.Android/Android.Runtime/JNIEnvInit.cs |
Makes trimmable managers and registration unconditional. |
src/Mono.Android/Android.Runtime/JNIEnv.cs |
Removes native typemap lookup. |
src/Mono.Android/Android.Runtime/AndroidRuntime.cs |
Removes reflection-backed runtime managers. |
src/Microsoft.Android.Sdk.ILLink/PreserveLists/Mono.Android.xml |
Removes obsolete preservation entries. |
src/Microsoft.Android.Runtime.NativeAOT/Java.Interop/JreRuntime.cs |
Uses trimmable value management. |
src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs |
Updates manager initialization. |
Documentation/guides/internals/JavaJNI_Interop.md |
Marks the legacy pipeline historical. |
Documentation/guides/app-bundles.md |
Removes legacy typemap bundle entries. |
| @@ -367,7 +367,6 @@ | |||
| <Compile Include="Microsoft.Android.Runtime\ITypeMap.cs" /> | |||
| <Compile Include="Microsoft.Android.Runtime\JniRemappingLookup.cs" /> | |||
| <Compile Include="Microsoft.Android.Runtime\JavaMarshalRegisteredPeers.cs" /> | |||
20e8350 to
cfeefee
Compare
76d8591 to
f38be86
Compare
e74f5de to
bd99358
Compare
62d9032 to
2fccae2
Compare
2fccae2 to
01bb1a7
Compare
01bb1a7 to
046c6e6
Compare
57df1fc to
710fbc0
Compare
710fbc0 to
e03abb7
Compare
Stacked on #12887; **base: `simonrozsival-default-trimmable-typemap`**. ## Summary - Remove the obsolete llvm-ir typemap targets and generators, native typemap output, marshal-method assembly rewriting, legacy Java-stub tasks, and dead after-link chain. Keep shared application configuration, NativeAOT bootstrap, Java remapping, and the empty native symbols still required until #12890. - Preserve the trimmable build behavior previously mixed into #12887 as six separate, scoped commits: CoreCLR additional process providers; pre-ILLink abstract-method repair on project-local assembly copies; effective-RID post-trim JCW selection and Proguard inputs; typemap assembly metadata and FastDeploy preference for linked/ReadyToRun DLLs; Java-library categorization before nested D8; and the deserialization callback trimmer root. - Keep the shared post-ILLink steps, `LinkDescription`, `LinkerDumpDependencies`, and incremental file tracking. Reject `AndroidEnableMarshalMethods=true` with `XA1049` rather than accepting an unsupported path. The default property and `XA4265` validation remain in the small bottom PR. JVM-only test cleanup is in #12894; this PR does not replay the old bottom branch's broad CI and test-fixture changes. ## Validation - 1,025 standalone trimmable typemap tests and 11 focused build-task tests passed (7 fixture-dependent cases skipped); the FastDeploy task project built without warnings or errors. - Changed XML and the target dependency graph were checked, as was the diff. - Full build-task, host, and device integration tests could not run here without the built in-tree Android SDK and generated `generator.dll`; CI must validate the combined path.
Consolidate the runtime cleanup onto the merged typemap pipeline. Preserve the new JNI remapping startup data, filter framework P/Invokes before ABI indexing, and keep the runtime-linking regression tests. Remove the duplicated application-config test that blocked CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the obsolete activation-cache benchmark and now-empty native P/Invoke translation units. Update newly merged peer-identity, JNI-remapping, and incremental-build tests to use the unconditional trimmable runtime and the reduced application config. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
6a51f54 to
40bec60
Compare
Remove the no-op Runtime.register JNI shim, obsolete startup fields and state, unused config tokens and remapping counters, and their build-time plumbing. Preserve live exception propagation, class-name lookup, and JNI remapping data. Update the config parser and regression coverage, and remove the dead marshal compile switch, trace enums, TimeZone cache, test matrix, and XA0002 resources. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@dalexsoto review |
Retain the GC bridge bootstrap in CoreCLR and NativeAOT startup, assert its presence after linking, and refresh Release APK size baselines for the legacy runtime removal. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
dalexsoto
left a comment
There was a problem hiding this comment.
The complete 87-file/current-hunk review, separate material replacement/integration pass and final independent sweep leave one current test blocker. The GC-bridge initialization and unsupported-JVM-fixture corrections are fixed in current source; the intentional legacy typemap/platform-JCW compatibility removal remains accepted.
Make the R8 exception-peer assertion runtime-specific (BuildTest2.cs:1609-1621). BuildProguardEnabledProject requires Landroid/runtime/JavaProxyThrowable; for both runtimes. After removing mono.android.jar, NativeAOT retains application/framework JCWs according to ILC reachability; this app does not retain that otherwise-unused platform peer. Its supported exception dispatch instead uses net/dot/jni/internal/JavaProxyThrowable, supplied by the trimmable runtime jar and covered by the net.dot.jni.** keep rule.
Actual existing CI build1622337 fails this exact DEX assertion in both NativeAOT variants: run44954574/result100148 (android-arm64) and run44954602/result100173 (emptyRID). CI uses merge 36f92ba, not the exact head tree; the failed test is byte-identical to this head and the relevant runtime/retention sources were reconciled. These are source-related test expectations, not infrastructure failures.
Keep the CoreCLR assertion and validate NativeAOT's actual exception peer in its branch. Restoring the legacy jar or activation path is unnecessary. No additional high-confidence blocker remained. This combines immutable source/contract proof and observed existing CI results, not locally executed builds/device tests or a green-pipeline claim.

Summary
Remove the obsolete native typemap and reflection-backed activation path now that the managed trimmable typemap is the supported CoreCLR/NativeAOT runtime path. This removes compatibility stubs and duplicated build/runtime machinery that no longer serve applications.
main.mono.android.jar/mono.android.dextargeting-pack entries. Binding and application Javac usejava_runtime_trimmable.jar; application builds generate framework JCWs through the trimmable typemap.GenerateNativeRuntimeLinkingSourcestask, including the framework-only filtering fix and its multi-ABI/duplicate-assembly regression tests.The prerequisite #12889 has merged. This PR now targets
mainand is rebased onto4126afa379785ba94bd951586d9e05f4658f8262, with the cleanup history consolidated as requested.Compatibility
Third-party Java sources importing legacy platform JCW implementation classes from
mono.android.jarno longer resolve those classes during standalone binding compilation. Framework JCWs are generated and compiled per application. This removal is intentional;TypeManager.Activateand reflection-backed activation are not restored. The public explicit type-registration shim is retained but throwsNotSupportedException; Java peer types must use[Register].Validation
dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -v minimal --filter 'FullyQualifiedName~TrimmableTypeMap|FullyQualifiedName~GenerateTrimmableTypeMap|FullyQualifiedName~ExtractTypeMapKeys'— passed: 31 tests, 7 skipped.dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --no-restore -v minimal— passed: 60 tests, 7 skipped. The skipped tests require a locally built Mono.Android assembly.JAVA_HOME=$(/usr/libexec/java_home) && clang++ -std=c++20 -fsyntax-only -DDEBUG -Duint=uint32_t -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -Isrc/native/clr/include -Isrc/native/common/include src/native/clr/xamarin-app-stub/application_dso_stub.cc && clang++ -std=c++20 -fsyntax-only -DRELEASE -Duint=uint32_t -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -Isrc/native/clr/include -Isrc/native/common/include src/native/clr/xamarin-app-stub/application_dso_stub.cc— passed. These are host syntax checks, not Android ABI builds; the explicituintalias supplies the Android typedef on macOS.git diff origin/main --checkpassed; no unmerged paths or conflict markers remain.Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: