Skip to content

[release/11.0.1xx] [Xamarin.Android.Build.Tasks] Fix 5-part JDK versions (#13524) - #13598

Merged
jonathanpeppers merged 1 commit into
release/11.0.1xxfrom
jonathanpeppers-backport-5-part-jdk-versions
Nov 17, 2026
Merged

jonathanpeppers merged 1 commit into
release/11.0.1xxfrom
jonathanpeppers-backport-5-part-jdk-versions

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Backport of #13524 to release/11.0.1xx. The automatic backport failed with a conflict in the test file.

Microsoft OpenJDK can report 21.0.13.0.2. System.Version only accepts four components, so the build logs XA0033 and skips JDK version validation.

Read the first four components from the JDK release file and from java and javac version output.

The task change applies cleanly. The release branch does not have the CurrentSdkUsesConfiguredJavaVersionRange test from main, so this adds a FivePartVersion test for both code paths (release file and java -version).

Fixes: #13445

Validation:

  • build.cmd: passed
  • dotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~ValidateJavaVersionTests": passed (11/11)

Microsoft OpenJDK can report `21.0.13.0.2`.  System.Version only
accepts four components, so the build logs XA0033 and skips JDK
version validation.

Read the first four components from the JDK release file and from
java and javac version output.

Fixes: #13445

Co-authored-by: Copilot App <[email protected]>
(cherry picked from commit 380fbcb)
Copilot AI balanced review requested due to automatic review settings November 17, 2026 19:25

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.

🟡 Changes recommended

For target 36.0, validation replaces the configured minimum JDK version with 11.0, allowing an out-of-range version, and the new tests do not cover rejection cases.

1 open issue
What changed in this PR

Backports #13524 to release/11.0.1xx, fixing XA0033 warnings when Android build validation encounters five-part Microsoft OpenJDK versions.

Changes:

  • Parse the first four version components from the JDK release file and java/javac output.
  • Add regression tests for release-file and executable-based version detection.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ValidateJavaVersionTests.cs Tests five-part version parsing through both detection paths.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ValidateJavaVersion.cs Shares version normalization across release-file and executable parsing.

Review effort: Balanced

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 17, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) November 17, 2026 20:40

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed 9f632cbf against release/11.0.1xx at 37b36910 (2 files). This is a static, read-only review.

The ValidateJavaVersion.cs change is identical to #13524; only line offsets differ. TryParseJavaVersion keeps the first four parts, matching the in-tree JdkInfo truncation, so 21.0.13.0.2 becomes 21.0.13.0. The _JdkVersion consumers (Javac Version.Parse, JavaToolTask.GetJavaOptions Version.TryParse) now get a parseable value instead of the XA0033 path, and Legacy.ValidateJavaVersion still goes through the patched GetVersionFromTool. [NotNullWhen] resolves on netstandard2.0 via the linked NullableAttributes.cs. The standalone FivePartVersion(bool) test is a justified divergence from main, because this branch lacks CurrentSdkUsesConfiguredJavaVersionRange. The one commit behind (#13575) only touches tools/workload-dependencies.

Non-blocking: with a bare java as javaExe, the UseJavaExeVersion=false case looks up a cwd-relative ../release, which ReleaseFile_Valid/ReleaseFile_Invalid write and never delete. A repeat run in the same working directory can therefore fail FivePartVersion(false). Fresh runs pass on alphabetical order, and main has the same exposure; the fix belongs in the ReleaseFile_* tests (per-test temp dir).

LGTM.

@jonathanpeppers
jonathanpeppers merged commit d94c7d6 into release/11.0.1xx Nov 17, 2026
45 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-backport-5-part-jdk-versions branch November 17, 2026 23:14
simonrozsival pushed a commit that referenced this pull request Nov 18, 2026
Backport of #13524 to release/10.0.1xx (cherry-picked from the release/11.0.1xx backport, #13598).

Microsoft OpenJDK can report `21.0.13.0.2`. `System.Version` only accepts four components, so the build logs XA0033 and skips JDK version validation.

Read the first four components from the JDK `release` file and from `java`/`javac` version output.

The test file conflicted because release/10.0.1xx does not have the newer null `JavaSdkPath` tests. The `FivePartVersion` test is added at the end of the class.

Fixes: #13445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants