Add jvm arg -Xlog:jni+resolve=off by default
This commit is contained in:
@@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
@@ -33,12 +34,13 @@ import org.springsource.ide.eclipse.commons.core.util.IOUtil;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class STS4LanguageServerProcessStreamConnector extends ProcessStreamConnectionProvider {
|
||||
|
||||
private static LanguageServerProcessReaper processReaper = new LanguageServerProcessReaper();
|
||||
|
||||
private static final String LOG_RESOLVE_VM_ARG_PREFIX = "-Xlog:jni+resolve=";
|
||||
|
||||
private Supplier<Console> consoles = null;
|
||||
private String connectorId;
|
||||
|
||||
@@ -83,7 +85,7 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
|
||||
Assert.isNotNull(lsFolder);
|
||||
Assert.isNotNull(mainClass);
|
||||
|
||||
ImmutableList.Builder<String> command = ImmutableList.builder();
|
||||
List<String> command = new ArrayList<>();
|
||||
|
||||
command.add(runtime.getJavaExecutable());
|
||||
command.add("-cp");
|
||||
@@ -112,6 +114,10 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
|
||||
|
||||
command.addAll(extraVmArgs);
|
||||
|
||||
if (!hasVmArgStartingWith(command, LOG_RESOLVE_VM_ARG_PREFIX)) {
|
||||
command.add(LOG_RESOLVE_VM_ARG_PREFIX + "off");
|
||||
}
|
||||
|
||||
if (configFileName != null) {
|
||||
command.add("-Dspring.config.location=file:" + languageServerRoot.resolve("BOOT-INF/classes").resolve(configFileName).toFile());
|
||||
}
|
||||
@@ -120,13 +126,22 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
|
||||
|
||||
command.add("--languageserver.hover-timeout=225");
|
||||
|
||||
setCommands(command.build());
|
||||
setCommands(command);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LanguageServerCommonsActivator.logError(e, "Failed to assemble exploded LS JAR launch command");
|
||||
}
|
||||
}
|
||||
|
||||
protected static boolean hasVmArgStartingWith(List<String> vmargs, String prefix) {
|
||||
for (String vmarg : vmargs) {
|
||||
if (vmarg.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProcessBuilder createProcessBuilder() {
|
||||
if (consoles==null) {
|
||||
|
||||
@@ -26,6 +26,7 @@ const p2c = P2C.createConverter(undefined, false, false);
|
||||
|
||||
PortFinder.basePort = 45556;
|
||||
|
||||
const LOG_RESOLVE_VM_ARG_PREFIX = '-Xlog:jni+resolve=';
|
||||
const DEBUG_ARG = '-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y';
|
||||
|
||||
export interface ActivatorOptions {
|
||||
@@ -259,6 +260,10 @@ function prepareJvmArgs(options: ActivatorOptions, context: VSCode.ExtensionCont
|
||||
if (DEBUG) {
|
||||
args.unshift(DEBUG_ARG);
|
||||
}
|
||||
// Below is to fix: https://github.com/spring-projects/sts4/issues/811
|
||||
if (!hasVmArg(LOG_RESOLVE_VM_ARG_PREFIX, args)) {
|
||||
args.push(`${LOG_RESOLVE_VM_ARG_PREFIX}off`);
|
||||
}
|
||||
|
||||
if (options.explodedLsJarData) {
|
||||
const explodedLsJarData = options.explodedLsJarData;
|
||||
@@ -294,10 +299,15 @@ function addCpAndLauncherToJvmArgs(args: string[], options: ActivatorOptions, co
|
||||
}
|
||||
|
||||
function hasHeapArg(vmargs?: string[]) : boolean {
|
||||
return hasVmArg('-Xmx');
|
||||
}
|
||||
|
||||
function hasVmArg(argPrefix: string, vmargs?: string[]): boolean {
|
||||
if (vmargs) {
|
||||
return vmargs.some(a => a.startsWith("-Xmx"));
|
||||
return vmargs.some(a => a.startsWith(argPrefix));
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function findServerJar(jarsDir) : string {
|
||||
|
||||
Reference in New Issue
Block a user