summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-12-18 12:41:12 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-12-18 12:48:38 +0100
commit0ec4ca54bd11752f3bc91b6e785053287c3618d9 (patch)
tree3dca07fd6b2a53ce5cd897cb057b3c63118055d9 /stoc
parent6f14709d55e343886abdfb73bcd530ace2a13e4f (diff)
Let JavaVirtualMachine::getJavaVm start the VM it already found
Since b69951996967a1c79e3a55dd13dd5609b19db6a1 "Drop support for /etc/opt/ure and ~/.ure from LibreOffice 4" there is no place any more where a plain URE will store information about a selected JVM, so JavaVirtualMachine::getJavaVM will go into an endless loop of jfw_startVM -> JFW_E_NO_SELECT -> jfw_findAndSelectJRE -> jfw_startVM -> ... The solution is to pass the JavaInfo determined by jfw_findAndSelectJRE into the second invocation of jfw_startVM (for which the parameter list of the latter needed to be changed), instead of relying on jfw_findAndSelectJRE and jfw_startVM implicitly communicating that information via user configuration files. Change-Id: I5799f04c457e8a849c67ed827dc5e134c6563362 (cherry picked from commit e5546342cb4e4f106257a7f7594d4356e6adbff3)
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/javavm/javavm.cxx28
1 files changed, 25 insertions, 3 deletions
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index b0e7225dfe09..a8e85748a15a 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -78,6 +78,7 @@
#include <time.h>
#include <memory>
#include <vector>
+#include "boost/noncopyable.hpp"
#include "boost/scoped_array.hpp"
#define OUSTR(x) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x ))
@@ -703,6 +704,23 @@ JavaVirtualMachine::getSupportedServiceNames()
return serviceGetSupportedServiceNames();
}
+namespace {
+
+struct JavaInfoGuard: private boost::noncopyable {
+ JavaInfoGuard(): info(0) {}
+
+ ~JavaInfoGuard() { jfw_freeJavaInfo(info); }
+
+ void clear() {
+ jfw_freeJavaInfo(info);
+ info = 0;
+ }
+
+ JavaInfo * info;
+};
+
+}
+
css::uno::Any SAL_CALL
JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
throw (css::uno::RuntimeException)
@@ -727,6 +745,7 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
if (aId != aProcessId)
return css::uno::Any();
+ JavaInfoGuard info;
while (!m_xVirtualMachine.is()) // retry until successful
{
// This is the second attempt to create Java. m_bDontCreateJvm is
@@ -773,7 +792,7 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
if (getenv("STOC_FORCE_NO_JRE"))
errcode = JFW_E_NO_SELECT;
else
- errcode = jfw_startVM(arOptions, index, & m_pJavaVm,
+ errcode = jfw_startVM(info.info, arOptions, index, & m_pJavaVm,
& pMainThreadEnv);
bool bStarted = false;
@@ -784,7 +803,8 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
{
// No Java configured. We silenty run the java configuration
// Java.
- javaFrameworkError errFind = jfw_findAndSelectJRE( NULL );
+ info.clear();
+ javaFrameworkError errFind = jfw_findAndSelectJRE(&info.info);
if (getenv("STOC_FORCE_NO_JRE"))
errFind = JFW_E_NO_JAVA_FOUND;
if (errFind == JFW_E_NONE)
@@ -861,7 +881,9 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
if (bExist == sal_False
&& ! (pJavaInfo->nRequirements & JFW_REQUIRE_NEEDRESTART))
{
- javaFrameworkError errFind = jfw_findAndSelectJRE( NULL );
+ info.clear();
+ javaFrameworkError errFind = jfw_findAndSelectJRE(
+ &info.info);
if (errFind == JFW_E_NONE)
{
continue;