[Libreoffice-commits] .: 3 commits - jvmfwk/inc jvmfwk/source odk/util stoc/source ure/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 03:48:01 PST 2012


 jvmfwk/inc/jvmfwk/framework.h   |    8 +-
 jvmfwk/source/framework.cxx     |  144 +++++++++++++++++++++-------------------
 odk/util/makefile.pmk           |    1 
 stoc/source/javavm/javavm.cxx   |   28 ++++++-
 ure/source/uretest/Makefile     |   15 +---
 ure/source/uretest/Makefile.pln |   15 +---
 6 files changed, 118 insertions(+), 93 deletions(-)

New commits:
commit e5546342cb4e4f106257a7f7594d4356e6adbff3
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Dec 18 12:41:12 2012 +0100

    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

diff --git a/jvmfwk/inc/jvmfwk/framework.h b/jvmfwk/inc/jvmfwk/framework.h
index 98c49c3..7f61f21 100644
--- a/jvmfwk/inc/jvmfwk/framework.h
+++ b/jvmfwk/inc/jvmfwk/framework.h
@@ -482,6 +482,8 @@ JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
     created and JFW_E_NEED_RESTART error is returned. If a VM is already running
     then a JFW_E_RUNNING_JVM is returned.</p>
 
+    @param pInfo
+    [in] optional pointer to a specific JRE; must be caller-freed if not NULL
     @param arOptions
     [in] the array containing additional start arguments or NULL.
     @param nSize
@@ -516,9 +518,9 @@ JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
     JFW_E_FAILED_VERSION the "Default Mode" is active. The JRE determined by
     <code>JAVA_HOME</code>does not meet the version requirements.
  */
-JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions,
-                                 sal_Int32 nSize, JavaVM **ppVM,
-                                 JNIEnv **ppEnv);
+JVMFWK_DLLPUBLIC javaFrameworkError SAL_CALL jfw_startVM(
+    JavaInfo const * pInfo, JavaVMOption * arOptions, sal_Int32 nSize,
+    JavaVM ** ppVM, JNIEnv ** ppEnv);
 
 /** determines the JRE that is to be used.
 
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index d6e687d..6bfe53a 100644
--- a/jvmfwk/source/framework.cxx
+++ b/jvmfwk/source/framework.cxx
@@ -25,6 +25,7 @@
 #include "osl/module.hxx"
 #include "jvmfwk/framework.h"
 #include "jvmfwk/vendorplugin.h"
+#include <cassert>
 #include <vector>
 #include <functional>
 #include <algorithm>
@@ -290,10 +291,12 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi
 #endif
 }
 
-javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOptions,
-                                 JavaVM **ppVM, JNIEnv **ppEnv)
+javaFrameworkError SAL_CALL jfw_startVM(
+    JavaInfo const * pInfo, JavaVMOption * arOptions, sal_Int32 cOptions,
+    JavaVM ** ppVM, JNIEnv ** ppEnv)
 {
 #ifndef SOLAR_JAVA
+    (void) pInfo;
     (void) arOptions;
     (void) cOptions;
     (void) ppVM;
@@ -320,84 +323,89 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
         std::vector<rtl::OString> vmParams;
         rtl::OString sUserClassPath;
         jfw::CJavaInfo aInfo;
-        jfw::JFW_MODE mode = jfw::getMode();
-        if (mode == jfw::JFW_MODE_APPLICATION)
+        if (pInfo == NULL)
         {
-            const jfw::MergedSettings settings;
-            if (sal_False == settings.getEnabled())
-                return JFW_E_JAVA_DISABLED;
-            aInfo.attach(settings.createJavaInfo());
-            //check if a Java has ever been selected
-            if (aInfo == NULL)
-                return JFW_E_NO_SELECT;
+            jfw::JFW_MODE mode = jfw::getMode();
+            if (mode == jfw::JFW_MODE_APPLICATION)
+            {
+                const jfw::MergedSettings settings;
+                if (sal_False == settings.getEnabled())
+                    return JFW_E_JAVA_DISABLED;
+                aInfo.attach(settings.createJavaInfo());
+                //check if a Java has ever been selected
+                if (aInfo == NULL)
+                    return JFW_E_NO_SELECT;
 
 #ifdef WNT
-            //Because on Windows there is no system setting that we can use to determine
-            //if Assistive Technology Tool support is needed, we ship a .reg file that the
-            //user can use to create a registry setting. When the user forgets to set
-            //the key before he starts the office then a JRE may be selected without access bridge.
-            //When he later sets the key then we select a JRE with accessibility support but
-            //only if the user has not manually changed the selected JRE in the options dialog.
-            if (jfw::isAccessibilitySupportDesired())
-            {
-                // If no JRE has been selected then we do not select one. This function shall then
-                //return JFW_E_NO_SELECT
-                if (aInfo != NULL &&
-                    (aInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE) == 0)
+                //Because on Windows there is no system setting that we can use to determine
+                //if Assistive Technology Tool support is needed, we ship a .reg file that the
+                //user can use to create a registry setting. When the user forgets to set
+                //the key before he starts the office then a JRE may be selected without access bridge.
+                //When he later sets the key then we select a JRE with accessibility support but
+                //only if the user has not manually changed the selected JRE in the options dialog.
+                if (jfw::isAccessibilitySupportDesired())
                 {
-                    //has the user manually selected a JRE?
-                    if (settings.getJavaInfoAttrAutoSelect() == true)
+                    // If no JRE has been selected then we do not select one. This function shall then
+                    //return JFW_E_NO_SELECT
+                    if (aInfo != NULL &&
+                        (aInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE) == 0)
                     {
-                        // if not then the automatism has previously selected a JRE
-                        //without accessibility support. We return JFW_E_NO_SELECT
-                        //to cause that we search for another JRE. The search code will
-                        //then prefer a JRE with accessibility support.
-                        return JFW_E_NO_SELECT;
+                        //has the user manually selected a JRE?
+                        if (settings.getJavaInfoAttrAutoSelect() == true)
+                        {
+                            // if not then the automatism has previously selected a JRE
+                            //without accessibility support. We return JFW_E_NO_SELECT
+                            //to cause that we search for another JRE. The search code will
+                            //then prefer a JRE with accessibility support.
+                            return JFW_E_NO_SELECT;
+                        }
                     }
                 }
-            }
 #endif
-            //check if the javavendors.xml has changed after a Java was selected
-            rtl::OString sVendorUpdate = jfw::getElementUpdated();
+                //check if the javavendors.xml has changed after a Java was selected
+                rtl::OString sVendorUpdate = jfw::getElementUpdated();
 
-            if (sVendorUpdate != settings.getJavaInfoAttrVendorUpdate())
-                return JFW_E_INVALID_SETTINGS;
+                if (sVendorUpdate != settings.getJavaInfoAttrVendorUpdate())
+                    return JFW_E_INVALID_SETTINGS;
 
-            //check if JAVA is disabled
-            //If Java is enabled, but it was disabled when this process was started
-            // then no preparational work, such as setting the LD_LIBRARY_PATH, was
-            //done. Therefore if a JRE needs it it must not be started.
-            if (g_bEnabledSwitchedOn &&
+                //check if JAVA is disabled
+                //If Java is enabled, but it was disabled when this process was started
+                // then no preparational work, such as setting the LD_LIBRARY_PATH, was
+                //done. Therefore if a JRE needs it it must not be started.
+                if (g_bEnabledSwitchedOn &&
                     (aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART))
-                return JFW_E_NEED_RESTART;
-
-            //Check if the selected Java was set in this process. If so it
-            //must not have the requirments flag JFW_REQUIRE_NEEDRESTART
-            if ((aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART)
-                &&
-                (jfw::wasJavaSelectedInSameProcess() == true))
-                return JFW_E_NEED_RESTART;
-
-            vmParams = settings.getVmParametersUtf8();
-            sUserClassPath = jfw::makeClassPathOption(settings.getUserClassPath());
-        } // end mode FWK_MODE_OFFICE
-        else if (mode == jfw::JFW_MODE_DIRECT)
-        {
-            errcode = jfw_getSelectedJRE(&aInfo.pInfo);
-            if (errcode != JFW_E_NONE)
-                return errcode;
-            //In direct mode the options are specified by bootstrap variables
-            //of the form UNO_JAVA_JFW_PARAMETER_1 .. UNO_JAVA_JFW_PARAMETER_n
-            vmParams = jfw::BootParams::getVMParameters();
-            sUserClassPath =
-                "-Djava.class.path=" + jfw::BootParams::getClasspath();
+                    return JFW_E_NEED_RESTART;
+
+                //Check if the selected Java was set in this process. If so it
+                //must not have the requirments flag JFW_REQUIRE_NEEDRESTART
+                if ((aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART)
+                    &&
+                    (jfw::wasJavaSelectedInSameProcess() == true))
+                    return JFW_E_NEED_RESTART;
+
+                vmParams = settings.getVmParametersUtf8();
+                sUserClassPath = jfw::makeClassPathOption(settings.getUserClassPath());
+            } // end mode FWK_MODE_OFFICE
+            else if (mode == jfw::JFW_MODE_DIRECT)
+            {
+                errcode = jfw_getSelectedJRE(&aInfo.pInfo);
+                if (errcode != JFW_E_NONE)
+                    return errcode;
+                //In direct mode the options are specified by bootstrap variables
+                //of the form UNO_JAVA_JFW_PARAMETER_1 .. UNO_JAVA_JFW_PARAMETER_n
+                vmParams = jfw::BootParams::getVMParameters();
+                sUserClassPath =
+                    "-Djava.class.path=" + jfw::BootParams::getClasspath();
+            }
+            else
+                OSL_ASSERT(0);
+            pInfo = aInfo.pInfo;
         }
-        else
-            OSL_ASSERT(0);
+        assert(pInfo != NULL);
 
         //get the function jfw_plugin_startJavaVirtualMachine
         jfw::VendorSettings aVendorSettings;
-        rtl::OUString sLibPath = aVendorSettings.getPluginLibrary(aInfo.getVendor());
+        rtl::OUString sLibPath = aVendorSettings.getPluginLibrary(pInfo->sVendor);
 
 #ifndef DISABLE_DYNLOADING
         osl::Module modulePlugin(sLibPath);
@@ -454,7 +462,7 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
         //start Java
         JavaVM *pVm = NULL;
         SAL_INFO("jvmfwk", "starting java");
-        javaPluginError plerr = (*pFunc)(aInfo, arOpt, index, & pVm, ppEnv);
+        javaPluginError plerr = (*pFunc)(pInfo, arOpt, index, & pVm, ppEnv);
         if (plerr == JFW_PLUGIN_E_VM_CREATION_FAILED)
         {
             errcode = JFW_E_VM_CREATION_FAILED;
@@ -677,13 +685,13 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
             jfw::NodeJava javaNode(jfw::NodeJava::USER);
             javaNode.setJavaInfo(aCurrentInfo,true);
             javaNode.write();
+            //remember that this JRE was selected in this process
+            jfw::setJavaSelected();
 
             if (pInfo !=NULL)
             {
                 //copy to out param
                 *pInfo = aCurrentInfo.cloneJavaInfo();
-                //remember that this JRE was selected in this process
-                jfw::setJavaSelected();
             }
         }
         else
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index b0e7225..a8e85748 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;
commit 39da5cf13337d2945b802587f5b0d9d4ef0512dd
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Dec 18 08:53:56 2012 +0100

    SDK's include/stl is long gone
    
    ...since 1628005298923ad15cc78dbad63669b701f5fd04 "Trying to remove the stlport
    mention from the code"
    
    Change-Id: I8785274bc2fdc9d97200aea245e1e8182249cde6

diff --git a/ure/source/uretest/Makefile b/ure/source/uretest/Makefile
index 051bcdc..e988a70 100644
--- a/ure/source/uretest/Makefile
+++ b/ure/source/uretest/Makefile
@@ -114,9 +114,8 @@ out.sdk/cppmain.uno.$(SHAREDLIB_EXT): out.sdk/cppmain.$(OBJ_EXT) | out.sdk
 
 out.sdk/cppmain.$(OBJ_EXT): cppmain.cc out.sdk/cpputypes.cppumaker.flag \
             out.sdk/types.cppumaker.flag | out.sdk
-	$(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ -I$(PRJ)/include/stl \
-            $(CC_INCLUDES) -Iout.sdk/include/cpputypes -Iout.sdk/include/types \
-            $(CC_DEFINES) $<
+	$(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ $(CC_INCLUDES) \
+            -Iout.sdk/include/cpputypes -Iout.sdk/include/types $(CC_DEFINES) $<
 
 
 out.sdk/cpptest.uno.$(SHAREDLIB_EXT): out.sdk/cpptest.$(OBJ_EXT) | out.sdk
@@ -125,9 +124,8 @@ out.sdk/cpptest.uno.$(SHAREDLIB_EXT): out.sdk/cpptest.$(OBJ_EXT) | out.sdk
 
 out.sdk/cpptest.$(OBJ_EXT): cpptest.cc out.sdk/cpputypes.cppumaker.flag \
             out.sdk/types.cppumaker.flag | out.sdk
-	$(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ -I$(PRJ)/include/stl \
-            $(CC_INCLUDES) -Iout.sdk/include/cpputypes -Iout.sdk/include/types \
-            $(CC_DEFINES) $<
+	$(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ $(CC_INCLUDES) \
+            -Iout.sdk/include/cpputypes -Iout.sdk/include/types $(CC_DEFINES) $<
 
 
 out.sdk/cppserver.uno.$(SHAREDLIB_EXT): out.sdk/cppserver.$(OBJ_EXT) | out.sdk
@@ -136,9 +134,8 @@ out.sdk/cppserver.uno.$(SHAREDLIB_EXT): out.sdk/cppserver.$(OBJ_EXT) | out.sdk
 
 out.sdk/cppserver.$(OBJ_EXT): cppserver.cc out.sdk/cpputypes.cppumaker.flag \
             out.sdk/types.cppumaker.flag | out.sdk
-	$(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ -I$(PRJ)/include/stl \
-            $(CC_INCLUDES) -Iout.sdk/include/cpputypes -Iout.sdk/include/types \
-            $(CC_DEFINES) $<
+	$(CC) $(CC_FLAGS) $(CC_OUTPUT_SWITCH)$@ $(CC_INCLUDES) \
+            -Iout.sdk/include/cpputypes -Iout.sdk/include/types $(CC_DEFINES) $<
 
 
 out.sdk/cpputypes.cppumaker.flag: | out.sdk
diff --git a/ure/source/uretest/Makefile.pln b/ure/source/uretest/Makefile.pln
index 2c5f62e..23e1f05 100644
--- a/ure/source/uretest/Makefile.pln
+++ b/ure/source/uretest/Makefile.pln
@@ -86,9 +86,8 @@ out.pln/cppmain.uno.so: out.pln/cppmain.o | out.pln out.pln/lib/libuno_cppu.so \
 out.pln/cppmain.o: cppmain.cc out.pln/cpputypes.cppumaker.flag \
             out.pln/types.cppumaker.flag | out.pln
 	g++ -c -o $@ -fpic -fvisibility=hidden -Wall -Wno-ctor-dtor-privacy \
-            -I $(SDK_HOME)/include/stl -I $(SDK_HOME)/include \
-            -I out.pln/include/cpputypes -I out.pln/include/types \
-            -DCPPU_ENV=gcc3 -DLINUX -DUNX $<
+            -I $(SDK_HOME)/include -I out.pln/include/cpputypes \
+            -I out.pln/include/types -DCPPU_ENV=gcc3 -DLINUX -DUNX $<
 
 
 out.pln/cpptest.uno.so: out.pln/cpptest.o | out.pln out.pln/lib/libuno_cppu.so \
@@ -99,9 +98,8 @@ out.pln/cpptest.uno.so: out.pln/cpptest.o | out.pln out.pln/lib/libuno_cppu.so \
 out.pln/cpptest.o: cpptest.cc out.pln/cpputypes.cppumaker.flag \
             out.pln/types.cppumaker.flag | out.pln
 	g++ -c -o $@ -fpic -fvisibility=hidden -Wall -Wno-ctor-dtor-privacy \
-            -I $(SDK_HOME)/include/stl -I $(SDK_HOME)/include \
-            -I out.pln/include/cpputypes -I out.pln/include/types \
-            -DCPPU_ENV=gcc3 -DLINUX -DUNX $<
+            -I $(SDK_HOME)/include -I out.pln/include/cpputypes \
+            -I out.pln/include/types -DCPPU_ENV=gcc3 -DLINUX -DUNX $<
 
 
 out.pln/cppserver.uno.so: out.pln/cppserver.o | out.pln \
@@ -113,9 +111,8 @@ out.pln/cppserver.uno.so: out.pln/cppserver.o | out.pln \
 out.pln/cppserver.o: cppserver.cc out.pln/cpputypes.cppumaker.flag \
             out.pln/types.cppumaker.flag | out.pln
 	g++ -c -o $@ -fpic -fvisibility=hidden -Wall -Wno-ctor-dtor-privacy \
-            -I $(SDK_HOME)/include/stl -I $(SDK_HOME)/include \
-            -I out.pln/include/cpputypes -I out.pln/include/types \
-            -DCPPU_ENV=gcc3 -DLINUX -DUNX $<
+            -I $(SDK_HOME)/include -I out.pln/include/cpputypes \
+            -I out.pln/include/types -DCPPU_ENV=gcc3 -DLINUX -DUNX $<
 
 
 out.pln/cpputypes.cppumaker.flag: | out.pln
commit 0a354ba6f865bcda4b9fdfe05912d07f54671cc6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Dec 18 08:50:32 2012 +0100

    Duplicate definition
    
    Change-Id: Ifd8d8ee0c101f77a0c8832a8e4379eabd6334e85

diff --git a/odk/util/makefile.pmk b/odk/util/makefile.pmk
index 0be6e89..8d753eb 100644
--- a/odk/util/makefile.pmk
+++ b/odk/util/makefile.pmk
@@ -36,7 +36,6 @@ DESTDIRINC=$(DESTDIR)/include
 DESTDIRJAR=$(DESTDIR)/classes
 DESTDIRSETTINGS=$(DESTDIR)/settings
 DESTDIREXAMPLES=$(DESTDIR)/examples
-DESTDIRINC=$(DESTDIR)/include
 DESTDIRCLASSES=$(DESTDIR)/classes
 DESTDIRDOCU=$(DESTDIR)/docs
 DESTDIRCOMMONDOCU=$(DESTDIRDOCU)/common


More information about the Libreoffice-commits mailing list