2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 19:49:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 16:47:52 +00:00
|
|
|
|
2017-04-11 19:10:23 +02:00
|
|
|
#include <sal/config.h>
|
2018-08-05 00:50:24 +02:00
|
|
|
#include <sal/log.hxx>
|
2017-04-11 19:10:23 +02:00
|
|
|
|
|
|
|
#include <cassert>
|
2015-06-15 17:58:15 +09:00
|
|
|
#include <memory>
|
2017-04-13 15:18:14 +02:00
|
|
|
|
2019-03-09 17:28:06 +01:00
|
|
|
#include <rtl/ref.hxx>
|
2017-10-23 22:38:59 +02:00
|
|
|
#include <rtl/ustring.hxx>
|
2019-03-09 17:28:06 +01:00
|
|
|
#include <osl/diagnose.h>
|
2017-10-23 22:38:59 +02:00
|
|
|
#include <osl/thread.hxx>
|
|
|
|
#include <jvmfwk/framework.hxx>
|
2019-03-09 17:28:06 +01:00
|
|
|
#include <vendorbase.hxx>
|
2017-10-23 22:38:59 +02:00
|
|
|
#include <vendorplugin.hxx>
|
2004-04-19 14:57:02 +00:00
|
|
|
#include <vector>
|
2004-11-09 15:12:48 +00:00
|
|
|
#include <algorithm>
|
2004-04-19 14:57:02 +00:00
|
|
|
#include "framework.hxx"
|
2017-10-23 22:38:59 +02:00
|
|
|
#include <fwkutil.hxx>
|
|
|
|
#include <elements.hxx>
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
#include <fwkbase.hxx>
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
namespace {
|
2004-04-27 14:22:15 +00:00
|
|
|
|
2012-10-08 11:04:57 +03:00
|
|
|
static bool g_bEnabledSwitchedOn = false;
|
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
static JavaVM * g_pJavaVM = nullptr;
|
2004-05-07 13:49:41 +00:00
|
|
|
|
2014-02-18 12:01:43 +01:00
|
|
|
bool areEqualJavaInfo(
|
2004-04-27 14:22:15 +00:00
|
|
|
JavaInfo const * pInfoA,JavaInfo const * pInfoB)
|
|
|
|
{
|
|
|
|
return jfw_areEqualJavaInfo(pInfoA, pInfoB);
|
|
|
|
}
|
2012-10-08 11:04:57 +03:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-11 18:04:54 +02:00
|
|
|
javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparInfo)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2017-04-11 19:10:23 +02:00
|
|
|
assert(pparInfo != nullptr);
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
|
|
|
|
jfw::VendorSettings aVendorSettings;
|
|
|
|
//Add the JavaInfos found by jfw_plugin_getAllJavaInfos to the vector
|
2017-04-13 15:18:14 +02:00
|
|
|
std::vector<std::unique_ptr<JavaInfo>> vecInfo;
|
2004-11-09 15:12:48 +00:00
|
|
|
//get the list of paths to jre locations which have been
|
|
|
|
//added manually
|
2007-06-13 06:57:42 +00:00
|
|
|
const jfw::MergedSettings settings;
|
2013-04-07 12:06:47 +02:00
|
|
|
const std::vector<OUString>& vecJRELocations =
|
2007-06-13 06:57:42 +00:00
|
|
|
settings.getJRELocations();
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
//Use all plug-in libraries to get Java installations.
|
|
|
|
std::vector<std::unique_ptr<JavaInfo>> arInfos;
|
|
|
|
std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos;
|
|
|
|
javaPluginError plerr = jfw_plugin_getAllJavaInfos(
|
|
|
|
true,
|
|
|
|
aVendorSettings,
|
|
|
|
& arInfos,
|
|
|
|
infos);
|
2004-04-21 08:30:36 +00:00
|
|
|
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
if (plerr != javaPluginError::NONE)
|
|
|
|
return JFW_E_ERROR;
|
2004-11-09 15:12:48 +00:00
|
|
|
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
for (auto & j: arInfos)
|
|
|
|
vecInfo.push_back(std::move(j));
|
2004-11-09 15:12:48 +00:00
|
|
|
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
//Check if any plugin can detect JREs at the location
|
|
|
|
// of the paths added by jfw_addJRELocation
|
|
|
|
//Check every manually added location
|
|
|
|
for (auto const & ii: vecJRELocations)
|
|
|
|
{
|
|
|
|
std::unique_ptr<JavaInfo> aInfo;
|
|
|
|
plerr = jfw_plugin_getJavaInfoByPath(
|
|
|
|
ii,
|
|
|
|
aVendorSettings,
|
|
|
|
&aInfo);
|
|
|
|
if (plerr == javaPluginError::NoJre)
|
|
|
|
continue;
|
|
|
|
if (plerr == javaPluginError::FailedVersion)
|
|
|
|
continue;
|
|
|
|
else if (plerr != javaPluginError::NONE)
|
|
|
|
return JFW_E_ERROR;
|
2004-11-09 15:12:48 +00:00
|
|
|
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
// Was this JRE already added?
|
|
|
|
if (std::none_of(
|
|
|
|
vecInfo.begin(), vecInfo.end(),
|
|
|
|
[&aInfo](std::unique_ptr<JavaInfo> const & info) {
|
|
|
|
return areEqualJavaInfo(
|
|
|
|
info.get(), aInfo.get());
|
|
|
|
}))
|
2004-07-23 10:54:39 +00:00
|
|
|
{
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
vecInfo.push_back(std::move(aInfo));
|
2004-07-23 10:54:39 +00:00
|
|
|
}
|
2004-04-21 08:30:36 +00:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2017-04-13 15:18:14 +02:00
|
|
|
*pparInfo = std::move(vecInfo);
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2016-11-16 23:03:09 +01:00
|
|
|
return JFW_E_NONE;
|
2004-04-21 08:30:36 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-04-21 11:16:19 +00:00
|
|
|
{
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message);
|
2016-11-16 23:03:09 +01:00
|
|
|
return e.errorCode;
|
2004-04-21 11:16:19 +00:00
|
|
|
}
|
2004-04-21 08:30:36 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 15:13:45 +01:00
|
|
|
javaFrameworkError jfw_startVM(
|
2017-04-12 23:10:11 +02:00
|
|
|
JavaInfo const * pInfo, std::vector<OUString> const & arOptions,
|
2012-12-18 12:41:12 +01:00
|
|
|
JavaVM ** ppVM, JNIEnv ** ppEnv)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2017-04-11 19:10:23 +02:00
|
|
|
assert(ppVM != nullptr);
|
2004-04-19 14:57:02 +00:00
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2007-06-13 06:57:42 +00:00
|
|
|
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
|
|
|
|
//We keep this pointer so we can determine if a VM has already
|
|
|
|
//been created.
|
2015-11-10 10:18:19 +01:00
|
|
|
if (g_pJavaVM != nullptr)
|
2004-11-09 15:12:48 +00:00
|
|
|
return JFW_E_RUNNING_JVM;
|
2004-05-17 12:55:32 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
std::vector<OString> vmParams;
|
|
|
|
OString sUserClassPath;
|
2017-04-11 18:04:54 +02:00
|
|
|
std::unique_ptr<JavaInfo> aInfo;
|
2015-11-10 10:18:19 +01:00
|
|
|
if (pInfo == nullptr)
|
2004-05-13 10:15:02 +00:00
|
|
|
{
|
2012-12-18 12:41:12 +01:00
|
|
|
jfw::JFW_MODE mode = jfw::getMode();
|
|
|
|
if (mode == jfw::JFW_MODE_APPLICATION)
|
|
|
|
{
|
|
|
|
const jfw::MergedSettings settings;
|
2014-01-21 11:46:57 +01:00
|
|
|
if (!settings.getEnabled())
|
2012-12-18 12:41:12 +01:00
|
|
|
return JFW_E_JAVA_DISABLED;
|
2017-04-13 12:08:05 +02:00
|
|
|
aInfo = settings.createJavaInfo();
|
2012-12-18 12:41:12 +01:00
|
|
|
//check if a Java has ever been selected
|
2017-04-11 18:04:54 +02:00
|
|
|
if (!aInfo)
|
2012-12-18 12:41:12 +01:00
|
|
|
return JFW_E_NO_SELECT;
|
2004-12-16 10:47:25 +00:00
|
|
|
|
2016-02-16 14:14:43 +02:00
|
|
|
#ifdef _WIN32
|
2012-12-18 12:41:12 +01:00
|
|
|
//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())
|
2004-05-17 12:55:32 +00:00
|
|
|
{
|
2012-12-18 12:41:12 +01:00
|
|
|
// If no JRE has been selected then we do not select one. This function shall then
|
|
|
|
//return JFW_E_NO_SELECT
|
2017-04-11 18:04:54 +02:00
|
|
|
if (aInfo &&
|
2012-12-18 12:41:12 +01:00
|
|
|
(aInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE) == 0)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2012-12-18 12:41:12 +01:00
|
|
|
//has the user manually selected a JRE?
|
2016-10-14 16:54:24 +02:00
|
|
|
if (settings.getJavaInfoAttrAutoSelect())
|
2012-12-18 12:41:12 +01:00
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-05-17 12:55:32 +00:00
|
|
|
}
|
2004-05-13 10:15:02 +00:00
|
|
|
#endif
|
2012-12-18 12:41:12 +01:00
|
|
|
//check if the javavendors.xml has changed after a Java was selected
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sVendorUpdate = jfw::getElementUpdated();
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2012-12-18 12:41:12 +01:00
|
|
|
if (sVendorUpdate != settings.getJavaInfoAttrVendorUpdate())
|
|
|
|
return JFW_E_INVALID_SETTINGS;
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2012-12-18 12:41:12 +01:00
|
|
|
//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
|
2014-11-10 15:05:25 +01:00
|
|
|
//done. Therefore if a JRE needs it, it must not be started.
|
2012-12-18 12:41:12 +01:00
|
|
|
if (g_bEnabledSwitchedOn &&
|
2004-11-09 15:12:48 +00:00
|
|
|
(aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART))
|
2012-12-18 12:41:12 +01:00
|
|
|
return JFW_E_NEED_RESTART;
|
|
|
|
|
|
|
|
//Check if the selected Java was set in this process. If so it
|
2017-03-03 17:08:55 +01:00
|
|
|
//must not have the requirements flag JFW_REQUIRE_NEEDRESTART
|
2012-12-18 12:41:12 +01:00
|
|
|
if ((aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART)
|
2015-04-27 15:28:09 +02:00
|
|
|
&& jfw::wasJavaSelectedInSameProcess())
|
2012-12-18 12:41:12 +01:00
|
|
|
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)
|
|
|
|
{
|
2017-04-11 18:04:54 +02:00
|
|
|
errcode = jfw_getSelectedJRE(&aInfo);
|
2012-12-18 12:41:12 +01:00
|
|
|
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
|
2017-05-07 17:03:35 +10:00
|
|
|
OSL_ASSERT(false);
|
2017-04-11 18:04:54 +02:00
|
|
|
pInfo = aInfo.get();
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2015-11-10 10:18:19 +01:00
|
|
|
assert(pInfo != nullptr);
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2004-11-09 15:12:48 +00:00
|
|
|
// create JavaVMOptions array that is passed to the plugin
|
|
|
|
// it contains the classpath and all options set in the
|
|
|
|
//options dialog
|
2015-06-15 17:58:15 +09:00
|
|
|
std::unique_ptr<JavaVMOption[]> sarJOptions(
|
2018-03-27 15:19:15 +02:00
|
|
|
new JavaVMOption[
|
|
|
|
arOptions.size() + (sUserClassPath.isEmpty() ? 1 : 2) + vmParams.size()]);
|
2004-11-09 15:12:48 +00:00
|
|
|
JavaVMOption * arOpt = sarJOptions.get();
|
|
|
|
if (! arOpt)
|
2004-05-18 11:51:54 +00:00
|
|
|
return JFW_E_ERROR;
|
|
|
|
|
2004-11-09 15:12:48 +00:00
|
|
|
//The first argument is the classpath
|
2018-03-27 15:19:15 +02:00
|
|
|
int index = 0;
|
|
|
|
if (!sUserClassPath.isEmpty()) {
|
|
|
|
arOpt[index].optionString= const_cast<char*>(sUserClassPath.getStr());
|
|
|
|
arOpt[index].extraInfo = nullptr;
|
|
|
|
++index;
|
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
// Set a flag that this JVM has been created via the JNI Invocation API
|
|
|
|
// (used, for example, by UNO remote bridges to share a common thread pool
|
|
|
|
// factory among Java and native bridge implementations):
|
2018-03-27 15:19:15 +02:00
|
|
|
arOpt[index].optionString = const_cast<char *>("-Dorg.openoffice.native=");
|
|
|
|
arOpt[index].extraInfo = nullptr;
|
|
|
|
++index;
|
2004-11-09 15:12:48 +00:00
|
|
|
|
|
|
|
//add the options set by options dialog
|
2017-10-12 20:32:17 +02:00
|
|
|
for (auto const & vmParam : vmParams)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2019-12-19 09:46:58 +02:00
|
|
|
arOpt[index].optionString = const_cast<char*>(vmParam.getStr());
|
2015-11-10 10:18:19 +01:00
|
|
|
arOpt[index].extraInfo = nullptr;
|
2004-11-09 15:12:48 +00:00
|
|
|
index ++;
|
|
|
|
}
|
|
|
|
//add all options of the arOptions argument
|
2018-04-12 08:26:34 +02:00
|
|
|
std::vector<OString> convertedOptions;
|
2017-04-12 23:10:11 +02:00
|
|
|
for (auto const & ii: arOptions)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2017-04-12 23:10:11 +02:00
|
|
|
OString conv = OUStringToOString(ii, osl_getThreadTextEncoding());
|
2018-04-12 08:26:34 +02:00
|
|
|
convertedOptions.push_back(conv);
|
|
|
|
// keep conv.getStr() alive until after the call to
|
|
|
|
// jfw_plugin_startJavaVirtualMachine below
|
2017-04-12 23:10:11 +02:00
|
|
|
arOpt[index].optionString = const_cast<char *>(conv.getStr());
|
|
|
|
arOpt[index].extraInfo = nullptr;
|
2004-11-09 15:12:48 +00:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//start Java
|
2015-11-10 10:18:19 +01:00
|
|
|
JavaVM *pVm = nullptr;
|
2013-03-22 08:25:43 +02:00
|
|
|
SAL_INFO("jfw", "Starting Java");
|
2014-10-09 17:24:52 +02:00
|
|
|
javaPluginError plerr = jfw_plugin_startJavaVirtualMachine(pInfo, arOpt, index, & pVm, ppEnv);
|
2016-05-20 15:45:02 +02:00
|
|
|
if (plerr == javaPluginError::VmCreationFailed)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = JFW_E_VM_CREATION_FAILED;
|
|
|
|
}
|
2016-05-20 15:45:02 +02:00
|
|
|
else if (plerr != javaPluginError::NONE )
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = JFW_E_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_pJavaVM = pVm;
|
|
|
|
*ppVM = pVm;
|
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-11-09 15:12:48 +00:00
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2004-05-07 13:49:41 +00:00
|
|
|
return errcode;
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2004-04-23 07:40:39 +00:00
|
|
|
/** We do not use here jfw_findAllJREs and then check if a JavaInfo
|
|
|
|
meets the requirements, because that means using all plug-ins, which
|
2014-09-10 14:56:25 +02:00
|
|
|
may take quite a while. The implementation first inspects JAVA_HOME and
|
|
|
|
PATH environment variables. If no suitable JavaInfo is found there, it
|
|
|
|
inspects all JavaInfos found by the jfw_plugin_get* functions.
|
2004-04-23 07:40:39 +00:00
|
|
|
*/
|
2017-04-11 18:04:54 +02:00
|
|
|
javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
2006-06-19 23:11:00 +00:00
|
|
|
sal_uInt64 nFeatureFlags = 0;
|
2017-04-13 12:27:50 +02:00
|
|
|
std::unique_ptr<JavaInfo> aCurrentInfo;
|
2014-09-10 14:56:25 +02:00
|
|
|
//Determine if accessibility support is needed
|
2004-11-09 15:12:48 +00:00
|
|
|
bool bSupportAccessibility = jfw::isAccessibilitySupportDesired();
|
|
|
|
nFeatureFlags = bSupportAccessibility ?
|
2019-12-26 01:03:08 +03:00
|
|
|
JFW_FEATURE_ACCESSBRIDGE : 0;
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2014-09-10 14:56:25 +02:00
|
|
|
|
|
|
|
// 'bInfoFound' indicates whether a Java installation has been found
|
|
|
|
// that supports all desired features
|
|
|
|
bool bInfoFound = false;
|
|
|
|
|
|
|
|
// get list of vendors for Java installations
|
2004-11-09 15:12:48 +00:00
|
|
|
jfw::VendorSettings aVendorSettings;
|
|
|
|
|
2014-12-15 16:42:03 +01:00
|
|
|
std::vector<rtl::Reference<jfw_plugin::VendorBase>> infos;
|
|
|
|
|
2014-09-10 14:56:25 +02:00
|
|
|
// first inspect Java installation that the JAVA_HOME
|
|
|
|
// environment variable points to (if it is set)
|
2017-04-13 15:25:28 +02:00
|
|
|
if (jfw_plugin_getJavaInfoFromJavaHome(
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
aVendorSettings, &aCurrentInfo, infos)
|
2016-05-20 15:45:02 +02:00
|
|
|
== javaPluginError::NONE)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
|
|
|
// compare features
|
|
|
|
// if the user does not require any features (nFeatureFlags = 0)
|
|
|
|
// or the Java installation provides all features, then this installation is used
|
2017-04-13 15:25:28 +02:00
|
|
|
if ((aCurrentInfo->nFeatures & nFeatureFlags) == nFeatureFlags)
|
2004-04-23 07:40:39 +00:00
|
|
|
{
|
2014-09-10 14:56:25 +02:00
|
|
|
bInfoFound = true;
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2014-09-10 14:56:25 +02:00
|
|
|
}
|
2004-04-23 07:40:39 +00:00
|
|
|
|
2014-09-10 14:56:25 +02:00
|
|
|
// if no Java installation providing all features was detected by using JAVA_HOME,
|
|
|
|
// query PATH for Java installations
|
|
|
|
if (!bInfoFound)
|
|
|
|
{
|
2017-04-13 15:19:17 +02:00
|
|
|
std::vector<std::unique_ptr<JavaInfo>> vecJavaInfosFromPath;
|
2014-12-15 16:42:03 +01:00
|
|
|
if (jfw_plugin_getJavaInfosFromPath(
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
aVendorSettings, vecJavaInfosFromPath, infos)
|
2016-05-20 15:45:02 +02:00
|
|
|
== javaPluginError::NONE)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
2017-04-13 15:19:17 +02:00
|
|
|
for (auto & pJInfo: vecJavaInfosFromPath)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2017-04-13 15:19:17 +02:00
|
|
|
// if the current Java installation implements all required features: use it
|
|
|
|
if ((pJInfo->nFeatures & nFeatureFlags) == nFeatureFlags)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
2017-04-13 15:19:17 +02:00
|
|
|
aCurrentInfo = std::move(pJInfo);
|
|
|
|
bInfoFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!aCurrentInfo)
|
|
|
|
{
|
|
|
|
// current Java installation does not provide all features
|
|
|
|
// but no Java installation has been detected before
|
|
|
|
// -> remember the current one until one is found
|
|
|
|
// that provides all features
|
|
|
|
aCurrentInfo = std::move(pJInfo);
|
2014-09-10 14:56:25 +02:00
|
|
|
}
|
2004-04-23 07:40:39 +00:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-10 14:56:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
// if no suitable Java installation has been found yet:
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
// first use jfw_plugin_getAllJavaInfos to find a suitable Java installation,
|
2014-09-10 14:56:25 +02:00
|
|
|
// then try paths that have been added manually
|
|
|
|
if (!bInfoFound)
|
|
|
|
{
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
//get all installations
|
|
|
|
std::vector<std::unique_ptr<JavaInfo>> arInfos;
|
|
|
|
javaPluginError plerr = jfw_plugin_getAllJavaInfos(
|
|
|
|
false,
|
|
|
|
aVendorSettings,
|
|
|
|
& arInfos,
|
|
|
|
infos);
|
|
|
|
|
|
|
|
if (plerr == javaPluginError::NONE)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2014-09-10 14:56:25 +02:00
|
|
|
//iterate over all installations to find the best which has
|
|
|
|
//all features
|
2017-04-13 16:54:32 +02:00
|
|
|
for (auto & pJInfo: arInfos)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
|
|
|
// compare features
|
|
|
|
// If the user does not require any features (nFeatureFlags = 0)
|
|
|
|
// then the first installation is used
|
|
|
|
if ((pJInfo->nFeatures & nFeatureFlags) == nFeatureFlags)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2014-09-10 14:56:25 +02:00
|
|
|
//the just found Java implements all required features
|
|
|
|
//currently there is only accessibility!!!
|
2017-04-13 16:54:32 +02:00
|
|
|
aCurrentInfo = std::move(pJInfo);
|
2014-09-10 14:56:25 +02:00
|
|
|
break;
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2017-04-13 12:27:50 +02:00
|
|
|
else if (!aCurrentInfo)
|
|
|
|
{
|
|
|
|
// We remember the first installation in aCurrentInfo if
|
|
|
|
// no JavaInfo has been found before:
|
2017-04-13 16:54:32 +02:00
|
|
|
aCurrentInfo = std::move(pJInfo);
|
2017-04-13 12:27:50 +02:00
|
|
|
}
|
2014-09-10 14:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
|
2017-04-13 12:27:50 +02:00
|
|
|
if (!aCurrentInfo)
|
2014-09-10 14:56:25 +02:00
|
|
|
{//The plug-ins did not find a suitable Java. Now try the paths which have been
|
|
|
|
//added manually.
|
|
|
|
//get the list of paths to jre locations which have been added manually
|
|
|
|
const jfw::MergedSettings settings;
|
|
|
|
//node.loadFromSettings();
|
|
|
|
const std::vector<OUString> & vecJRELocations =
|
|
|
|
settings.getJRELocations();
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
//use all plug-ins to determine the JavaInfo objects
|
|
|
|
for (auto const & JRELocation : vecJRELocations)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
std::unique_ptr<JavaInfo> aInfo;
|
|
|
|
javaPluginError err = jfw_plugin_getJavaInfoByPath(
|
|
|
|
JRELocation,
|
|
|
|
aVendorSettings,
|
|
|
|
&aInfo);
|
|
|
|
if (err == javaPluginError::NoJre)
|
|
|
|
continue;
|
|
|
|
if (err == javaPluginError::FailedVersion)
|
|
|
|
continue;
|
|
|
|
else if (err !=javaPluginError::NONE)
|
|
|
|
return JFW_E_ERROR;
|
|
|
|
|
|
|
|
if (aInfo)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
// compare features
|
|
|
|
// If the user does not require any features (nFeatureFlags = 0)
|
|
|
|
// then the first installation is used
|
|
|
|
if ((aInfo->nFeatures & nFeatureFlags) == nFeatureFlags)
|
2014-09-10 14:56:25 +02:00
|
|
|
{
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
//the just found Java implements all required features
|
|
|
|
//currently there is only accessibility!!!
|
|
|
|
aCurrentInfo = std::move(aInfo);
|
|
|
|
break;
|
2014-09-10 14:56:25 +02:00
|
|
|
}
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
else if (!aCurrentInfo)
|
|
|
|
{
|
|
|
|
// We remember the very first installation in
|
|
|
|
// aCurrentInfo:
|
|
|
|
aCurrentInfo = std::move(aInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}//end iterate over paths
|
2014-09-10 14:56:25 +02:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2017-04-13 12:27:50 +02:00
|
|
|
if (aCurrentInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2012-08-10 15:52:22 +02:00
|
|
|
jfw::NodeJava javaNode(jfw::NodeJava::USER);
|
2017-04-13 12:27:50 +02:00
|
|
|
javaNode.setJavaInfo(aCurrentInfo.get(),true);
|
2007-06-13 06:57:42 +00:00
|
|
|
javaNode.write();
|
2012-12-18 12:41:12 +01:00
|
|
|
//remember that this JRE was selected in this process
|
|
|
|
jfw::setJavaSelected();
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2015-11-10 10:18:19 +01:00
|
|
|
if (pInfo !=nullptr)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2017-04-13 12:27:50 +02:00
|
|
|
*pInfo = std::move(aCurrentInfo);
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errcode = JFW_E_NO_JAVA_FOUND;
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-11-09 15:12:48 +00:00
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
2012-10-08 11:04:57 +03:00
|
|
|
|
2016-03-10 15:13:45 +01:00
|
|
|
bool jfw_areEqualJavaInfo(JavaInfo const * pInfoA,JavaInfo const * pInfoB)
|
2004-04-21 11:16:19 +00:00
|
|
|
{
|
|
|
|
if (pInfoA == pInfoB)
|
2016-03-10 15:10:39 +01:00
|
|
|
return true;
|
2015-11-10 10:18:19 +01:00
|
|
|
if (pInfoA == nullptr || pInfoB == nullptr)
|
2016-03-10 15:10:39 +01:00
|
|
|
return false;
|
2016-03-10 17:11:10 +01:00
|
|
|
if (pInfoA->sVendor == pInfoB->sVendor
|
|
|
|
&& pInfoA->sLocation == pInfoB->sLocation
|
|
|
|
&& pInfoA->sVersion == pInfoB->sVersion
|
2004-04-21 11:16:19 +00:00
|
|
|
&& pInfoA->nFeatures == pInfoB->nFeatures
|
|
|
|
&& pInfoA->nRequirements == pInfoB->nRequirements
|
2016-03-10 17:32:48 +01:00
|
|
|
&& pInfoA->arVendorData == pInfoB->arVendorData)
|
2004-04-21 11:16:19 +00:00
|
|
|
{
|
2016-03-10 15:10:39 +01:00
|
|
|
return true;
|
2004-04-21 11:16:19 +00:00
|
|
|
}
|
2016-03-10 15:10:39 +01:00
|
|
|
return false;
|
2004-04-21 11:16:19 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
|
2017-04-11 18:04:54 +02:00
|
|
|
javaFrameworkError jfw_getSelectedJRE(std::unique_ptr<JavaInfo> *ppInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2017-04-11 19:10:23 +02:00
|
|
|
assert(ppInfo != nullptr);
|
2004-04-19 14:57:02 +00:00
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
|
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
{
|
2017-04-11 21:38:46 +02:00
|
|
|
if ((errcode = jfw_getJavaInfoByPath(
|
|
|
|
jfw::BootParams::getJREHome(), ppInfo))
|
2004-11-09 15:12:48 +00:00
|
|
|
!= JFW_E_NONE)
|
|
|
|
throw jfw::FrameworkException(
|
|
|
|
JFW_E_CONFIGURATION,
|
2017-05-29 09:48:54 +02:00
|
|
|
"[Java framework] The JRE specified by the bootstrap "
|
|
|
|
"variable UNO_JAVA_JFW_JREHOME or UNO_JAVA_JFW_ENV_JREHOME "
|
|
|
|
" could not be recognized. Check the values and make sure that you "
|
|
|
|
"use a plug-in library that can recognize that JRE.");
|
2004-11-09 15:12:48 +00:00
|
|
|
|
|
|
|
return JFW_E_NONE;
|
|
|
|
}
|
|
|
|
|
2007-06-13 06:57:42 +00:00
|
|
|
const jfw::MergedSettings settings;
|
2017-04-13 12:08:05 +02:00
|
|
|
*ppInfo = settings.createJavaInfo();
|
2017-04-11 18:59:13 +02:00
|
|
|
if (!*ppInfo)
|
2004-05-04 07:43:42 +00:00
|
|
|
{
|
|
|
|
return JFW_E_NONE;
|
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
//If the javavendors.xml has changed, then the current selected
|
|
|
|
//Java is not valid anymore
|
|
|
|
// /java/javaInfo/@vendorUpdate != javaSelection/updated (javavendors.xml)
|
2013-04-07 12:06:47 +02:00
|
|
|
OString sUpdated = jfw::getElementUpdated();
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2017-07-06 13:10:19 +02:00
|
|
|
if (sUpdated != settings.getJavaInfoAttrVendorUpdate())
|
2017-04-11 18:04:54 +02:00
|
|
|
{
|
|
|
|
ppInfo->reset();
|
2004-04-19 14:57:02 +00:00
|
|
|
return JFW_E_INVALID_SETTINGS;
|
2017-04-11 18:04:54 +02:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:33:31 +02:00
|
|
|
bool jfw_isVMRunning()
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2017-04-11 18:33:31 +02:00
|
|
|
return g_pJavaVM != nullptr;
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-11 21:38:46 +02:00
|
|
|
javaFrameworkError jfw_getJavaInfoByPath(OUString const & pPath, std::unique_ptr<JavaInfo> *ppInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2017-04-11 19:10:23 +02:00
|
|
|
assert(ppInfo != nullptr);
|
2004-04-19 14:57:02 +00:00
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
|
|
|
|
jfw::VendorSettings aVendorSettings;
|
|
|
|
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
//ask all plugins if this is a JRE.
|
|
|
|
//If so check if it meets the version requirements.
|
|
|
|
//Only if it does return a JavaInfo
|
|
|
|
javaPluginError plerr = jfw_plugin_getJavaInfoByPath(
|
|
|
|
pPath,
|
|
|
|
aVendorSettings,
|
|
|
|
ppInfo);
|
2004-11-09 15:12:48 +00:00
|
|
|
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
if(plerr == javaPluginError::FailedVersion)
|
|
|
|
{//found JRE but it has the wrong version
|
|
|
|
ppInfo->reset();
|
|
|
|
errcode = JFW_E_FAILED_VERSION;
|
2004-04-22 11:52:40 +00:00
|
|
|
}
|
tdf#124503: Support JRE installations with unknown java.vendor property
After recent additions of 61c4f96d6ae6a80370774e53287edb27cbce8067 "Support
AdoptOpenJDK" and 41507db590b24e1b9b45d95cad55c71ba2e4091d "Support Amazon
Corretto" to our hard-coded list, there is now reports that at least Debian and
Ubuntu tried to distribute versions of OpenJDK with the java.vendor propety set
to string like "Debian" or "Ubuntu". Instead of trying to catch up with an
ever-growing hard-coded list, it is probably better to stop relying exclusively
on such a hard-coded list, and for unknown vendor values, try out whether the
SunInfo backend (which supports the "generic" OpenJDK) would be able to handle
the given JRE. (For simplicity, assume that any versions of such JREs are
supported. Our baseline is Java 6, and there are unlikely any older versions of
JREs from unknown vendors out there. If this turns out to be problematic, we
could include information about problematic vendors after all, or add a general
check that JREs from unknown vendors are at least Java 6.)
Many functions in jvmfwk/inc/vendorplugin.hxx that used to take a set of
sVendor/sMinVersion/sMaxVerison/arExcludeList paramters had to be revised to
take a vendorSettings parameter instead, and
VendorSettings::getVersionInformation has been changed to return a
boost::optional, so that unknown vendors can be handled gracefully.
Change-Id: Ibf915f2ddd59e09b77e2c03be688cac0547b9ac9
Reviewed-on: https://gerrit.libreoffice.org/70460
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-09 14:51:54 +02:00
|
|
|
OSL_ASSERT(plerr == javaPluginError::NONE || plerr == javaPluginError::NoJre);
|
2017-04-11 18:04:54 +02:00
|
|
|
if (!*ppInfo && errcode != JFW_E_FAILED_VERSION)
|
2004-11-09 15:12:48 +00:00
|
|
|
errcode = JFW_E_NOT_RECOGNIZED;
|
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-10 15:13:45 +01:00
|
|
|
javaFrameworkError jfw_setSelectedJRE(JavaInfo const *pInfo)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-05-12 09:33:33 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
|
|
|
//check if pInfo is the selected JRE
|
2017-04-11 18:04:54 +02:00
|
|
|
std::unique_ptr<JavaInfo> currentInfo;
|
2004-11-09 15:12:48 +00:00
|
|
|
errcode = jfw_getSelectedJRE( & currentInfo);
|
|
|
|
if (errcode != JFW_E_NONE && errcode != JFW_E_INVALID_SETTINGS)
|
2004-05-12 09:33:33 +00:00
|
|
|
return errcode;
|
2004-11-09 15:12:48 +00:00
|
|
|
|
2017-04-11 18:04:54 +02:00
|
|
|
if (!jfw_areEqualJavaInfo(currentInfo.get(), pInfo))
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
2012-08-10 15:52:22 +02:00
|
|
|
jfw::NodeJava node(jfw::NodeJava::USER);
|
2004-11-09 15:12:48 +00:00
|
|
|
node.setJavaInfo(pInfo, false);
|
2007-06-13 06:57:42 +00:00
|
|
|
node.write();
|
2004-11-09 15:12:48 +00:00
|
|
|
//remember that the JRE was selected in this process
|
|
|
|
jfw::setJavaSelected();
|
|
|
|
}
|
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-05-12 09:33:33 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
2016-03-10 15:13:45 +01:00
|
|
|
javaFrameworkError jfw_setEnabled(bool bEnabled)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
|
|
|
|
2015-07-16 13:51:43 +02:00
|
|
|
if (!g_bEnabledSwitchedOn && bEnabled)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
//When the process started then Enabled was false.
|
|
|
|
//This is first time enabled is set to true.
|
|
|
|
//That means, no preparational work has been done, such as setting the
|
|
|
|
//LD_LIBRARY_PATH, etc.
|
|
|
|
|
|
|
|
//check if Enabled is false;
|
2007-06-13 06:57:42 +00:00
|
|
|
const jfw::MergedSettings settings;
|
2014-01-21 11:46:57 +01:00
|
|
|
if (!settings.getEnabled())
|
2004-11-09 15:12:48 +00:00
|
|
|
g_bEnabledSwitchedOn = true;
|
|
|
|
}
|
2012-08-10 15:52:22 +02:00
|
|
|
jfw::NodeJava node(jfw::NodeJava::USER);
|
2004-11-09 15:12:48 +00:00
|
|
|
node.setEnabled(bEnabled);
|
2007-06-13 06:57:42 +00:00
|
|
|
node.write();
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-05-07 13:49:41 +00:00
|
|
|
{
|
2004-11-09 15:12:48 +00:00
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-05-07 13:49:41 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:38:51 +02:00
|
|
|
javaFrameworkError jfw_getEnabled(bool *pbEnabled)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2017-04-11 19:10:23 +02:00
|
|
|
assert(pbEnabled != nullptr);
|
2004-04-19 14:57:02 +00:00
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
2004-12-16 10:47:25 +00:00
|
|
|
return JFW_E_DIRECT_MODE;
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
|
|
|
jfw::MergedSettings settings;
|
|
|
|
*pbEnabled = settings.getEnabled();
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-11 22:25:23 +02:00
|
|
|
javaFrameworkError jfw_setVMParameters(std::vector<OUString> const & arOptions)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
2012-08-10 15:52:22 +02:00
|
|
|
jfw::NodeJava node(jfw::NodeJava::USER);
|
2017-04-11 22:25:23 +02:00
|
|
|
node.setVmParameters(arOptions);
|
2007-06-13 06:57:42 +00:00
|
|
|
node.write();
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
|
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2017-04-11 22:25:23 +02:00
|
|
|
javaFrameworkError jfw_getVMParameters(std::vector<OUString> * parOptions)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
|
|
|
|
2007-06-13 06:57:42 +00:00
|
|
|
const jfw::MergedSettings settings;
|
2017-04-11 22:25:23 +02:00
|
|
|
settings.getVmParametersArray(parOptions);
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2017-04-11 21:38:46 +02:00
|
|
|
javaFrameworkError jfw_setUserClassPath(OUString const & pCp)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
2012-08-10 15:52:22 +02:00
|
|
|
jfw::NodeJava node(jfw::NodeJava::USER);
|
2004-11-09 15:12:48 +00:00
|
|
|
node.setUserClassPath(pCp);
|
2007-06-13 06:57:42 +00:00
|
|
|
node.write();
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2017-04-11 21:38:46 +02:00
|
|
|
javaFrameworkError jfw_getUserClassPath(OUString * ppCP)
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2017-04-11 19:10:23 +02:00
|
|
|
assert(ppCP != nullptr);
|
2004-04-19 14:57:02 +00:00
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
2007-06-13 06:57:42 +00:00
|
|
|
const jfw::MergedSettings settings;
|
2017-04-11 21:38:46 +02:00
|
|
|
*ppCP = settings.getUserClassPath();
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-04-19 14:57:02 +00:00
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2017-04-11 21:38:46 +02:00
|
|
|
javaFrameworkError jfw_addJRELocation(OUString const & sLocation)
|
2004-04-21 08:30:36 +00:00
|
|
|
{
|
|
|
|
javaFrameworkError errcode = JFW_E_NONE;
|
2004-11-09 15:12:48 +00:00
|
|
|
try
|
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
osl::MutexGuard guard(jfw::FwkMutex::get());
|
2004-11-09 15:12:48 +00:00
|
|
|
if (jfw::getMode() == jfw::JFW_MODE_DIRECT)
|
|
|
|
return JFW_E_DIRECT_MODE;
|
2012-08-10 15:52:22 +02:00
|
|
|
jfw::NodeJava node(jfw::NodeJava::USER);
|
2007-06-13 06:57:42 +00:00
|
|
|
node.load();
|
2004-11-09 15:12:48 +00:00
|
|
|
node.addJRELocation(sLocation);
|
2007-06-13 06:57:42 +00:00
|
|
|
node.write();
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2011-12-15 13:51:29 +09:00
|
|
|
catch (const jfw::FrameworkException& e)
|
2004-11-09 15:12:48 +00:00
|
|
|
{
|
|
|
|
errcode = e.errorCode;
|
2017-05-29 09:48:54 +02:00
|
|
|
SAL_WARN( "jfw", e.message );
|
2004-11-09 15:12:48 +00:00
|
|
|
}
|
2004-04-21 08:30:36 +00:00
|
|
|
|
|
|
|
return errcode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-11 18:18:42 +02:00
|
|
|
javaFrameworkError jfw_existJRE(const JavaInfo *pInfo, bool *exist)
|
2009-04-02 16:25:40 +00:00
|
|
|
{
|
2014-10-09 17:24:52 +02:00
|
|
|
javaPluginError plerr = jfw_plugin_existJRE(pInfo, exist);
|
2009-04-02 16:25:40 +00:00
|
|
|
|
2010-10-26 12:28:33 +02:00
|
|
|
javaFrameworkError ret = JFW_E_NONE;
|
|
|
|
switch (plerr)
|
2009-04-02 16:25:40 +00:00
|
|
|
{
|
2016-05-20 15:45:02 +02:00
|
|
|
case javaPluginError::NONE:
|
2010-10-26 12:28:33 +02:00
|
|
|
ret = JFW_E_NONE;
|
|
|
|
break;
|
2016-05-20 15:45:02 +02:00
|
|
|
case javaPluginError::Error:
|
2010-10-26 12:28:33 +02:00
|
|
|
ret = JFW_E_ERROR;
|
|
|
|
break;
|
|
|
|
default:
|
2009-04-02 16:25:40 +00:00
|
|
|
ret = JFW_E_ERROR;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-03-10 15:13:45 +01:00
|
|
|
void jfw_lock()
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
jfw::FwkMutex::get().acquire();
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 15:13:45 +01:00
|
|
|
void jfw_unlock()
|
2004-04-19 14:57:02 +00:00
|
|
|
{
|
2007-06-13 06:57:42 +00:00
|
|
|
jfw::FwkMutex::get().release();
|
2004-04-19 14:57:02 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:07 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|