-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: Fix issues when zgc is not fully supported
Turns out setting ZGC on graalvm for JDK 17 will break communication between metals server and vs code as it prints an unexpected warning to STDOUT
- Loading branch information
Showing
6 changed files
with
95 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,53 @@ | ||
import { ServerOptions } from "./interfaces/ServerOptions"; | ||
import { JavaConfig } from "./getJavaConfig"; | ||
|
||
interface GetServerOptions { | ||
metalsClasspath: string; | ||
serverProperties: string[] | undefined; | ||
clientName?: string; | ||
javaConfig: JavaConfig; | ||
} | ||
|
||
export function getServerOptions({ | ||
metalsClasspath, | ||
serverProperties = [], | ||
clientName, | ||
javaConfig: { javaOptions, javaPath, extraEnv }, | ||
}: GetServerOptions): ServerOptions { | ||
export function getServerOptions( | ||
metalsClasspath: string, | ||
serverProperties: string[], | ||
clientName: string, | ||
javaConfig: JavaConfig | ||
): ServerOptions { | ||
const baseProperties = ["-Xss4m", "-Xms100m"]; | ||
|
||
if (clientName) { | ||
baseProperties.push(`-Dmetals.client=${clientName}`); | ||
} | ||
|
||
/** | ||
* GraalVM for JDK 17-20 prints additional warnings that breaks things | ||
*/ | ||
const skipZGC = | ||
+javaConfig.javaHome.version < 21 && | ||
javaConfig.javaHome.description.indexOf("GraalVM") > -1; | ||
|
||
var filteredServerProperties = serverProperties; | ||
if (skipZGC) { | ||
filteredServerProperties = serverProperties.filter(function (prop) { | ||
return prop.indexOf("UseZGC") === -1; | ||
}); | ||
} | ||
const mainArgs = ["-classpath", metalsClasspath, "scala.meta.metals.Main"]; | ||
|
||
// let user properties override base properties | ||
const launchArgs = [ | ||
...baseProperties, | ||
...javaOptions, | ||
...serverProperties, | ||
...javaConfig.javaOptions, | ||
...filteredServerProperties, | ||
...mainArgs, | ||
]; | ||
|
||
const env = () => ({ ...process.env, ...extraEnv }); | ||
const env = () => ({ ...process.env, ...javaConfig.extraEnv }); | ||
|
||
return { | ||
run: { command: javaPath, args: launchArgs, options: { env: env() } }, | ||
debug: { command: javaPath, args: launchArgs, options: { env: env() } }, | ||
run: { | ||
command: javaConfig.javaPath, | ||
args: launchArgs, | ||
options: { env: env() }, | ||
}, | ||
debug: { | ||
command: javaConfig.javaPath, | ||
args: launchArgs, | ||
options: { env: env() }, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters