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

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

Merged
jonpryor merged 2 commits into
mainfrom
dev/jonp/jonp-do-not-use-os-specific-paths-on-other-os
Mar 21, 2025
Merged

[Xamarin.Android.Tools.AndroidSdk] Don't check Linux paths on Windows#250
jonpryor merged 2 commits into
mainfrom
dev/jonp/jonp-do-not-use-os-specific-paths-on-other-os

Conversation

@jonpryor

Copy link
Copy Markdown
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.

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

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
@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>
pull Bot pushed a commit to MaxMood96/xamarin-android that referenced this pull request Jul 1, 2026
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants