Skip to content

Commit fc6cb66

Browse files
authored
Fix: /usr is wrongly recognized as JDK in macOS Big Sur (#502)
Signed-off-by: Yan Zhang <[email protected]>
1 parent da5ff14 commit fc6cb66

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/java-runtime/utils/findJavaRuntime.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,24 @@ async function fromPathEnv(): Promise<string[]> {
9191
try {
9292
buffer = cp.execSync(macUtility, { cwd: dir });
9393
const absoluteJavaHome = "" + buffer.toString().replace(/\n$/, "");
94-
ret.push(absoluteJavaHome);
94+
const verified = await verifyJavaHome(absoluteJavaHome, JAVAC_FILENAME);
95+
if (verified) {
96+
ret.push(absoluteJavaHome);
97+
}
9598
} catch (error) {
9699
// do nothing
97100
}
98101
}
99102
}
100103
}
101104

102-
return ret;
105+
if (isMac) {
106+
// Exclude /usr, because in macOS Big Sur /usr/bin/javac is no longer symlink.
107+
// See https://github.com/redhat-developer/vscode-java/issues/1700#issuecomment-729478810
108+
return ret.filter(item => item !== "/usr");
109+
} else {
110+
return ret;
111+
}
103112
}
104113

105114
async function fromWindowsRegistry(): Promise<string[]> {

0 commit comments

Comments
 (0)