[Libreoffice-commits] core.git: jvmfwk/plugins

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Mon May 10 12:39:36 UTC 2021


 jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java |   11 ----
 jvmfwk/plugins/sunmajor/pluginlib/util.cxx           |   42 +------------------
 2 files changed, 5 insertions(+), 48 deletions(-)

New commits:
commit b3541dea4889b9d0039554f87bd16e55189cf8b1
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun May 9 18:07:16 2021 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon May 10 14:38:57 2021 +0200

    I suspect that we unlikely to use JRE older than 1.3.1_07
    
    ... and so possibly can rely on -Dfile.encoding=UTF8 now.
    
    This reverts 79ac0685de0b19d856db70a208a8372cb589646c
    and 3428bace79d64a10cfcabb79e4caa608ee5db233.
    
    Change-Id: Ia9e09025691b200c0f79427e0f4efe500f9c81f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115272
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java b/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java
index 0d3503af385f..d863c359a489 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java
+++ b/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java
@@ -25,9 +25,6 @@ import java.util.*;
     unfortunately this works only with later update - versions (for example,
     1.3.1_07). Therefore we use this scheme. The property string has this form:
     name=value
-
-    Every character is cast to an integer which value is printed, followed by a
-    space. If all characters of the string are printed, then a new line is printed.
 */
 public class JREProperties
 {
@@ -40,13 +37,7 @@ public class JREProperties
             while (e.hasMoreElements()) {
                 String sProp = (String) e.nextElement();
                 String sCompleteProp = sProp + "=" + p.getProperty(sProp);
-                char[] arChars = new char[sCompleteProp.length()];
-                sCompleteProp.getChars(0, sCompleteProp.length(), arChars, 0);
-                for (int c = 0; c < arChars.length; c++) {
-                    System.out.print(String.valueOf((int) arChars[c]));
-                    System.out.print(" ");
-                }
-                System.out.print("\n");
+                System.out.println(sCompleteProp);
             }
         }
         catch(Exception e)
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 3b7a2beb2314..85001803bebc 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -113,9 +113,6 @@ static bool getSDKInfoFromRegistry(vector<OUString> & vecHome);
 static bool getJREInfoFromRegistry(vector<OUString>& vecJavaHome);
 #endif
 
-static bool decodeOutput(const OString& s, OUString* out);
-
-
 namespace
 {
 
@@ -384,11 +381,11 @@ bool getJavaProps(const OUString & exePath,
 #endif
 
     //prepare the arguments
-    sal_Int32 const cArgs = 3;
+    OUString arg0 = "-Dfile.encoding=UTF8";
     OUString arg1 = "-classpath";// + sClassPath;
     OUString arg2 = sClassPath;
     OUString arg3("JREProperties");
-    rtl_uString *args[cArgs] = {arg1.pData, arg2.pData, arg3.pData};
+    rtl_uString *args[] = {arg0.pData, arg1.pData, arg2.pData, arg3.pData};
 
     oslProcess javaProcess= nullptr;
     oslFileHandle fileOut= nullptr;
@@ -401,7 +398,7 @@ bool getJavaProps(const OUString & exePath,
     oslProcessError procErr =
         osl_executeProcess_WithRedirectedIO( exePath.pData,//usExe.pData,
                                              args,
-                                             cArgs,                 //sal_uInt32   nArguments,
+                                             SAL_N_ELEMENTS(args), //sal_uInt32   nArguments,
                                              osl_Process_HIDDEN, //oslProcessOption Options,
                                              nullptr, //oslSecurity Security,
                                              usStartDir.pData,//usStartDir.pData,//usWorkDir.pData, //rtl_uString *strWorkDir,
@@ -438,9 +435,7 @@ bool getJavaProps(const OUString & exePath,
         rs = stdoutReader.readLine( & aLine);
         if (rs != FileHandleReader::RESULT_OK)
             break;
-        OUString sLine;
-        if (!decodeOutput(aLine, &sLine))
-            continue;
+        OUString sLine = OStringToOUString(aLine, RTL_TEXTENCODING_UTF8);
         JFW_TRACE2("  \"" << sLine << "\"");
         sLine = sLine.trim();
         if (sLine.isEmpty())
@@ -478,35 +473,6 @@ bool getJavaProps(const OUString & exePath,
     return ret;
 }
 
-/* converts the properties printed by JREProperties.class into
-    readable strings. The strings are encoded as integer values separated
-    by spaces.
- */
-bool decodeOutput(const OString& s, OUString* out)
-{
-    OSL_ASSERT(out != nullptr);
-    OUStringBuffer buff(512);
-    sal_Int32 nIndex = 0;
-    do
-    {
-        OString aToken = s.getToken( 0, ' ', nIndex );
-        if (!aToken.isEmpty())
-        {
-            for (sal_Int32 i = 0; i < aToken.getLength(); ++i)
-            {
-                if (aToken[i] < '0' || aToken[i] > '9')
-                    return false;
-            }
-            sal_Unicode value = static_cast<sal_Unicode>(aToken.toInt32());
-            buff.append(value);
-        }
-    } while (nIndex >= 0);
-
-    *out = buff.makeStringAndClear();
-    return true;
-}
-
-
 #if defined(_WIN32)
 
 static bool getJavaInfoFromRegistry(const wchar_t* szRegKey,


More information about the Libreoffice-commits mailing list