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

change regex pattern to find java version #1469

Merged
merged 1 commit into from Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,7 +1,7 @@
import { IJavaHomeInfo } from "@viperproject/locate-java-home/js/es5/lib/interfaces";
import path from "path";

const exampleJavaVersionString = `openjdk 17.0.1 2021-10-19
const exampleJavaVersionString = `openjdk "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)`;

Expand Down
4 changes: 2 additions & 2 deletions packages/metals-languageclient/src/getJavaHome.ts
Expand Up @@ -34,7 +34,7 @@ export async function getJavaHome(
return fromEnvValue ? fromEnvValue : await locate(javaVersion);
}

const versionRegex = /\d+\.\d+\.\d+/;
const versionRegex = /\"\d\d/;
async function validateJavaVersion(
javaHome: string,
javaVersion: JavaVersion,
Expand All @@ -55,7 +55,7 @@ async function validateJavaVersion(
const javaInfoStr = (await javaVersionOut).stderr as string;
const matches = javaInfoStr.match(versionRegex);
if (matches) {
return +matches[0].slice(0, 2) >= +javaVersion;
return +matches[0].slice(1, 3) >= +javaVersion;
}
} catch (error) {
outputChannel.appendLine(`failed while running ${javaBin} -version`);
Expand Down