Kaydet (Commit) 564fe4e3 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up JNI_CreateJavaVM option code

Change-Id: I1902c73a72f29e948e479a2ae4776f2dff77b2b5
üst 0b3f0f0b
...@@ -655,60 +655,58 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( ...@@ -655,60 +655,58 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
// Valgrind typically emits many false errors when executing JIT'ed JVM // Valgrind typically emits many false errors when executing JIT'ed JVM
// code, so force the JVM into interpreted mode: // code, so force the JVM into interpreted mode:
bool forceInterpreted = FORCE_INTERPRETED > 0; bool addForceInterpreted = FORCE_INTERPRETED > 0;
// Some testing with Java 1.4 showed that JavaVMOption.optionString has to // Some testing with Java 1.4 showed that JavaVMOption.optionString has to
// be encoded with the system encoding (i.e., osl_getThreadTextEncoding): // be encoded with the system encoding (i.e., osl_getThreadTextEncoding):
JavaVMInitArgs vm_args; JavaVMInitArgs vm_args;
sal_Int32 nOptions = 1 + cOptions + (forceInterpreted ? 1 : 0); struct Option {
//TODO: check for overflow Option(OString const & theOptionString, void * theExtraInfo):
boost::scoped_array<JavaVMOption> sarOptions(new JavaVMOption[nOptions]); optionString(theOptionString), extraInfo(theExtraInfo)
JavaVMOption * options = sarOptions.get(); {}
OString optionString;
void * extraInfo;
};
std::vector<Option> options;
// We set an abort handler which is called when the VM calls _exit during // We set an abort handler which is called when the VM calls _exit during
// JNI_CreateJavaVM. This happens when the LD_LIBRARY_PATH does not contain // JNI_CreateJavaVM. This happens when the LD_LIBRARY_PATH does not contain
// all some directories of the Java installation. This is necessary for // all some directories of the Java installation. This is necessary for
// all versions below 1.5.1 // all versions below 1.5.1
int n = 0; options.push_back(Option("abort", reinterpret_cast<void*>(abort_handler)));
options[n].optionString= (char *) "abort";
options[n].extraInfo= reinterpret_cast<void*>(abort_handler);
++n;
OString sClassPathOption;
for (int i = 0; i < cOptions; i++) for (int i = 0; i < cOptions; i++)
{ {
OString opt(arOptions[i].optionString);
#ifdef UNX #ifdef UNX
// Until java 1.5 we need to put a plugin.jar or javaplugin.jar (<1.4.2) // Until java 1.5 we need to put a plugin.jar or javaplugin.jar (<1.4.2)
// in the class path in order to have applet support. // in the class path in order to have applet support:
OString sClassPath = arOptions[i].optionString; if (opt.startsWith("-Djava.class.path="))
if (sClassPath.startsWith("-Djava.class.path="))
{ {
OString sAddPath = getPluginJarPath(pInfo->sVendor, pInfo->sLocation,pInfo->sVersion); OString sAddPath = getPluginJarPath(pInfo->sVendor, pInfo->sLocation,pInfo->sVersion);
if (!sAddPath.isEmpty()) if (!sAddPath.isEmpty())
sClassPathOption = sClassPath + OString(SAL_PATHSEPARATOR) opt += OString(SAL_PATHSEPARATOR) + sAddPath;
+ sAddPath;
else
sClassPathOption = sClassPath;
options[n].optionString = (char *) sClassPathOption.getStr();
options[n].extraInfo = arOptions[i].extraInfo;
} }
else
{
#endif #endif
options[n].optionString = arOptions[i].optionString; if (opt == "-Xint") {
options[n].extraInfo = arOptions[i].extraInfo; addForceInterpreted = false;
#ifdef UNX
} }
#endif options.push_back(Option(opt, arOptions[i].extraInfo));
#if OSL_DEBUG_LEVEL >= 2
JFW_TRACE2("VM option: " << options[n].optionString);
#endif
++n;
} }
if (forceInterpreted) { if (addForceInterpreted) {
options[n].optionString = const_cast<char *>("-Xint"); options.push_back(Option("-Xint", nullptr));
options[n].extraInfo = 0; }
++n;
boost::scoped_array<JavaVMOption> sarOptions(new JavaVMOption[options.size()]);
for (std::vector<Option>::size_type i = 0; i != options.size(); ++i) {
SAL_INFO(
"jfw",
"VM option \"" << options[i].optionString << "\" "
<< options[i].extraInfo);
sarOptions[i].optionString = const_cast<char *>(
options[i].optionString.getStr());
sarOptions[i].extraInfo = options[i].extraInfo;
} }
#ifdef MACOSX #ifdef MACOSX
...@@ -716,8 +714,8 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( ...@@ -716,8 +714,8 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
#else #else
vm_args.version= JNI_VERSION_1_2; vm_args.version= JNI_VERSION_1_2;
#endif #endif
vm_args.options= options; vm_args.options= sarOptions.get();
vm_args.nOptions= nOptions; vm_args.nOptions= options.size(); //TODO overflow
vm_args.ignoreUnrecognized= JNI_TRUE; vm_args.ignoreUnrecognized= JNI_TRUE;
/* We set a global flag which is used by the abort handler in order to /* We set a global flag which is used by the abort handler in order to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment