Skip to content

[build] Recommend latest supported JDK in workload metadata - #12500

Open
Redth wants to merge 1 commit into
mainfrom
redth-recommend-jdk-21
Open

[build] Recommend latest supported JDK in workload metadata#12500
Redth wants to merge 1 commit into
mainfrom
redth-recommend-jdk-21

Conversation

@Redth

@Redth Redth commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • select jdk.recommendedVersion from the newest non-preview, non-obsolete JDK in the Android installer feed
  • constrain the recommendation to the workload's supported JDK range
  • preserve the existing compatibility range while allowing installer feed refreshes to advance the recommended Microsoft OpenJDK release

For the current stable inputs, this changes recommendedVersion from 17.0.14 to 21.0.9 while leaving version at [17.0,22.0). This prevents setup tools that honor recommendedVersion from proposing JDK 17 when JDK 21 is supported and preferred.

Testing

  • dotnet build tools/workload-dependencies/workload-dependencies.csproj -p:DotNetStableTargetFramework=net10.0 -p:MonoOptionsVersion=6.12.0.148 -p:NewtonsoftJsonPackageVersion=13.0.3 --no-restore --nologo
  • generated stable workload metadata with JavaSdkVersion=17.0.14 and LatestSupportedJavaVersion=21.0.99; verified version: "[17.0,22.0)" and recommendedVersion: "21.0.9"
  • ran GenerateWorkloadDependencies through tools/workload-dependencies/WorkloadDependencies.proj; verified packaged data/WorkloadDependencies.json contains the expected JDK metadata
  • generated with a JDK 17 maximum and verified the range filter retains recommendedVersion: "17.0.14"

Select the newest non-preview JDK from the installer feed within the workload's supported range instead of reusing the build JDK version.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4b3f9f46-be20-4288-af69-a4f32ef172a1
Copilot AI lite review requested due to automatic review settings August 25, 2026 00:17

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

Updates workload metadata to recommend the newest supported, non-preview JDK release while preserving the compatibility range.

Changes:

  • Filters JDK revisions to the supported range.
  • Selects the latest eligible release.
  • Preserves the existing compatibility range.

Comment thread tools/workload-dependencies/Program.cs
@jonathanpeppers

Copy link
Copy Markdown
Member

I don't think we even support the 17, where is the 17 coming from?

See also:

So, we might recommend 21 in .NET 11 and allow up to 25 -- still need to get it working, though.

@Redth

Redth commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

I traced the 17 in the published stable manifest. It is not coming from the current main support policy; it comes from a stale installer default embedded in the 36.1.69 SDK pack.

Specifically, Microsoft.Android.Sdk.* 36.1.69 contains:

  • tools/Xamarin.Installer.Common.props: JavaSdkVersion=17.0.14
  • tools/Xamarin.Android.Common.props: JavaSdkVersion=21.0.8, MinimumSupportedJavaVersion=17.0, LatestSupportedJavaVersion=21.0.99

WorkloadDependencies.proj imports Xamarin.Installer.Common.props first. Since both JavaSdkVersion assignments are conditional, 17.0.14 wins. It is then passed as --jdk-version=$(JavaSdkVersion), and the old generator uses that value both as the range floor and as recommendedVersion. LatestSupportedJavaVersion=21.0.99 supplies the ceiling, producing exactly:

{
  "version": "[17.0,22.0)",
  "recommendedVersion": "17.0.14"
}

The NuGet package identifies source commit d549e1dc4e2a083b08b4f24cb5495e81b99d79b5, and I verified these values directly in the published Microsoft.NET.Sdk.Android.Manifest-10.0.100 and Microsoft.Android.Sdk.Darwin 36.1.69 packages.

Current main already has JavaSdkVersion=21.0.8 in Xamarin.Installer.Common.props. With #12478 establishing the .NET 11 support range as JDK 21 through 25, I agree we should not preserve 17 for the .NET 11 manifest. This PR is fixing the separate coupling that made the build/default JDK automatically become the recommendation.

@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12500

@github-actions github-actions Bot 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.

❌ Reject

Findings: 1 error, 0 warnings, 0 suggestions.

The supported-range selection fixes the stale JDK recommendation and all 45 reported checks are green. However, the new filter bypasses existing revision normalization and can fail on a previously accepted feed value; address the inline finding before merge.

Generated by Android PR Reviewer for #12500 · gpt56 · 97.8 AIC · ⌖ 8.79 AIC · ⊞ 25.7K
Comment /review to run again

{
return GetByRevisions (doc, element)
.Where (item => {
var version = new Version (item.Revision);

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.

🤖 ❌ Error handlingOrderByRevision() accepts one-component revisions by appending .0, but this new new Version (item.Revision) parses the original raw value. A supported feed entry such as revision="21" will now throw and abort metadata generation. Preserve the normalized Version in GetByRevisions() and compare that here; please add regression coverage for this accepted input.

Rule: Preserve existing input normalization

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.

I think this it just saying new Version("21") will throw ArgumentException and to check how it's done in other methods in this file.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants