Skip to content

[TrimmableTypeMap] Trim value-type set instantiations - #12801

Draft
simonrozsival wants to merge 3 commits into
simonrozsival-javacollection-typemap-universefrom
simonrozsival-javaset-typemap-universe
Draft

simonrozsival wants to merge 3 commits into
simonrozsival-javacollection-typemap-universefrom
simonrozsival-javaset-typemap-universe

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • add a conditional external typemap universe for all 18 primitive and nullable Android.Runtime.JavaSet<T> instantiations
  • keep the JavaSet universe, TypeMapping call, converter leaves, direct activation interception, and root discovery edge NativeAOT-only so they are fully trimmed from CoreCLR
  • activate NativeAOT reference-type JavaSet<T> through a rooted JavaSet<IJavaPeerable> canonical template
  • preserve CoreCLR concrete JavaSet<T> reflection and unsupported-value behavior
  • keep ICollection<T> in the existing JavaCollection<T> universe because the target interface does not distinguish Java sets from other Java collections

Stack layer 4 above #12800. Base: simonrozsival-javacollection-typemap-universe at 54acba5784623ad6dbb30e62f7dc13b01b20bf1a. This PR contains only the JavaSet-specific delta. Stack metadata was not modified.

APK size

Identical unsigned Release android-arm64 MAUI APKs using the trimmable typemap. The previous layer is updated #12800; stack base is the exact main parent of #12793.

Runtime Previous #12800 This PR Change vs previous Stack base Change vs base
NativeAOT 13,372,429 B 13,376,698 B +4,269 B (+0.032%) 14,180,177 B -803,479 B (-5.666%)
CoreCLR 18,032,035 B 18,031,968 B -67 B (-0.000%) 18,032,646 B -678 B (-0.004%)

NativeAOT lib/arm64-v8a/libNativeAotSize.so uncompressed size: 21,471,016 B. The tiny CoreCLR byte variance is packaging noise; focused linked-output validation confirms the generated CoreCLR root has no dictionary/list/collection/set built-in edges and linked Mono.Android.dll has no value-type universe factory symbols.

Validation

  • Microsoft.Android.Sdk.TrimmableTypeMap.Tests: 1,006 passed
  • Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests: 44 passed
  • Mono.Android.csproj build: succeeded
  • focused ReleaseTrimmableTypeMap_BuiltInCollectionUniversesAreNativeAotOnly: 2 passed (CoreCLR has zero built-in edges/symbols; NativeAOT retains all four)
  • CoreCLR trimmable device category: 32 passed
  • NativeAOT trimmable device category: 26 passed, 6 expected unsupported-reflection skips
  • identical MAUI NativeAOT and CoreCLR publishes: succeeded

simonrozsival and others added 3 commits September 15, 2026 23:59
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the simonrozsival-javaset-typemap-universe branch from 1c79827 to 81986c9 Compare September 15, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant