Skip to content

Conversation

@jonpryor
Copy link
Contributor

OS-specific JDK locators should only be used on the OS that they're intended for. Remove checks for Linux JDK probe mechanisms such as /usr/libexec/java_home and /usr/lib/jvm/* from Windows & macOS.

OS-specific JDK locators should only be used on the OS that they're
intended for.  Remove checks for Linux JDK probe mechanisms such as
`/usr/libexec/java_home` and `/usr/lib/jvm/*` from Windows & macOS.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures Linux-specific JDK locator mechanisms are only executed on Linux by introducing an OS.IsLinux check.

  • Added OS.IsLinux checks in GetLibexecJdkPaths, GetJavaAlternativesJdkPaths, and GetLibJvmJdkPaths in JdkInfo.cs.
  • Added the OS.IsLinux property in OS.cs and updated NativeLibraryFormat initialization accordingly.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs Added Linux OS checks to conditionally execute Linux-specific code.
src/Xamarin.Android.Tools.AndroidSdk/OS.cs Introduced OS.IsLinux and updated library format assignment based on the OS.

`/usr/libexec/java_home` is a macOS-ism, not a Linux-ism.
Fix the OS check.

`GetMacOSMicrosoftDistJdkPaths()` is also macOS-specific.
@jonpryor jonpryor merged commit 0658bc6 into main Mar 21, 2025
2 checks passed
@jonpryor jonpryor deleted the dev/jonp/jonp-do-not-use-os-specific-paths-on-other-os branch March 21, 2025 12:24
jonpryor added a commit to dotnet/android that referenced this pull request Mar 21, 2025
Changes: dotnet/android-tools@ac8d0ee...0658bc6

  * dotnet/android-tools@0658bc6: [Xamarin.Android.Tools.AndroidSdk] OS-specific dirs are OS-specific (dotnet/android-tools#250)
jonpryor added a commit that referenced this pull request Mar 21, 2025
…250)

OS-specific JDK locators should only be attempted on the OS that
they're intended for: macOS-specific JDK probe mechanisms such as
`/usr/libexec/java_home -X` should only be used on macOS, and
Linux-specific JDK probe mechanisms such as looking at
`/usr/lib/jvm/*` should only be done on Linux.
jonpryor added a commit that referenced this pull request Mar 21, 2025
…250)

OS-specific JDK locators should only be attempted on the OS that
they're intended for: macOS-specific JDK probe mechanisms such as
`/usr/libexec/java_home -X` should only be used on macOS, and
Linux-specific JDK probe mechanisms such as looking at
`/usr/lib/jvm/*` should only be done on Linux.
jonpryor added a commit to dotnet/android that referenced this pull request Mar 21, 2025
Changes: dotnet/android-tools@f53106a...5612c1a

  * dotnet/android-tools@5612c1a: [Xamarin.Android.Tools.AndroidSdk] OS-specific dirs are OS-specific (dotnet/android-tools#250)
  * dotnet/android-tools@da87185: [Xamarin.Android.Tools.AndroidSdk] Remove hardcoded Path (dotnet/android-tools#248)
jonpryor added a commit to dotnet/android that referenced this pull request Mar 21, 2025
Changes: dotnet/android-tools@ab657df...59cab87

  * dotnet/android-tools@59cab87: [Xamarin.Android.Tools.AndroidSdk] OS-specific dirs are OS-specific (dotnet/android-tools#250)
  * dotnet/android-tools@ab50990: [ci] Move PR build to dnceng public (dotnet/android-tools#249)
pjcollins pushed a commit to dotnet/android that referenced this pull request Mar 21, 2025
Changes: dotnet/android-tools@f53106a...5612c1a

  * dotnet/android-tools@5612c1a: [Xamarin.Android.Tools.AndroidSdk] OS-specific dirs are OS-specific (dotnet/android-tools#250)
  * dotnet/android-tools@da87185: [Xamarin.Android.Tools.AndroidSdk] Remove hardcoded Path (dotnet/android-tools#248)
jonpryor pushed a commit to dotnet/java-interop that referenced this pull request Mar 28, 2025
Changes: dotnet/android-tools@ac8d0ee...0658bc6

  * dotnet/android-tools@0658bc6: [Xamarin.Android.Tools.AndroidSdk] OS-specific dirs are OS-specific (dotnet/android-tools#250)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

4 participants