Skip to content

[TrimmableTypeMap] Use separate trimmable Java.Interop test jar - #11336

Merged
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/fix-javaobjecttest-disposeaccessesthis
May 13, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/fix-javaobjecttest-disposeaccessesthis

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Description

Use a distinct Java.Interop test jar for the trimmable typemap device-test lane.

The trimmable lane swaps in an Android-specific GetThis.java fixture that omits the desktop JVM ManagedPeer.registerNativeMembers() static initializer. Because both trimmable and non-trimmable builds previously wrote Jars/Mono.Android-Test-classes.jar, MSBuild could reuse a stale non-trimmable jar and package the desktop GetThis class, causing JavaObjectTest.DisposeAccessesThis to hit legacy native-member registration under the trimmable typemap.

Testing

  • make prepare && make all
  • dotnet test tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.csproj -v minimal
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~TrimmableTypeMapBuildTests"
  • ./dotnet-local.sh test tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests.csproj -v minimal --no-build
  • ./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -t:RunTestApp -p:_AndroidTypeMapImplementation=llvm-ir -nr:false
  • ./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -t:RunTestApp -p:_AndroidTypeMapImplementation=trimmable -nr:false

Also attempted -p:_AndroidTypeMapImplementation=managed; it failed during build with existing XAGTM7009: Internal error: set of unique assemblies must be provided.

Avoid reusing the non-trimmable Java.Interop test jar when building the Mono.Android device tests with the trimmable typemap. The shared jar output could leave the desktop GetThis fixture in place, causing DisposeAccessesThis to hit legacy native-member registration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 13, 2026 11:42
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels May 13, 2026
@simonrozsival simonrozsival changed the title Use separate trimmable Java.Interop test jar [TrimmableTypeMap] Use separate trimmable Java.Interop test jar May 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents stale Java.Interop test JAR reuse when switching the Mono.Android device-test project between trimmable and non-trimmable typemap lanes by producing a distinct output JAR for the trimmable configuration.

Changes:

  • Introduces a _JavaInteropTestsJarFile property that selects a different Jars\*.jar output when $(_AndroidTypeMapImplementation) is trimmable.
  • Updates the AndroidJavaLibrary input and TestJarEntry.OutputFile to use the selected JAR path, ensuring MSBuild up-to-date checks don’t reuse the non-trimmable JAR.
  • Adjusts the explanatory comment to reflect the new β€œseparate output jar” behavior rather than requiring a clean rebuild.

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 13, 2026
@jonathanpeppers
jonathanpeppers merged commit 530866a into main May 13, 2026
7 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/simonrozsival/fix-javaobjecttest-disposeaccessesthis branch May 13, 2026 15:29
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

copilot `copilot-cli` or other AIs were used to author this ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants