jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |   16 +++++++++++++---
 jvmfwk/source/framework.cxx                         |    8 ++++++--
 jvmfwk/source/fwkbase.cxx                           |    3 +++
 3 files changed, 22 insertions(+), 5 deletions(-)

New commits:
commit 566692d96b665b7f33fb5ceb7c19b419a3dc6797
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon Feb 21 11:55:21 2022 +0100
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Mar 2 14:41:01 2022 +0100

    Avoid unnecessary empty -Djava.class.path=
    
    Change-Id: Idcfe7321077b60381c0273910b1faeb444ef1fd8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130242
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>
    (cherry picked from commit 5e8f64e50f97d39e83a3358697be14db03566878)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130265
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 04bb6f736f92b93497bed28b7420fac97753f95e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130311
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx 
b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 5df7ef298795..dcc679b9f841 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -721,17 +721,22 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
     // all versions below 1.5.1
     options.emplace_back("abort", reinterpret_cast<void*>(abort_handler));
     bool hasStackSize = false;
+#ifdef UNX
+    // 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:
+    OString sAddPath = getPluginJarPath(pInfo->sVendor, 
pInfo->sLocation,pInfo->sVersion);
+#endif
     for (int i = 0; i < cOptions; i++)
     {
         OString opt(arOptions[i].optionString);
 #ifdef UNX
-        // 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:
         if (opt.startsWith("-Djava.class.path="))
         {
-            OString sAddPath = getPluginJarPath(pInfo->sVendor, 
pInfo->sLocation,pInfo->sVersion);
             if (!sAddPath.isEmpty())
+            {
                 opt += OStringChar(SAL_PATHSEPARATOR) + sAddPath;
+                sAddPath.clear();
+            }
         }
 #endif
         if (opt == "-Xint") {
@@ -776,6 +781,11 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
         }
 #endif
     }
+#ifdef UNX
+    if (!sAddPath.isEmpty()) {
+        options.emplace_back("-Djava.class.path=" + sAddPath, nullptr);
+    }
+#endif
 
     std::unique_ptr<JavaVMOption[]> sarOptions(new 
JavaVMOption[options.size()]);
     for (std::vector<Option>::size_type i = 0; i != options.size(); ++i) {
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index e478f80105ee..a8d051d19313 100644
--- a/jvmfwk/source/framework.cxx
+++ b/jvmfwk/source/framework.cxx
@@ -191,8 +191,12 @@ javaFrameworkError jfw_startVM(
                 //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();
+                auto const cp = jfw::BootParams::getClasspath();
+                if (!cp.isEmpty())
+                {
+                    sUserClassPath =
+                        "-Djava.class.path=" + cp;
+                }
             }
             else
                 OSL_ASSERT(false);
diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx
index dc7a8a153a5c..423407b82695 100644
--- a/jvmfwk/source/fwkbase.cxx
+++ b/jvmfwk/source/fwkbase.cxx
@@ -463,6 +463,9 @@ OString makeClassPathOption(std::u16string_view 
sUserClassPath)
     }
 
     sPaths = OUStringToOString(sBufCP.makeStringAndClear(), PathEncoding());
+    if (sPaths.isEmpty()) {
+        return "";
+    }
 
     OString sOptionClassPath = "-Djava.class.path=" + sPaths;
     return sOptionClassPath;

Reply via email to