summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,