Skip to content

[Xamarin.Android.Tools.AndroidSdk] Don't check Linux paths on Windows #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2025

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 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 added a commit to dotnet/android that referenced this pull request Mar 21, 2025
jonpryor added a commit to dotnet/android that referenced this pull request Mar 22, 2025
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.

3 participants