use of com.intellij.rt.execution.application.AppMainV2 in project intellij-community by JetBrains.
the class ProcessProxyFactoryImpl method createCommandLineProxy.
@Override
public ProcessProxy createCommandLineProxy(JavaCommandLine javaCmdLine) throws ExecutionException {
JavaParameters javaParameters = javaCmdLine.getJavaParameters();
String mainClass = javaParameters.getMainClass();
if (ourMayUseLauncher && mainClass != null) {
String rtJarPath = JavaSdkUtil.getIdeaRtJarPath();
boolean runtimeJarFile = new File(rtJarPath).isFile() && FileUtil.isAncestor(PathManager.getHomePath(), rtJarPath, true);
if (runtimeJarFile || javaParameters.getModuleName() == null) {
try {
ProcessProxyImpl proxy = new ProcessProxyImpl(StringUtil.getShortName(mainClass));
String port = String.valueOf(proxy.getPortNumber());
String binPath = PathManager.getBinPath();
if (runtimeJarFile && JavaSdkUtil.isJdkAtLeast(javaParameters.getJdk(), JavaSdkVersion.JDK_1_5)) {
javaParameters.getVMParametersList().add("-javaagent:" + rtJarPath + '=' + port + ':' + binPath);
} else {
JavaSdkUtil.addRtJar(javaParameters.getClassPath());
ParametersList vmParametersList = javaParameters.getVMParametersList();
vmParametersList.defineProperty(AppMainV2.LAUNCHER_PORT_NUMBER, port);
vmParametersList.defineProperty(AppMainV2.LAUNCHER_BIN_PATH, binPath);
javaParameters.getProgramParametersList().prepend(mainClass);
javaParameters.setMainClass(AppMainV2.class.getName());
}
return proxy;
} catch (Exception e) {
Logger.getInstance(ProcessProxy.class).warn(e);
}
}
}
return null;
}
Aggregations