Lines 121-136
Link Here
|
121 |
return !javaPath.empty(); |
121 |
return !javaPath.empty(); |
122 |
} |
122 |
} |
123 |
|
123 |
|
124 |
bool JvmLauncher::start(const char *mainClassName, list<string> args, list<string> options, bool &separateProcess, DWORD *retCode) { |
124 |
bool JvmLauncher::start(const char *mainClassName, const list<string> &args, const list<string> &options, bool &separateProcess, DWORD *retCode) { |
125 |
assert(mainClassName); |
125 |
assert(mainClassName); |
126 |
logMsg("JvmLauncher::start()\n\tmainClassName: %s\n\tseparateProcess: %s", |
126 |
logMsg("JvmLauncher::start()\n\tmainClassName: %s\n\tseparateProcess: %s", |
127 |
mainClassName, separateProcess ? "true" : "false"); |
127 |
mainClassName, separateProcess ? "true" : "false"); |
128 |
logMsg(" args:"); |
128 |
logMsg(" args:"); |
129 |
for (list<string>::iterator it = args.begin(); it != args.end(); ++it) { |
129 |
for (list<string>::const_iterator it = args.begin(); it != args.end(); ++it) { |
130 |
logMsg("\t%s", it->c_str()); |
130 |
logMsg("\t%s", it->c_str()); |
131 |
} |
131 |
} |
132 |
logMsg(" options:"); |
132 |
logMsg(" options:"); |
133 |
for (list<string>::iterator it = options.begin(); it != options.end(); ++it) { |
133 |
for (list<string>::const_iterator it = options.begin(); it != options.end(); ++it) { |
134 |
logMsg("\t%s", it->c_str()); |
134 |
logMsg("\t%s", it->c_str()); |
135 |
} |
135 |
} |
136 |
|
136 |
|
Lines 166-173
Link Here
|
166 |
: startInProcJvm(mainClassName, args, options); |
166 |
: startInProcJvm(mainClassName, args, options); |
167 |
} |
167 |
} |
168 |
|
168 |
|
169 |
bool JvmLauncher::findClientOption(list<string> &options) { |
169 |
bool JvmLauncher::findClientOption(const list<string> &options) { |
170 |
for (list<string>::iterator it = options.begin(); it != options.end(); ++it) { |
170 |
for (list<string>::const_iterator it = options.begin(); it != options.end(); ++it) { |
171 |
if (*it == "-client") { |
171 |
if (*it == "-client") { |
172 |
return true; |
172 |
return true; |
173 |
} |
173 |
} |
Lines 195-201
Link Here
|
195 |
return *end == '\0'; |
195 |
return *end == '\0'; |
196 |
} |
196 |
} |
197 |
|
197 |
|
198 |
bool JvmLauncher::startInProcJvm(const char *mainClassName, std::list<std::string> args, std::list<std::string> options) { |
198 |
bool JvmLauncher::startInProcJvm(const char *mainClassName, const std::list<std::string> &args, const std::list<std::string> &options) { |
199 |
|
199 |
|
200 |
class Jvm { |
200 |
class Jvm { |
201 |
public: |
201 |
public: |
Lines 228-234
Link Here
|
228 |
} |
228 |
} |
229 |
} |
229 |
} |
230 |
|
230 |
|
231 |
bool init(list<string> options) { |
231 |
bool init(const list<string> &options) { |
232 |
logMsg("JvmLauncher::Jvm::init()"); |
232 |
logMsg("JvmLauncher::Jvm::init()"); |
233 |
logMsg("LoadLibrary(\"%s\")", jvmLauncher->javaDllPath.c_str()); |
233 |
logMsg("LoadLibrary(\"%s\")", jvmLauncher->javaDllPath.c_str()); |
234 |
{ |
234 |
{ |
Lines 249-256
Link Here
|
249 |
logMsg("JVM options:"); |
249 |
logMsg("JVM options:"); |
250 |
jvmOptions = new JavaVMOption[options.size()]; |
250 |
jvmOptions = new JavaVMOption[options.size()]; |
251 |
int i = 0; |
251 |
int i = 0; |
252 |
for (list<string>::iterator it = options.begin(); it != options.end(); ++it, ++i) { |
252 |
for (list<string>::const_iterator it = options.begin(); it != options.end(); ++it, ++i) { |
253 |
string &option = *it; |
253 |
const string &option = *it; |
254 |
logMsg("\t%s", option.c_str()); |
254 |
logMsg("\t%s", option.c_str()); |
255 |
jvmOptions[i].optionString = (char *) option.c_str(); |
255 |
jvmOptions[i].optionString = (char *) option.c_str(); |
256 |
jvmOptions[i].extraInfo = 0; |
256 |
jvmOptions[i].extraInfo = 0; |
Lines 314-322
Link Here
|
314 |
return false; |
314 |
return false; |
315 |
} |
315 |
} |
316 |
int i = 0; |
316 |
int i = 0; |
317 |
for (list<string>::iterator it = args.begin(); it != args.end(); ++it, ++i) { |
317 |
for (list<string>::const_iterator it = args.begin(); it != args.end(); ++it, ++i) { |
318 |
string &arg = *it; |
318 |
const string &arg = *it; |
319 |
jstring jstringArg = jvm.env->NewStringUTF(arg.c_str()); |
319 |
const int len = 32*1024; |
|
|
320 |
char utf8[len] = ""; |
321 |
if (convertAnsiToUtf8(arg.c_str(), utf8, len)) |
322 |
logMsg("Conversion to UTF8 failed"); |
323 |
jstring jstringArg = jvm.env->NewStringUTF(utf8); |
320 |
if (!jstringArg) { |
324 |
if (!jstringArg) { |
321 |
logErr(false, true, "NewStringUTF() failed"); |
325 |
logErr(false, true, "NewStringUTF() failed"); |
322 |
return false; |
326 |
return false; |
Lines 329-338
Link Here
|
329 |
} |
333 |
} |
330 |
|
334 |
|
331 |
|
335 |
|
332 |
bool JvmLauncher::startOutProcJvm(const char *mainClassName, std::list<std::string> args, std::list<std::string> options, DWORD *retCode) { |
336 |
bool JvmLauncher::startOutProcJvm(const char *mainClassName, const std::list<std::string> &args, const std::list<std::string> &options, DWORD *retCode) { |
333 |
string cmdLine = '\"' + (suppressConsole ? javawExePath : javaExePath) + '\"'; |
337 |
string cmdLine = '\"' + (suppressConsole ? javawExePath : javaExePath) + '\"'; |
334 |
cmdLine.reserve(32*1024); |
338 |
cmdLine.reserve(32*1024); |
335 |
for (list<string>::iterator it = options.begin(); it != options.end(); ++it) { |
339 |
for (list<string>::const_iterator it = options.begin(); it != options.end(); ++it) { |
336 |
cmdLine += " \""; |
340 |
cmdLine += " \""; |
337 |
cmdLine += *it; |
341 |
cmdLine += *it; |
338 |
cmdLine += "\""; |
342 |
cmdLine += "\""; |
Lines 341-347
Link Here
|
341 |
// mainClass and args |
345 |
// mainClass and args |
342 |
cmdLine += ' '; |
346 |
cmdLine += ' '; |
343 |
cmdLine += mainClassName; |
347 |
cmdLine += mainClassName; |
344 |
for (list<string>::iterator it = args.begin(); it != args.end(); ++it) { |
348 |
for (list<string>::const_iterator it = args.begin(); it != args.end(); ++it) { |
345 |
if (javaClientDllPath.empty() && *it == "-client") { |
349 |
if (javaClientDllPath.empty() && *it == "-client") { |
346 |
logMsg("Removing -client option, client java dll not found."); |
350 |
logMsg("Removing -client option, client java dll not found."); |
347 |
// remove client parameter, no client java found |
351 |
// remove client parameter, no client java found |