On MacOS, do not assume existence of Contents/Home in the JDK binary path (#9684)

This commit is contained in:
GregoryTravis 2024-04-15 16:07:25 -04:00 committed by GitHub
parent 9d2d9038c9
commit 271a744b67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"