in src/main/cpp/bootstrap/jvmlauncher.cpp [351:400]
bool JvmLauncher::startOutProcJvm(const char *mainClassName, const std::list<std::string> &args, const std::list<std::string> &options, DWORD *retCode) {
string cmdLine = '\"' + (suppressConsole ? javawExePath : javaExePath) + '\"';
cmdLine.reserve(32*1024);
for (list<string>::const_iterator it = options.begin(); it != options.end(); ++it) {
cmdLine += " \"";
cmdLine += *it;
cmdLine += "\"";
}
// mainClass and args
cmdLine += ' ';
cmdLine += mainClassName;
for (list<string>::const_iterator it = args.begin(); it != args.end(); ++it) {
if (javaClientDllPath.empty() && *it == "-client") {
logMsg("Removing -client option, client java dll not found.");
// remove client parameter, no client java found
continue;
}
cmdLine += " \"";
cmdLine += *it;
cmdLine += "\"";
}
logMsg("Command line:\n%s", cmdLine.c_str());
if (cmdLine.size() >= 32*1024) {
logErr(false, true, "Command line is too long. Length: %u. Maximum length: %u.", cmdLine.c_str(), 32*1024);
return false;
}
STARTUPINFO si = {0};
si.cb = sizeof (STARTUPINFO);
PROCESS_INFORMATION pi = {0};
char cmdLineStr[32*1024] = "";
strcpy(cmdLineStr, cmdLine.c_str());
if (!CreateProcess(NULL, cmdLineStr, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) {
logErr(true, true, "Failed to create process");
return false;
}
disableFolderVirtualization(pi.hProcess);
ResumeThread(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
if (retCode) {
GetExitCodeProcess(pi.hProcess, retCode);
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return true;
}