Skip to content

[TrimmableTypeMap] Use trimmable virtual-constructor fixtures#11274

Draft
simonrozsival wants to merge 1 commit intotrimmable-java-proxy-objectfrom
trimmable-virtual-constructor
Draft

[TrimmableTypeMap] Use trimmable virtual-constructor fixtures#11274
simonrozsival wants to merge 1 commit intotrimmable-java-proxy-objectfrom
trimmable-virtual-constructor

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented May 3, 2026

Re-enables Java.InteropTests.InvokeVirtualFromConstructorTests for the CoreCLR trimmable typemap lane.

This swaps the incompatible Java.Interop desktop-JVM fixtures for Android-owned trimmable copies that use generated n_* callbacks and register those callbacks through mono.android.Runtime.registerNatives(Class) instead of ManagedPeer.registerNativeMembers / ManagedPeer.construct. It also lets the trimmable typemap emit native registrations for hand-written Java peers marked with JniAddNativeMethodRegistrationAttribute.

The trimmable Java fixture calls registerNatives(Class) via reflection because Mono.Android-Test-classes.jar is compiled by build-tools/scripts/Jar.targets with only android.jar and java-interop.jar on the javac classpath. mono.android.Runtime lives in the Android runtime jar/dex, so it is available when the test app runs but not when these Java fixture sources are compiled.

Validation:

  • dotnet build src/Microsoft.Android.Sdk.TrimmableTypeMap/Microsoft.Android.Sdk.TrimmableTypeMap.csproj -v:minimal
  • ANDROID_SERIAL=emulator-5570 MSBUILDDISABLENODEREUSE=1 dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -t:RunTestApp -c Debug -p:_AndroidTypeMapImplementation=trimmable -p:UseMonoRuntime=false -p:TestFixture=Java.InteropTests.InvokeVirtualFromConstructorTests -nr:false -m:1 -v:minimal

Note: local validation used the PR-built Xamarin.Android.Build.Tasks / Microsoft.Android.Sdk.TrimmableTypeMap assemblies in the prepared parent local SDK; those assemblies were restored afterward.

Related issues

@simonrozsival simonrozsival changed the title Use trimmable virtual-constructor fixtures [TrimmableTypeMap] Use trimmable virtual-constructor fixtures May 3, 2026
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels May 3, 2026
@simonrozsival simonrozsival force-pushed the trimmable-java-proxy-object branch from 1467afa to e66930e Compare May 4, 2026 18:21
@simonrozsival simonrozsival force-pushed the trimmable-virtual-constructor branch from 711aeae to 7e2737b Compare May 4, 2026 18:23
Enable the Java.Interop virtual-constructor tests in the trimmable typemap lane by swapping in Android-owned Java fixtures that use Runtime.registerNatives and generated n_* callbacks instead of ManagedPeer.

Teach the trimmable typemap scanner/model to emit native registrations for hand-written Java peers that opt into JniAddNativeMethodRegistrationAttribute.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival force-pushed the trimmable-java-proxy-object branch from e66930e to 0644b70 Compare May 4, 2026 18:31
@simonrozsival simonrozsival force-pushed the trimmable-virtual-constructor branch from 7e2737b to dc13b42 Compare May 4, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot `copilot-cli` or other AIs were used to author this trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant