summaryrefslogtreecommitdiff
path: root/jvmfwk
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-07-07 11:28:47 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-07-07 15:07:32 +0200
commit515b72fb9275c76ff9f26b0c3c47cac706d92af0 (patch)
tree591b9c7b0099ac527cd24cbe3f87e3c1f9aec9e8 /jvmfwk
parent716c20460372e3f3543f4dc81a49368a5291cd34 (diff)
Revert "I suspect that we unlikely to use JRE older than 1.3.1_07"
This reverts commit b3541dea4889b9d0039554f87bd16e55189cf8b1. Reason for revert: The code did not just deal with text encoding differences, but also with properties whose value contains line breaks. For example, OpenJ9 has line breaks in "java.vm.info" and "java.fullversion", which now trigger asserts; also there is "line.separator" but this one happened not to cause problems so far. Change-Id: I3ded8e824e96b6fcf21677dd9ba72cbf58c1d261 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118495 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'jvmfwk')
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java11
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx42
2 files changed, 48 insertions, 5 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java b/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java
index d863c359a489..0d3503af385f 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java
+++ b/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java
@@ -25,6 +25,9 @@ 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
{
@@ -37,7 +40,13 @@ public class JREProperties
while (e.hasMoreElements()) {
String sProp = (String) e.nextElement();
String sCompleteProp = sProp + "=" + p.getProperty(sProp);
- System.out.println(sCompleteProp);
+ 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");
}
}
catch(Exception e)
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 90911ee7d153..df14c0841bf9 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -114,6 +114,9 @@ static bool getSDKInfoFromRegistry(vector<OUString> & vecHome);
static bool getJREInfoFromRegistry(vector<OUString>& vecJavaHome);
#endif
+static bool decodeOutput(const OString& s, OUString* out);
+
+
namespace
{
@@ -382,11 +385,11 @@ bool getJavaProps(const OUString & exePath,
#endif
//prepare the arguments
- OUString arg0 = "-Dfile.encoding=UTF8";
+ sal_Int32 const cArgs = 3;
OUString arg1 = "-classpath";// + sClassPath;
OUString arg2 = sClassPath;
OUString arg3("JREProperties");
- rtl_uString *args[] = {arg0.pData, arg1.pData, arg2.pData, arg3.pData};
+ rtl_uString *args[cArgs] = {arg1.pData, arg2.pData, arg3.pData};
oslProcess javaProcess= nullptr;
oslFileHandle fileOut= nullptr;
@@ -399,7 +402,7 @@ bool getJavaProps(const OUString & exePath,
oslProcessError procErr =
osl_executeProcess_WithRedirectedIO( exePath.pData,//usExe.pData,
args,
- SAL_N_ELEMENTS(args), //sal_uInt32 nArguments,
+ cArgs, //sal_uInt32 nArguments,
osl_Process_HIDDEN, //oslProcessOption Options,
nullptr, //oslSecurity Security,
usStartDir.pData,//usStartDir.pData,//usWorkDir.pData, //rtl_uString *strWorkDir,
@@ -436,7 +439,9 @@ bool getJavaProps(const OUString & exePath,
rs = stdoutReader.readLine( & aLine);
if (rs != FileHandleReader::RESULT_OK)
break;
- OUString sLine = OStringToOUString(aLine, RTL_TEXTENCODING_UTF8);
+ OUString sLine;
+ if (!decodeOutput(aLine, &sLine))
+ continue;
JFW_TRACE2(" \"" << sLine << "\"");
sLine = sLine.trim();
if (sLine.isEmpty())
@@ -474,6 +479,35 @@ 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,