diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-03-27 15:19:15 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-28 17:28:01 +0200 |
commit | e6871cdd25dd9e2d3995ea8cea3af10b50368907 (patch) | |
tree | f07d216d5a6a5cc021c72e2cacb76930d79dcc64 /jvmfwk/source | |
parent | e0cdb1e50b77b9a7e93904dd7af0e914a6432abd (diff) |
Don't pass empty option to JNI_CreateJavaVM
sUserClassPath may be empty (instead of containing "-Djava.class.path=...")
here, which older versions of Java have apparently silently ignored. But
Java 10 now fails with JNI_EINVAL (-6). (Happens e.g. during
CppunitTest_dbaccess_hsqldb_test.)
Reviewed-on: https://gerrit.libreoffice.org/51949
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
(cherry picked from commit 19d2ec6539f789dfbe38612e5e7807cac9fe0819)
Conflicts:
jvmfwk/source/framework.cxx
Change-Id: Ifd13222f0d0ae69547bd1a9fe0fd5eae47917d0a
Reviewed-on: https://gerrit.libreoffice.org/51978
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'jvmfwk/source')
-rw-r--r-- | jvmfwk/source/framework.cxx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index ddc5e6c19747..ea2f029153eb 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -248,22 +248,27 @@ javaFrameworkError jfw_startVM( // it contains the classpath and all options set in the //options dialog std::unique_ptr<JavaVMOption[]> sarJOptions( - new JavaVMOption[arOptions.size() + 2 + vmParams.size()]); + new JavaVMOption[ + arOptions.size() + (sUserClassPath.isEmpty() ? 1 : 2) + vmParams.size()]); JavaVMOption * arOpt = sarJOptions.get(); if (! arOpt) return JFW_E_ERROR; //The first argument is the classpath - arOpt[0].optionString= const_cast<char*>(sUserClassPath.getStr()); - arOpt[0].extraInfo = nullptr; + int index = 0; + if (!sUserClassPath.isEmpty()) { + arOpt[index].optionString= const_cast<char*>(sUserClassPath.getStr()); + arOpt[index].extraInfo = nullptr; + ++index; + } // Set a flag that this JVM has been created via the JNI Invocation API // (used, for example, by UNO remote bridges to share a common thread pool // factory among Java and native bridge implementations): - arOpt[1].optionString = const_cast<char *>("-Dorg.openoffice.native="); - arOpt[1].extraInfo = nullptr; + arOpt[index].optionString = const_cast<char *>("-Dorg.openoffice.native="); + arOpt[index].extraInfo = nullptr; + ++index; //add the options set by options dialog - int index = 2; typedef std::vector<OString>::const_iterator cit; for (cit i = vmParams.begin(); i != vmParams.end(); ++i) { |