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
commit420901602f0ffa83a21f9789f007f34d4469f54e (patch)
tree2cbd74ea878cccbca43c624e3b4c22b57261ba56 /stoc
parent96269bbedd8e0a664a584b3cc742acc3c6d2e3d5 (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.hxx10
3 files changed, 65 insertions, 16 deletions
diff --git a/stoc/source/javavm/interact.cxx b/stoc/source/javavm/interact.cxx
index 217723de4..2d9b14d5c 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 70b6fe47c..f9bcf6cd9 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 c70855970..eba3377f7 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
@@ -130,7 +130,11 @@ 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();