summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2002-09-25 14:37:50 +0000
committerJoachim Lingner <jl@openoffice.org>2002-09-25 14:37:50 +0000
commit291a8e7952c03da277aed76be6fbadee62e52a30 (patch)
tree71d7577528d822ca30771a9bb79a723e73773c95 /stoc
parent3c9615e926be3eac96b14101050a3945333464c4 (diff)
#103704# #103724#
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/javavm/interact.cxx31
-rw-r--r--stoc/source/javavm/javavm.cxx40
-rw-r--r--stoc/source/javavm/javavm.hxx8
3 files changed, 64 insertions, 15 deletions
diff --git a/stoc/source/javavm/interact.cxx b/stoc/source/javavm/interact.cxx
index 1123eaad4127..69f4544ca80b 100644
--- a/stoc/source/javavm/interact.cxx
+++ b/stoc/source/javavm/interact.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: interact.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jl $ $Date: 2002-09-16 12:30:42 $
+ * last change: $Author: jl $ $Date: 2002-09-25 15:37:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,6 +63,9 @@
#ifndef _COM_SUN_STAR_JAVA_JAVADISABLEDEXCEPTION_HPP_
#include <com/sun/star/java/JavaDisabledException.hpp>
#endif
+#ifndef _COM_SUN_STAR_JAVA_JAVAVMCREATIONFAILUREEXCEPTION_HPP_
+#include <com/sun/star/java/JavaVMCreationFailureException.hpp>
+#endif
namespace stoc_javavm
@@ -144,12 +147,24 @@ SAL_CALL InteractionRequest::getContinuations( ) throw (RuntimeException)
m_seqContinuations= Sequence< Reference< XInteractionContinuation> >( arObjs, 1);
}
#else
- Reference<XInteractionContinuation> arObjs[2];
- arObjs[0]= Reference< XInteractionContinuation >(
- static_cast<XWeak*> (new InteractionRetry(m_xJVM, m_pJVM)), UNO_QUERY);
- arObjs[1]= Reference< XInteractionContinuation> (
- static_cast<XWeak*> (new InteractionAbort(m_xJVM, m_pJVM)), UNO_QUERY);
- m_seqContinuations= Sequence< Reference< XInteractionContinuation> >( arObjs, 2);
+ // If the creation of JVM failed then don't offer retry, because java might crash
+ // next time
+ if( m_anyRequest.getValueType() == getCppuType( (JavaVMCreationFailureException*)0))
+ {
+ Reference<XInteractionContinuation> arObjs[1];
+ arObjs[0]= Reference< XInteractionContinuation> (
+ static_cast<XWeak*> (new InteractionAbort(m_xJVM, m_pJVM)), UNO_QUERY);
+ m_seqContinuations= Sequence< Reference< XInteractionContinuation> >( arObjs, 1);
+ }
+ else
+ {
+ Reference<XInteractionContinuation> arObjs[2];
+ arObjs[0]= Reference< XInteractionContinuation >(
+ static_cast<XWeak*> (new InteractionRetry(m_xJVM, m_pJVM)), UNO_QUERY);
+ arObjs[1]= Reference< XInteractionContinuation> (
+ static_cast<XWeak*> (new InteractionAbort(m_xJVM, m_pJVM)), UNO_QUERY);
+ m_seqContinuations= Sequence< Reference< XInteractionContinuation> >( arObjs, 2);
+ }
#endif
}
}
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index 72eeaf420def..3ddd1fba1d3f 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javavm.cxx,v $
*
- * $Revision: 1.42 $
+ * $Revision: 1.43 $
*
- * last change: $Author: jl $ $Date: 2002-09-16 14:19:51 $
+ * last change: $Author: jl $ $Date: 2002-09-25 15:37:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1405,6 +1405,7 @@ JavaVirtualMachine_Impl::JavaVirtualMachine_Impl(const Reference< XComponentCont
, _xCtx( xCtx )
,m_bInteractionAbort(sal_False)
,m_bInteractionRetry(sal_False)
+ ,m_bDontCreateJVM(sal_False)
{
pCreatorThread= new OCreatorThread(this);
@@ -1677,7 +1678,7 @@ Any JavaVirtualMachine_Impl::getJavaVM(const Sequence<sal_Int8> & processId) thr
}
}
- if (pJvm->isEnabled())
+ if (pJvm->isEnabled() && !m_bDontCreateJVM)
{
// create the java vm
try {
@@ -1689,6 +1690,28 @@ Any JavaVirtualMachine_Impl::getJavaVM(const Sequence<sal_Int8> & processId) thr
}
catch(WrappedTargetRuntimeException& e)
{
+ //Dependent on platform and kind of error it is best
+ //not to create Java again because it might crash the application
+ const Type& valueType= e.TargetException.getValueType();
+ if(valueType == getCppuType((JavaNotConfiguredException*)0))
+ {
+#ifdef LINUX
+ //because of LD_LIBRARY_PATH, even javaldx --use-links does not work sometimes
+ m_bDontCreateJVM= sal_True;
+#endif
+ }
+ else if(valueType == getCppuType((MissingJavaRuntimeException*)0))
+ {
+#ifdef LINUX
+ //because of LD_LIBRARY_PATH, even javaldx --use-links does not work sometimes
+ m_bDontCreateJVM= sal_True;
+#endif
+ }
+ else if(valueType == getCppuType((JavaVMCreationFailureException*)0))
+ {
+ m_bDontCreateJVM= sal_True;
+ }
+
delete pCreatorThread;
pCreatorThread= new OCreatorThread(this);
if( pJvm)
@@ -1702,7 +1725,7 @@ Any JavaVirtualMachine_Impl::getJavaVM(const Sequence<sal_Int8> & processId) thr
{
case action_abort:
{
- const Type& valueType= e.TargetException.getValueType();
+
if( valueType == getCppuType((JavaNotConfiguredException*)0))
{
JavaNotConfiguredException exc;
@@ -1745,7 +1768,7 @@ Any JavaVirtualMachine_Impl::getJavaVM(const Sequence<sal_Int8> & processId) thr
// listen for changes in the configuration, e.g. proxy settings.
registerConfigChangesListener();
}
- else
+ else if( ! m_bDontCreateJVM)
{
// Java is not enabled. Notify the user via the XInteractionHandler.
// If the client selects retry then we jump back to the retry label,otherwise we
@@ -1766,6 +1789,13 @@ Any JavaVirtualMachine_Impl::getJavaVM(const Sequence<sal_Int8> & processId) thr
default: goto retry;
}
}
+ else
+ {// This is the second + attempt to create Java. m_bDontCreateJVM is set
+ // which means instantiation of JVM might cause a crash.
+ if( pJvm)
+ delete pJvm;
+ throw RuntimeException();
+ }
if( pJvm)
delete pJvm;
}
diff --git a/stoc/source/javavm/javavm.hxx b/stoc/source/javavm/javavm.hxx
index 3deb1b40647e..ba02cd363f6c 100644
--- a/stoc/source/javavm/javavm.hxx
+++ b/stoc/source/javavm/javavm.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javavm.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jl $ $Date: 2002-07-23 14:07:21 $
+ * last change: $Author: jl $ $Date: 2002-09-25 15:37:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -131,6 +131,10 @@ class JavaVirtualMachine_Impl : public WeakImplHelper4< XJavaVM, XJavaThreadRegi
sal_Bool m_bInteractionAbort;
sal_Bool m_bInteractionRetry;
+ // If the first creation of java failed an this flag is set then the next call
+ // to getJavaVM throws an RuntimException. This is useful when the second attempt
+ // to create Java might cause a crash.
+ sal_Bool m_bDontCreateJVM;
public:
JavaVirtualMachine_Impl(const Reference<XComponentContext> & xCtx) throw();
~JavaVirtualMachine_Impl() throw();