Skip to content

Commit

Permalink
On MacOS, do not assume existence of Contents/Home in the JDK binar…
Browse files Browse the repository at this point in the history
…y path (#9684)
  • Loading branch information
GregoryTravis authored Apr 15, 2024
1 parent 9d2d903 commit 271a744
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,20 @@ case class GraalRuntime(version: GraalVMVersion, path: Path) {
def javaHome: Path =
OS.operatingSystem match {
case OS.Linux => path
case OS.MacOS => path / "Contents" / "Home"
case OS.MacOS => findMacOSJavaPath()
case OS.Windows => path
}

/** The bin/ directory may or may not be inside Contents/Home, so check both
* possibilities.
*/
def findMacOSJavaPath(): Path = {
val contentsHomePath = path / "Contents" / "Home"
if (Files.exists(contentsHomePath))
contentsHomePath
else path
}

/** The path to the `java` executable associated with this runtime. */
def javaExecutable: Path = {
val executableName = if (OS.isWindows) "java.exe" else "java"
Expand Down

0 comments on commit 271a744

Please sign in to comment.