Repository navigation
[Build.Tasks] Use SDK-defined Java version requirements - #13133
jonathanpeppers merged 3 commits into
Conversation
The modern validator lowered the SDK minimum to JDK 11 for Android API 31 and later, allowing JDK 11 and 17 despite the configured JDK 21 minimum. Honor the SDK minimum and maximum directly, and remove the unused legacy framework/build-tools heuristics and their obsolete resources. Migrate the task fixtures to the modern validator, cover release-file and java/javac version checks including range boundaries, and isolate fake JDK release files. Document the SDK-defined minimum and retain the historical XA0032 documentation link. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d47a67e9-2b87-4c64-9b3f-955fcaa13213
There was a problem hiding this comment.
🟡 Changes recommended
The automated tests do not reproduce the API-level condition that triggered the original JDK-minimum regression.
1 open finding
What changed in this PR
Updates Java validation to enforce the SDK-defined JDK range and removes obsolete legacy heuristics.
Changes:
- Uses configured minimum and maximum JDK versions directly.
- Removes legacy validator inputs/resources.
- Expands Java validation tests and documentation.
| File | Description |
|---|---|
ValidateJavaVersionTests.cs |
Expands JDK range and detection tests. |
ResolveSdksTaskTests.cs |
Migrates tests to the modern validator. |
ValidateJavaVersion.cs |
Removes API-level minimum override. |
Legacy/ValidateJavaVersion.cs |
Deletes obsolete legacy validator. |
Resources.resx |
Removes obsolete English resources. |
Resources.Designer.cs |
Removes corresponding generated accessors. |
Microsoft.Android.Sdk.Tooling.targets |
Stops passing the removed input. |
xa0032.md |
Marks XA0032 as historical. |
xa0031.md |
Documents SDK-defined requirements. |
index.md |
Updates error-code summaries. |
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
🧠 Review effort: Balanced
The direct task range cases did not set TargetPlatformVersion, so they could not catch the former API 31+ downgrade of the configured minimum. Invoke the shipped tooling target for API 37 with a fake JDK 17 and an SDK minimum of JDK 21. Assert XA0031 for both release-file and process version detection. Temporarily restoring the old task override and target input makes both cases fail; the fixed focused suite passes all 36 tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d47a67e9-2b87-4c64-9b3f-955fcaa13213
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
The complete ten-file correctness and separate integration review found no high-confidence blocker. Validation now honors the SDK-configured minimum and maximum directly, including explicit too-old JDK rejection without substitution. Both detection paths and the shipped-target regression cover the removed API-level downgrade; target registration, legacy removal, generated/English/localized resources, diagnostics documentation and fake-JDK isolation remain consistent.
Static integration against the actual current main target was also verified: its sole additional upstream change is an unrelated documentation-link replacement, with the executable integration graph unchanged. This is source-review approval, not a claim that reviewer builds, tests or mutation tests were executed.
…te (#13201) `Xamarin.Android.Tasks.MonoAndroidHelper.SupportedVersions` is a mutable process-wide value. One project can replace the API data that another task uses. Remove that value and `RefreshSupportedVersions`, and pass `ReferenceAssemblyPaths` to each consumer. SDK discovery, Java validation, and legacy-tool cleanup are already merged in #13145, #13133, and #13161. This PR does not repeat those changes. It is the lower prerequisite for a separate nested-build optimization. **SDK and Java resolution call counts are unchanged**, including inner builds. Cache read-only `AndroidVersions` data through `IBuildEngine4` with `RegisteredTaskObjectLifetime.Build`. The key includes the task assembly identity and the absolute, original input directory list. The cache holds no task logger or mutable current-context pointer. Concurrent creation for an equal key is harmless; correctness does not depend on a cache shared across worker processes or assembly load contexts. All API-data consumers use explicit inputs: platform JAR and tooling resolution, manifests, aapt2, D8/R8, signing, jar2xml, launch activity/instrumentation, library resources, and dependency calculation. `ManifestDocument` keeps its own version resolver, with a known-version default for standalone use. Aapt2Link and library-resource generation resolve API metadata on the calling thread before yielding. The concurrency test runs 64 tasks against two different SDK/API datasets that map the same preview ID `Z` to API levels 127 and 128. It checks both JAR paths and API outputs. The aapt2 tests link two ABIs and require exactly one API lookup before `Yield`, with relative reference paths resolved from the task's captured working directory. Tests also check cache reuse, separate build engines, manifest resolver isolation, and library-resource metadata access before `Yield`.
|
/backport to release/11.0.1xx |
|
Started backporting to |

The .NET for Android SDK configures a supported JDK range, currently
21.0through25.0.99.Xamarin.Android.Tasks.ValidateJavaVersioninstead lowered the minimum to JDK 11 whenever the Android API level was 31 or later. This allowed explicitly selected JDK 11/17 installations despite the SDK's configured minimum.Honor
$(MinimumSupportedJavaVersion)and$(LatestSupportedJavaVersion)directly, without hardcoding versions in the validator. Remove the unused legacy validator and its framework/build-tools heuristics, along with the modern validator's unusedTargetPlatformVersioninput. Preserve the corresponding input on<ResolveAndroidTooling/>.Migrate the two Java-validation fixtures to the modern task. Cover JDK 11/17 rejection, JDK 21/25 acceptance, JDK 26 rejection, exact range boundaries, release-file detection, and separate
java/javacprocess validation. Keep fake release files inside each fake JDK and use absolute fake Java executable paths so reruns do not contaminate other tests.Remove only the obsolete English XA0031/XA0032 resources, retaining XA0031_NET and all localized files. Document the SDK-defined minimum and preserve XA0032's historical documentation link. This is an independent correctness/legacy-cleanup change; it does not include SDK-state, nested-build, cache, or concurrency refactors. No associated issue.
Local validation
Built this worktree's own SDK using pinned .NET
12.0.100-alpha.1.26509.101; the representative app targetsnet11.0-android. Bounded shells setDOTNET_CLI_USE_MSBUILD_SERVER=0,MSBUILDDISABLENODEREUSE=1, andDOTNET_CLI_TELEMETRY_OPTOUT=1. Focused tests setTEST_ANDROID_JDK_PATH=C:\Program Files\Android\openjdk\jdk-21.0.8. The SDK build ran with the discovered VS 18 Insiders developer environment.The following commands are shown in CMD syntax;
%LOGS%expands toC:\Users\jopepper\.copilot\session-state\d47a67e9-2b87-4c64-9b3f-955fcaa13213\files.SDK preparation: passed (exit 0).
dotnet msbuild Microsoft.Android.slnx -t:Prepare -nr:false -v:minimal -bl:%LOGS%\java-prepare.binlogFull SDK build: passed (exit 0), 119 warnings / 0 errors.
.\dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -nr:false -v:minimal -bl:%LOGS%\java-build.binlogFocused tests: both runs passed, 34 passed / 0 failed / 0 skipped each. The second run followed completion of the full SDK build and also verifies fixture rerun isolation.
Representative app generation: passed. Explicit JDK 17: rejected as intended (exit 1), XA0031 requiring JDK 21.0. Explicit JDK 21.0.8: passed (exit 0), 0 warnings / 0 errors; signed APK produced. The supported-JDK incremental rerun also passed. Rejecting an explicitly supplied too-old JDK is intentional; another installed JDK is not substituted silently.
binlogtoolconfirmed XA0031 originates from<ValidateJavaVersion/>for the JDK 17 build and that the supported build detects JDK21.0.8.git diff --checkand XML parsing of the edited targets/resources passed. No device tests are required for this host-side Java validation change.Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: