summaryrefslogtreecommitdiff
path: root/jvmfwk
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2012-10-07 07:52:26 +0300
committerTor Lillqvist <tml@iki.fi>2012-10-07 07:59:15 +0300
commit97593ae24a98daca89fad176dc2492e582b3a821 (patch)
treef52189545a5c5ffbc7cece7bca595b2cd18c9cc0 /jvmfwk
parent1691752dd29d661552700d9bcac5d3a3953fb91a (diff)
Handle lack of module loading/unloading API when DISABLE_DYNLOADING
There are basicically two classes of cases: 1) Where the code is for obscure historical reasons or what I see as misguided "optimization" split into a more libraries than necessary, and these then are loaded at run-time. Instead, just use direct linking. 2) Where dynamic loading is part of the functionality offered to some upper (scripting etc) layer, or where some system-specific non-LO library is loaded dynamically, as it is not necessarily present on end-user machines. Can't have such in the DISABLE_DYNLOADING case. Change-Id: I9eceac5fb635245def2f4f3320821447bb7cd8c0
Diffstat (limited to 'jvmfwk')
-rw-r--r--jvmfwk/source/framework.cxx88
1 files changed, 77 insertions, 11 deletions
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index 324b112b4e7e..2f1760aae209 100644
--- a/jvmfwk/source/framework.cxx
+++ b/jvmfwk/source/framework.cxx
@@ -53,6 +53,41 @@ sal_Bool areEqualJavaInfo(
}
}
+#ifdef DISABLE_DYNLOADING
+
+extern "C"
+javaPluginError jfw_plugin_getAllJavaInfos(
+ rtl_uString *sVendor,
+ rtl_uString *sMinVersion,
+ rtl_uString *sMaxVersion,
+ rtl_uString * *arExcludeList,
+ sal_Int32 nLenList,
+ JavaInfo*** parJavaInfo,
+ sal_Int32 *nLenInfoList);
+
+extern "C"
+javaPluginError jfw_plugin_getJavaInfoByPath(
+ rtl_uString *path,
+ rtl_uString *sVendor,
+ rtl_uString *sMinVersion,
+ rtl_uString *sMaxVersion,
+ rtl_uString * *arExcludeList,
+ sal_Int32 nLenList,
+ JavaInfo ** ppInfo);
+
+extern "C"
+javaPluginError jfw_plugin_startJavaVirtualMachine(
+ const JavaInfo *pInfo,
+ const JavaVMOption* arOptions,
+ sal_Int32 cOptions,
+ JavaVM ** ppVm,
+ JNIEnv ** ppEnv);
+
+extern "C"
+javaPluginError jfw_plugin_existJRE(const JavaInfo *pInfo, sal_Bool *exist);
+
+#endif
+
javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSize)
{
javaFrameworkError retVal = JFW_E_NONE;
@@ -67,12 +102,13 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi
//Get a list of plugins which provide Java information
std::vector<jfw::PluginLibrary> vecPlugins =
aVendorSettings.getPluginData();
-
+#ifndef DISABLE_DYNLOADING
//Create a vector that holds the libraries, which will be later
//dynamically loaded;
boost::scoped_array<osl::Module> sarModules;
sarModules.reset(new osl::Module[vecPlugins.size()]);
osl::Module * arModules = sarModules.get();
+#endif
//Add the JavaInfos found by jfw_plugin_getAllJavaInfos to the vector
//Make sure that the contents are destroyed if this
//function returns with an error
@@ -95,6 +131,7 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi
const jfw::PluginLibrary & library = *i;
jfw::VersionInfo versionInfo =
aVendorSettings.getVersionInformation(library.sVendor);
+#ifndef DISABLE_DYNLOADING
arModules[cModule].load(library.sPath);
osl::Module & pluginLib = arModules[cModule];
@@ -109,7 +146,10 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi
jfw_plugin_getAllJavaInfos_ptr getAllJavaFunc =
(jfw_plugin_getAllJavaInfos_ptr) pluginLib.getFunctionSymbol(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getAllJavaInfos")));
-
+#else
+ jfw_plugin_getAllJavaInfos_ptr getAllJavaFunc =
+ jfw_plugin_getAllJavaInfos;
+#endif
OSL_ASSERT(getAllJavaFunc);
if (getAllJavaFunc == NULL)
return JFW_E_ERROR;
@@ -138,10 +178,14 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi
//Check if the current plugin can detect JREs at the location
// of the paths added by jfw_setJRELocations or jfw_addJRELocation
//get the function from the plugin
+#ifndef DISABLE_DYNLOADING
jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc =
(jfw_plugin_getJavaInfoByPath_ptr) pluginLib.getFunctionSymbol(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getJavaInfoByPath")));
-
+#else
+ jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc =
+ jfw_plugin_getJavaInfoByPath;
+#endif
OSL_ASSERT(jfw_plugin_getJavaInfoByPathFunc);
if (jfw_plugin_getJavaInfoByPathFunc == NULL)
return JFW_E_ERROR;
@@ -347,6 +391,7 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
if ( ! modulePlugin)
return JFW_E_NO_PLUGIN;
+#ifndef DISABLE_DYNLOADING
rtl::OUString sFunctionName(
RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_startJavaVirtualMachine"));
jfw_plugin_startJavaVirtualMachine_ptr pFunc =
@@ -354,6 +399,10 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
osl_getFunctionSymbol(modulePlugin, sFunctionName.pData);
if (pFunc == NULL)
return JFW_E_ERROR;
+#else
+ jfw_plugin_startJavaVirtualMachine_ptr pFunc =
+ jfw_plugin_startJavaVirtualMachine;
+#endif
// create JavaVMOptions array that is passed to the plugin
// it contains the classpath and all options set in the
@@ -445,12 +494,13 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
jfw::VendorSettings aVendorSettings;
std::vector<jfw::PluginLibrary> vecPlugins =
aVendorSettings.getPluginData();
+#ifndef DISABLE_DYNLOADING
//Create a vector that holds the libraries, which will be later
//dynamically loaded;
boost::scoped_array<osl::Module> sarModules;
sarModules.reset(new osl::Module[vecPlugins.size()]);
osl::Module * arModules = sarModules.get();
-
+#endif
//Use every plug-in library to get Java installations. At the first usable
//Java the loop will break
typedef std::vector<jfw::PluginLibrary>::const_iterator ci_pl;
@@ -460,7 +510,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
const jfw::PluginLibrary & library = *i;
jfw::VersionInfo versionInfo =
aVendorSettings.getVersionInformation(library.sVendor);
-
+#ifndef DISABLE_DYNLOADING
arModules[cModule].load(library.sPath);
osl::Module & pluginLib = arModules[cModule];
if (pluginLib.is() == sal_False)
@@ -469,7 +519,10 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
jfw_plugin_getAllJavaInfos_ptr getAllJavaFunc =
(jfw_plugin_getAllJavaInfos_ptr) pluginLib.getFunctionSymbol(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getAllJavaInfos")));
-
+#else
+ jfw_plugin_getAllJavaInfos_ptr getAllJavaFunc =
+ jfw_plugin_getAllJavaInfos;
+#endif
OSL_ASSERT(getAllJavaFunc);
if (getAllJavaFunc == NULL)
continue;
@@ -542,7 +595,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
const jfw::PluginLibrary & library = *i;
jfw::VersionInfo versionInfo =
aVendorSettings.getVersionInformation(library.sVendor);
-
+#ifndef DISABLE_DYNLOADING
osl::Module pluginLib(library.sPath);
if (pluginLib.is() == sal_False)
return JFW_E_NO_PLUGIN;
@@ -552,7 +605,10 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc =
(jfw_plugin_getJavaInfoByPath_ptr) pluginLib.getFunctionSymbol(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getJavaInfoByPath")));
-
+#else
+ jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc =
+ jfw_plugin_getJavaInfoByPath;
+#endif
OSL_ASSERT(jfw_plugin_getJavaInfoByPathFunc);
if (jfw_plugin_getJavaInfoByPathFunc == NULL)
return JFW_E_ERROR;
@@ -742,12 +798,13 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
//Get a list of plugins which provide Java information
std::vector<jfw::PluginLibrary> vecPlugins =
aVendorSettings.getPluginData();
+#ifndef DISABLE_DYNLOADING
//Create a vector that holds the libraries, which will be later
//dynamically loaded;
boost::scoped_array<osl::Module> sarModules;
sarModules.reset(new osl::Module[vecPlugins.size()]);
osl::Module * arModules = sarModules.get();
-
+#endif
typedef std::vector<rtl::OUString>::const_iterator CIT_VENDOR;
std::vector<rtl::OUString> vecVendors =
aVendorSettings.getSupportedVendors();
@@ -762,6 +819,8 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
const jfw::PluginLibrary & library = *i;
jfw::VersionInfo versionInfo =
aVendorSettings.getVersionInformation(library.sVendor);
+
+#ifndef DISABLE_DYNLOADING
arModules[cModule].load(library.sPath);
osl::Module & pluginLib = arModules[cModule];
if (pluginLib.is() == sal_False)
@@ -776,7 +835,10 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc =
(jfw_plugin_getJavaInfoByPath_ptr) pluginLib.getFunctionSymbol(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jfw_plugin_getJavaInfoByPath")));
-
+#else
+ jfw_plugin_getJavaInfoByPath_ptr jfw_plugin_getJavaInfoByPathFunc =
+ jfw_plugin_getJavaInfoByPath;
+#endif
OSL_ASSERT(jfw_plugin_getJavaInfoByPathFunc);
if (jfw_plugin_getJavaInfoByPathFunc == NULL)
continue;
@@ -1112,6 +1174,7 @@ javaFrameworkError jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist)
jfw::VendorSettings aVendorSettings;
jfw::CJavaInfo aInfo;
aInfo = (const ::JavaInfo*) pInfo; //makes a copy of pInfo
+#ifndef DISABLE_DYNLOADING
rtl::OUString sLibPath = aVendorSettings.getPluginLibrary(aInfo.getVendor());
osl::Module modulePlugin(sLibPath);
if ( ! modulePlugin)
@@ -1123,7 +1186,10 @@ javaFrameworkError jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist)
osl_getFunctionSymbol(modulePlugin, sFunctionName.pData);
if (pFunc == NULL)
return JFW_E_ERROR;
-
+#else
+ jfw_plugin_existJRE_ptr pFunc =
+ jfw_plugin_existJRE;
+#endif
javaPluginError plerr = (*pFunc)(pInfo, exist);
javaFrameworkError ret = JFW_E_NONE;