Repository navigation
[release/11.0.1xx] [Xamarin.Android.Build.Tasks] Fix 5-part JDK versions (#13524) - #13598
Conversation
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)
There was a problem hiding this comment.
🟡 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
releasefile andjava/javacoutput. - 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
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
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.
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

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.Versiononly accepts four components, so the build logs XA0033 and skips JDK version validation.Read the first four components from the JDK
releasefile and fromjavaandjavacversion output.The task change applies cleanly. The release branch does not have the
CurrentSdkUsesConfiguredJavaVersionRangetest frommain, so this adds aFivePartVersiontest for both code paths (releasefile andjava -version).Fixes: #13445
Validation:
build.cmd: passeddotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~ValidateJavaVersionTests": passed (11/11)