Repository navigation
[tests] Cover R8 bound Java field preservation - #13248
Conversation
Port the regression tests from 5485ae3 to main. Check ACTION_COLLAPSE in DEX output for both obfuscation modes without asserting release-specific keep rules. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4f444992-9269-4af2-be93-975076a809d0
Port the test-only coverage from 2d4f358 to main. Verify the original int descriptor of a bound Java instance field after R8 optimization. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4f444992-9269-4af2-be93-975076a809d0
There was a problem hiding this comment.
🟢 Approval recommended
The focused test-only changes preserve existing helper behavior, have no identified blocking issues, and include reported successful local build and test validation.
No open issues 🎉
What changed in this PR
Adds regression coverage for bound Java field preservation under R8, bringing the tests from #13239 to main without changing production behavior.
Changes:
- Tests that
ACTION_COLLAPSEretains its name and type with obfuscation disabled and withprivate-members. - Tests that a bound instance
intfield retains its DEX descriptor rather than being narrowed tobyte. - Adds exact declaring-class, field-name, and type matching to the shared DEX helper, with unit coverage.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Utilities/DexUtils.cs | Shares member-matching logic between method and new field lookups. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs | Adds static and instance field preservation regression tests. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/DexUtilsTests.cs | Verifies exact field matching and rejects mismatched lookup values. |
Review effort: Balanced
|
@dalexsoto review |
|
@jonathanpeppers Not reviewing this request in this iteration: the current-head source passes found no significant issue and CI succeeded, but the explicit itemized candidate-finding/disposition ledger needed to verify the final consolidated review boundary has not yet been returned by the read-only reviewer. I will not submit a formal decision on an incomplete handoff. |
dalexsoto
left a comment
There was a problem hiding this comment.
The exact DEX field checks and R8 regression coverage preserve the existing method-matching behavior. No high-confidence blockers found in the three-file change and its material static integration.
Add the test coverage from #13239 to main. These tests protect managed JNI field access from R8 field removal, renaming, and type narrowing. Related issue: #13159.
The static-field test builds a trimmed CoreCLR Release app with Xamarin.AndroidX.Core 1.19.0.1 and checks
ACTION_COLLAPSEin DEX output with obfuscation disabled and withprivate-members. The instance-field test binds a Javaintfield with values 0, 1, and 2, keeps its Java reader live, and checks that R8 preserves itsIdescriptor instead of narrowing it toB.Add exact field class/name/type matching to the shared DEX test helper and unit coverage for that matching. Main already preserves these fields through its typemap member rules, so this PR contains no production or documentation changes and does not assert the release-specific generated rule.
Rebased on main at c44b901. Local validation after the rebase, using the local SDK:
dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -nodeReuse:false -v:minimal -bl:bin\BuildDebug\sdk-rebase.binlog— passed; 92 warnings, 0 errors.dotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~DexUtilsTests|Name~R8PreservesAccessibilityActionField|Name~R8PreservesInstanceIntFieldType" --logger "console;verbosity=normal" --logger "trx;LogFileName=r8-fields-rebase.trx" --results-directory C:\Users\jopepper\.copilot\session-state\4f444992-9269-4af2-be93-975076a809d0\files\TestResults— passed; 17 tests, 0 failed, 0 skipped (31.6117 seconds).Test environment:
TEST_ANDROID_JDK_PATH=D:\android-toolchain\jdk-25,TEST_ANDROID_SDK_PATH=D:\android-toolchain\sdk,TEST_ANDROID_NDK_PATH=D:\android-toolchain\ndk.Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: