summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2004-05-07 13:49:41 +0000
committerJoachim Lingner <jl@openoffice.org>2004-05-07 13:49:41 +0000
commit5def523f04bea8fbb65ea83648040df1741bb8a6 (patch)
treea296afe3990be4705a51c068d64e83f5b6c5ee06
parentb21347f0dce6d55c17a4f82946a9a092a1259a2a (diff)
#i20052#
-rw-r--r--jvmfwk/inc/jvmfwk/framework.h12
-rw-r--r--jvmfwk/inc/jvmfwk/vendorplugin.h8
-rwxr-xr-xjvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx13
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx10
-rw-r--r--jvmfwk/source/framework.cxx46
-rw-r--r--jvmfwk/source/fwkutil.cxx7
6 files changed, 77 insertions, 19 deletions
diff --git a/jvmfwk/inc/jvmfwk/framework.h b/jvmfwk/inc/jvmfwk/framework.h
index bd20b541aa61..73db8cdbfbf6 100644
--- a/jvmfwk/inc/jvmfwk/framework.h
+++ b/jvmfwk/inc/jvmfwk/framework.h
@@ -2,9 +2,9 @@
*
* $RCSfile: framework.h,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jl $ $Date: 2004-05-04 08:43:41 $
+ * last change: $Author: jl $ $Date: 2004-05-07 14:49:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -105,7 +105,8 @@ typedef enum
JFW_E_NO_PLUGIN,
JFW_E_NOT_RECOGNIZED,
JFW_E_FAILED_VERSION,
- JFW_E_NO_JAVA_FOUND
+ JFW_E_NO_JAVA_FOUND,
+ JFW_E_VM_CREATION_FAILED
} javaFrameworkError;
/** an instance of this struct represents an installation of a Java
@@ -413,6 +414,11 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath(
JFW_E_NEED_RESTART in the current process a different JRE has been selected
which needs a prepared environment, which has to be done before the office
process. Therefore the new JRE may not be used until the office was restarted.<br/>
+ JFW_E_NEED_RESTART is also returned when Java was disabled at the beginning and
+ then the user enabled it. If then the selected JRE has the requirement
+ JFW_REQUIRE_NEEDRESTART then this error is returned. </br>
+ JFW_E_VM_CREATION_FAILED the creation of the JVM failed. The creation is performed
+ by a plug-in library and not by this API.
*/
javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions,
sal_Int32 nSize, JavaVM **ppVM,
diff --git a/jvmfwk/inc/jvmfwk/vendorplugin.h b/jvmfwk/inc/jvmfwk/vendorplugin.h
index 77c4fc539a5c..2369d49cf209 100644
--- a/jvmfwk/inc/jvmfwk/vendorplugin.h
+++ b/jvmfwk/inc/jvmfwk/vendorplugin.h
@@ -2,9 +2,9 @@
*
* $RCSfile: vendorplugin.h,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jl $ $Date: 2004-05-05 14:11:17 $
+ * last change: $Author: jl $ $Date: 2004-05-07 14:49:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,7 +84,8 @@ typedef enum
JFW_PLUGIN_E_WRONG_VERSION_FORMAT,
JFW_PLUGIN_E_FAILED_VERSION,
JFW_PLUGIN_E_NO_JRE,
- JFW_PLUGIN_E_WRONG_VENDOR
+ JFW_PLUGIN_E_WRONG_VENDOR,
+ JFW_PLUGIN_E_VM_CREATION_FAILED
} javaPluginError;
@@ -135,6 +136,7 @@ javaPluginError getJavaInfoByPath(
JFW_PLUGIN_E_ERROR,
JFW_PLUGIN_E_WRONG_VENDOR
JFW_PLUGIN_E_INVALID_ARG,
+ JFW_PLUGIN_E_VM_CREATION_FAILED
*/
javaPluginError startJavaVirtualMachine(
diff --git a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx
index 93bc51ac77ab..a30c1298c13d 100755
--- a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx
+++ b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javaldx.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jl $ $Date: 2004-05-04 10:44:06 $
+ * last change: $Author: jl $ $Date: 2004-05-07 14:49:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,7 +99,10 @@ int main(int argc, char **argv)
}
if (bEnabled == sal_False)
+ {
+ //Do not do any preparation because that may only slow startup time.
return 0;
+ }
JavaInfo * pInfo = NULL;
javaFrameworkError errcode = JFW_E_NONE;
@@ -130,6 +133,12 @@ int main(int argc, char **argv)
return -1;
}
}
+
+ //Only do something if the sunjavaplugin created this JavaInfo
+ rtl::OUString sSunVendor(RTL_CONSTASCII_USTRINGPARAM("Sun Microsystems Inc."));
+ if (sSunVendor.equals(pInfo->sVendor) == sal_False)
+ return 0;
+
rtl::OString sPaths = getLD_LIBRARY_PATH(pInfo->arVendorData);
fprintf(stdout, "%s\n", sPaths.getStr());
jfw_freeJavaInfo(pInfo);
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 31683d0520c3..34b4094dd1df 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: sunjavaplugin.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jl $ $Date: 2004-05-06 11:44:47 $
+ * last change: $Author: jl $ $Date: 2004-05-07 14:49:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -398,7 +398,7 @@ javaPluginError startJavaVirtualMachine(
sSymbolCreateJava, osl_getThreadTextEncoding());
fprintf(stderr,"Java runtime library: %s does not export symbol %s !",
sLib.getStr(), sSymbol.getStr());
- return JFW_PLUGIN_E_ERROR;
+ return JFW_PLUGIN_E_VM_CREATION_FAILED;
}
// The office sets a signal handler at startup. That causes a crash
@@ -496,12 +496,12 @@ javaPluginError startJavaVirtualMachine(
if( err < 0)
{
fprintf(stderr,"Can not create Java Virtual Machine");
- errcode = JFW_PLUGIN_E_ERROR;
+ errcode = JFW_PLUGIN_E_VM_CREATION_FAILED;
}
else if( err > 0)
{
fprintf(stderr,"Can not create JavaVirtualMachine, abort handler was called");
- errcode = JFW_PLUGIN_E_ERROR;
+ errcode = JFW_PLUGIN_E_VM_CREATION_FAILED;
}
}
else
diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx
index ddaf79c68283..7db040eeb566 100644
--- a/jvmfwk/source/framework.cxx
+++ b/jvmfwk/source/framework.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: framework.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jl $ $Date: 2004-05-04 08:43:42 $
+ * last change: $Author: jl $ $Date: 2004-05-07 14:49:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,6 +91,8 @@
namespace {
JavaVM * g_pJavaVM = NULL;
+bool g_bEnabledSwitchedOn = false;
+
sal_Bool areEqualJavaInfo(
JavaInfo const * pInfoA,JavaInfo const * pInfoB)
{
@@ -316,6 +318,16 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
if (sVendorUpdate != javaSettings.getJavaInfoAttrVendorUpdate())
return JFW_E_INVALID_SETTINGS;
+ //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
+ //done. Therefore if a JRE needs it it must not be started.
+ if (javaSettings.getEnabled() == sal_False)
+ return JFW_E_JAVA_DISABLED;
+ else if (g_bEnabledSwitchedOn &&
+ (aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART))
+ return JFW_E_NEED_RESTART;
+
//Check if the selected Java was set in this process. If so it
//must not have the requirments flag JFW_REQUIRE_NEEDRESTART
if ((aInfo->nRequirements & JFW_REQUIRE_NEEDRESTART)
@@ -411,7 +423,11 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
//start Java
JavaVM *pVm = NULL;
javaPluginError plerr = (*pFunc)(aInfo, arOpt, index, & pVm, ppEnv);
- if (plerr != JFW_PLUGIN_E_NONE)
+ if (plerr == JFW_PLUGIN_E_VM_CREATION_FAILED)
+ {
+ errcode = JFW_E_VM_CREATION_FAILED;
+ }
+ else if (plerr != JFW_PLUGIN_E_NONE )
{
errcode = JFW_E_ERROR;
}
@@ -420,7 +436,8 @@ javaFrameworkError SAL_CALL jfw_startVM(JavaVMOption *arOptions, sal_Int32 cOpti
g_pJavaVM = pVm;
*ppVM = pVm;
}
- return JFW_E_NONE;
+ OSL_ASSERT(plerr != JFW_PLUGIN_E_WRONG_VENDOR);
+ return errcode;
}
/** We do not use here jfw_findAllJREs and then check if a JavaInfo
@@ -621,6 +638,8 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo)
{
//copy to out param
*pInfo = aCurrentInfo.cloneJavaInfo();
+ //remember that this JRE was selected in this process
+ jfw::setJavaSelected();
}
}
else
@@ -800,6 +819,8 @@ javaFrameworkError SAL_CALL jfw_setSelectedJRE(JavaInfo const *pInfo)
errcode = node.writeSettings();
if (errcode != JFW_E_NONE)
return errcode;
+ //remember that the JRE was selected in this process
+ jfw::setJavaSelected();
return errcode;
}
javaFrameworkError SAL_CALL jfw_setEnabled(sal_Bool bEnabled)
@@ -807,10 +828,27 @@ javaFrameworkError SAL_CALL jfw_setEnabled(sal_Bool bEnabled)
osl::MutexGuard guard(jfw::getFwkMutex());
javaFrameworkError errcode = JFW_E_NONE;
jfw::CNodeJava node;
+
+ if (g_bEnabledSwitchedOn == false && bEnabled == sal_True)
+ {
+ //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;
+ errcode = node.loadFromSettings();
+ if (errcode != JFW_E_NONE)
+ return errcode;
+ if (node.getEnabled() == sal_False)
+ g_bEnabledSwitchedOn = true;
+ }
node.setEnabled(bEnabled);
errcode = node.writeSettings();
if (errcode != JFW_E_NONE)
return errcode;
+ //remember if the enabled was false at the beginning and has
+ //been changed to true.
return errcode;
}
diff --git a/jvmfwk/source/fwkutil.cxx b/jvmfwk/source/fwkutil.cxx
index e9864ccaae09..fbb7099cf29d 100644
--- a/jvmfwk/source/fwkutil.cxx
+++ b/jvmfwk/source/fwkutil.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fwkutil.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jl $ $Date: 2004-04-28 09:11:38 $
+ * last change: $Author: jl $ $Date: 2004-05-07 14:49:41 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -89,6 +89,7 @@ namespace jfw
{
bool g_bJavaSet = false;
+
struct Init
{
osl::Mutex * operator()()
@@ -733,6 +734,8 @@ void setJavaSelected()
g_bJavaSet = true;
}
+
+
/** Determines if the currently selected Java was set in this process.
@see setProcessId()