From 9f7a8d0d3b5a5c8c8433c312efcf18f5f4724ffe Mon Sep 17 00:00:00 2001 From: Jonathan Dick Date: Thu, 27 Aug 2026 14:43:07 -0400 Subject: [PATCH] [build] Recommend latest supported JDK in workload metadata (#12500) ## Summary - select `jdk.recommendedVersion` from the newest non-preview, non-obsolete JDK in the Android installer feed within the workload's supported JDK range - carry the normalized `Version` used for revision ordering into range filtering while preserving the original feed revision string for output - continue accepting single-component feed revisions such as `revision="21"` - 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"` Co-authored-by: Jonathan Peppers Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- tools/workload-dependencies/Program.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/workload-dependencies/Program.cs b/tools/workload-dependencies/Program.cs index 8b9a9712f10..dfbccb3ee1e 100644 --- a/tools/workload-dependencies/Program.cs +++ b/tools/workload-dependencies/Program.cs @@ -165,7 +165,7 @@ JProperty CreateJdkProperty (XDocument doc) var v = new Version (JdkVersion ?? "17.0"); var start = new Version (v.Major, v.Minor); var end = GetMaxJdkVersion (v); - var latestRevision = JdkVersion ?? GetLatestRevision (doc, "jdk"); + var latestRevision = GetLatestRevision (doc, "jdk", start, new Version (end)); var contents = new JObject ( new JProperty ("version", $"[{start},{end})")); if (!string.IsNullOrEmpty (latestRevision)) @@ -196,15 +196,19 @@ IEnumerable GetSupportedElements (XDocument doc, string element) ; } -IEnumerable<(XElement Element, string Revision)> GetByRevisions (XDocument doc, string element) +IEnumerable<(XElement Element, string Revision, Version Version)> GetByRevisions (XDocument doc, string element) { return GetSupportedElements (doc, element) .OrderByRevision (); } -string? GetLatestRevision (XDocument doc, string element) +string? GetLatestRevision (XDocument doc, string element, Version minimumVersion, Version maximumVersion) { return GetByRevisions (doc, element) + .Where (item => { + var version = item.Version; + return version >= minimumVersion && version < maximumVersion; + }) .LastOrDefault () .Revision; } @@ -375,12 +379,12 @@ public static string ReqAttr (this XElement e, string attribute) return v; } - public static IEnumerable<(XElement Element, string Revision)> OrderByRevision (this IEnumerable elements) + public static IEnumerable<(XElement Element, string Revision, Version Version)> OrderByRevision (this IEnumerable elements) { return from e in elements let revision = e.ReqAttr ("revision") let version = new Version (revision.Contains (".") ? revision : revision + ".0") orderby version - select (e, revision); + select (e, revision, version); } }