Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Commit fc976d8

Browse files
authored
[Xamarin.Android.Tools.AndroidSdk] Add JdkInfo.GetSupportedJdkInfos() (#142)
Context: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1415418 Visual Studio needs to know the list of supported JDKs, so that it can appropriately compare and display them to the user as part of a "reset to defaults" experience. The list of "supported" JDKs was formerly provided by the *`internal`* `JdkInfo.GetPreferredJdkInfos()` method. Rename `JdkInfo.GetPreferredJdkInfos()` to `JdkInfo.GetSupportedJdkInfos()`, and make `public`. The rename is done to reduce ambiguity over what the "preferred" *means*, so that in public APIs it only means "whatever the user has previously selected, as per the Windows Registry/`monodroid-config.xml`/etc.
1 parent 34e98e2 commit fc976d8

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎src/Xamarin.Android.Tools.AndroidSdk/AndroidSdkInfo.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static void DetectAndSetPreferredJavaSdkPathToLatest (Action<TraceLevel,
185185

186186
logger=logger??DefaultConsoleLogger;
187187

188-
varlatestJdk=JdkInfo.GetPreferredJdkInfos(logger).FirstOrDefault();
188+
varlatestJdk=JdkInfo.GetSupportedJdkInfos(logger).FirstOrDefault();
189189
if(latestJdk==null)
190190
thrownewNotSupportedException("No Microsoft OpenJDK could be found. Please re-run the Visual Studio installer or manually specify the JDK path in settings.");
191191

‎src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
usingSystem;
1+
usingSystem;
22
usingSystem.Collections.Generic;
33
usingSystem.Collections.ObjectModel;
44
usingSystem.Diagnostics;
@@ -280,7 +280,7 @@ static Dictionary<string, List<string>> GetJavaProperties (string java)
280280
returnprops;
281281
}
282282

283-
// Keep ordering in sync w/ GetPreferredJdkInfos
283+
// Keep ordering in sync w/ GetSupportedJdkInfos
284284
publicstaticIEnumerable<JdkInfo>GetKnownSystemJdkInfos(Action<TraceLevel,string>?logger=null)
285285
{
286286
logger=logger??AndroidSdkInfo.DefaultConsoleLogger;
@@ -302,8 +302,10 @@ public static IEnumerable<JdkInfo> GetKnownSystemJdkInfos (Action<TraceLevel, st
302302
}
303303

304304
// Keep ordering in sync w/ GetKnownSystemJdkInfos
305-
internalstaticIEnumerable<JdkInfo>GetPreferredJdkInfos(Action<TraceLevel,string>logger)
305+
publicstaticIEnumerable<JdkInfo>GetSupportedJdkInfos(Action<TraceLevel,string>?logger=null)
306306
{
307+
logger=logger??AndroidSdkInfo.DefaultConsoleLogger;
308+
307309
returnMicrosoftOpenJdkLocations.GetMicrosoftOpenJdks(logger)
308310
.Concat(EclipseAdoptiumJdkLocations.GetEclipseAdoptiumJdks(logger))
309311
.Concat(MicrosoftDistJdkLocations.GetMicrosoftDistJdks(logger))

0 commit comments

Comments
 (0)