Skip to content
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

(Apple Silicon) aarch64 OpenJDK detect and install #273

Merged
merged 8 commits into from
Mar 7, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/assets/js/assetguard.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class JavaGuard extends EventEmitter {
break
}

const url = `https://corretto.aws/downloads/latest/amazon-corretto-${major}-x64-${sanitizedOS}-jdk.${ext}`
const url = `https://corretto.aws/downloads/latest/amazon-corretto-${major}-${process.arch.includes("arm") ? "aarch64" : "x64"}-${sanitizedOS}-jdk.${ext}`

return new Promise((resolve, reject) => {
request.head({url, json: true}, (err, resp) => {
Expand Down Expand Up @@ -495,6 +495,8 @@ class JavaGuard extends EventEmitter {
let vendorName = props[i].split('=')[1].trim()
this.logger.debug(props[i].trim())
meta.vendor = vendorName
} else if (props[i].indexOf('os.arch') > -1) {
meta.isARM = props[i].split('=')[1].trim() === 'aarch64'
}
}

Expand Down Expand Up @@ -866,6 +868,9 @@ class JavaGuard extends EventEmitter {
* @param {string} dataDir The base launcher directory.
* @returns {Promise.<string>} A Promise which resolves to the executable path of a valid
* x64 Java installation. If none are found, null is returned.
*
* Added: On the system with ARM architecture attempts to find aarch64 Java.
*
*/
async _darwinJavaValidate(dataDir){

Expand Down Expand Up @@ -894,7 +899,13 @@ class JavaGuard extends EventEmitter {
pathArr = JavaGuard._sortValidJavaArray(pathArr)

if(pathArr.length > 0){
return pathArr[0].execPath
let amd64 = pathArr.find(({ isARM }) => !isARM)
let arm = pathArr.find(({ isARM }) => isARM)
if (process.arch.includes("arm")) {
if (arm) return arm.execPath
return null
}
return amd64.execPath
} else {
return null
}
Expand Down