summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorStephan Bergmann <sb@openoffice.org>2002-12-06 09:48:59 +0000
committerStephan Bergmann <sb@openoffice.org>2002-12-06 09:48:59 +0000
commit63a62358c4bc2e3c3770b5958252e2fe0bcc6465 (patch)
tree4590064f48def38b6244b50e541567f4870d0d17 /stoc
parentf52629939659a694704ad664245a894115f1d76a (diff)
#105077# Base on new jvmaccess/virtualmachine, and cleanup.
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/javavm/interact.cxx183
-rw-r--r--stoc/source/javavm/interact.hxx102
-rw-r--r--stoc/source/javavm/javavm.cxx2871
-rw-r--r--stoc/source/javavm/javavm.hxx214
-rw-r--r--stoc/source/javavm/jen.xml7
-rw-r--r--stoc/source/javavm/jvmargs.cxx90
-rw-r--r--stoc/source/javavm/jvmargs.hxx8
-rw-r--r--stoc/source/javavm/makefile.mk8
8 files changed, 1670 insertions, 1813 deletions
diff --git a/stoc/source/javavm/interact.cxx b/stoc/source/javavm/interact.cxx
index 69f4544ca80b..a5f9927385c7 100644
--- a/stoc/source/javavm/interact.cxx
+++ b/stoc/source/javavm/interact.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: interact.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jl $ $Date: 2002-09-25 15:37:49 $
+ * last change: $Author: sb $ $Date: 2002-12-06 10:48:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,119 +58,114 @@
*
*
************************************************************************/
+
#include "interact.hxx"
-#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
+#include "com/sun/star/java/JavaDisabledException.hpp"
+#include "com/sun/star/java/JavaVMCreationFailureException.hpp"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionRetry.hpp"
+#include "com/sun/star/task/XInteractionContinuation.hpp"
+#include "cppuhelper/implbase1.hxx"
+#include "osl/mutex.hxx"
+namespace css = com::sun::star;
-namespace stoc_javavm
-{
+using stoc_javavm::InteractionRequest;
+
+namespace {
-InteractionAbort::InteractionAbort( const WeakReference<XInterface>& xJVM,
- JavaVirtualMachine_Impl * _pJVM):
- m_xJVM(xJVM),
- m_pJVM(_pJVM)
+class AbortContinuation:
+ public cppu::WeakImplHelper1< css::task::XInteractionAbort >
{
- OSL_ASSERT( _pJVM);
+public:
+ inline AbortContinuation() {}
+
+ virtual inline void SAL_CALL select() throw (css::uno::RuntimeException) {}
+
+private:
+ AbortContinuation(AbortContinuation &); // not implemented
+ void operator =(AbortContinuation); // not implemented
+
+ virtual inline ~AbortContinuation() {}
+};
+
}
-void SAL_CALL InteractionAbort::select( ) throw (RuntimeException)
+class InteractionRequest::RetryContinuation:
+ public cppu::WeakImplHelper1< css::task::XInteractionRetry >
{
- //If we get a hard reference to JavaVirtualMachine_Impl
- //then we may call the callback
- Reference<XInterface> xIntJVM= m_xJVM;
- if( xIntJVM.is())
- m_pJVM->selectAbort();
-}
-//================================================================================
-InteractionRetry::InteractionRetry( const WeakReference<XInterface>& xJVM,
- JavaVirtualMachine_Impl * _pJVM):
- m_xJVM(xJVM),
- m_pJVM(_pJVM)
+public:
+ inline RetryContinuation(): m_bSelected(false) {}
+
+ virtual void SAL_CALL select() throw (css::uno::RuntimeException);
+
+ bool isSelected() const;
+
+private:
+ RetryContinuation(RetryContinuation &); // not implemented
+ void operator =(RetryContinuation); // not implemented
+
+ virtual inline ~RetryContinuation() {}
+
+ mutable osl::Mutex m_aMutex;
+ bool m_bSelected;
+};
+
+void SAL_CALL InteractionRequest::RetryContinuation::select()
+ throw (css::uno::RuntimeException)
{
- OSL_ASSERT( _pJVM);
+ osl::MutexGuard aGuard(m_aMutex);
+ m_bSelected = true;
}
-void SAL_CALL InteractionRetry::select( ) throw (RuntimeException)
+bool InteractionRequest::RetryContinuation::isSelected() const
{
- //If we get a hard reference to JavaVirtualMachine_Impl
- //then we may call the callback
- Reference<XInterface> xIntJVM= m_xJVM;
- if( xIntJVM.is())
- m_pJVM->selectRetry();
+ osl::MutexGuard aGuard(m_aMutex);
+ return m_bSelected;
}
-//================================================================================
-InteractionRequest::InteractionRequest( const Reference<XInterface>& xJVM,
- JavaVirtualMachine_Impl* _pJVM,
- Any& _request):
- m_xJVM(xJVM),
- m_pJVM(_pJVM),
- m_anyRequest(_request),
- m_pseqContinuations(NULL)
+
+InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
+ m_aRequest(rRequest)
{
+ bool bRetry;
+#if defined LINUX
+ // Only if Java is disabled we allow retry:
+ bRetry = m_aRequest.isExtractableTo(
+ getCppuType(static_cast< css::java::JavaDisabledException * >(0)));
+#else // LINUX
+ // If the creation of the JVM failed then do not offer retry, because Java
+ // might crash next time:
+ bRetry = !m_aRequest.isExtractableTo(
+ getCppuType(
+ static_cast< css::java::JavaVMCreationFailureException * >(0)));
+#endif // LINUX
+ m_aContinuations.realloc(bRetry ? 2 : 1);
+ m_aContinuations[0] = new AbortContinuation;
+ if (bRetry)
+ {
+ m_xRetryContinuation = new RetryContinuation;
+ m_aContinuations[1] = m_xRetryContinuation.get();
+ }
}
-Any SAL_CALL InteractionRequest::getRequest( ) throw (RuntimeException)
+css::uno::Any SAL_CALL InteractionRequest::getRequest()
+ throw (css::uno::RuntimeException)
{
- return m_anyRequest;
+ return m_aRequest;
}
-Sequence< Reference< XInteractionContinuation > >
-SAL_CALL InteractionRequest::getContinuations( ) throw (RuntimeException)
+css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
+SAL_CALL InteractionRequest::getContinuations()
+ throw (css::uno::RuntimeException)
{
- if ( ! m_pseqContinuations)
- {
- MutexGuard guard(javavm_getMutex());
- if( ! m_pseqContinuations)
- {
-#ifdef LINUX
- // Only if java is disabled we allow retry
- if( m_anyRequest.getValueType() == getCppuType( (JavaDisabledException*)0))
- {
- 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);
- }
- else
- {
- 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
- // 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
- }
- }
- return m_seqContinuations;
+ return m_aContinuations;
}
+bool InteractionRequest::retry() const
+{
+ return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
+}
-
-} // end namespace
+InteractionRequest::~InteractionRequest()
+{}
diff --git a/stoc/source/javavm/interact.hxx b/stoc/source/javavm/interact.hxx
index 6b4f15a11a75..3e2611feedc8 100644
--- a/stoc/source/javavm/interact.hxx
+++ b/stoc/source/javavm/interact.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: interact.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jl $ $Date: 2002-07-23 14:07:17 $
+ * last change: $Author: sb $ $Date: 2002-12-06 10:48:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,74 +58,52 @@
*
*
************************************************************************/
-#ifndef _JVM_INTERACT_HXX_
-#define _JVM_INTERACT_HXX_
-#ifndef _CPPUHELPER_IMPLBASE2_HXX_
-#include <cppuhelper/implbase1.hxx>
-#endif
-#ifndef _CPPUHELPER_WEAKREF_HXX_
-#include <cppuhelper/weakref.hxx>
-#endif
-#ifndef _COM_SUN_STAR_TASK_XINTERACTIONRETRY_HPP_
-#include <com/sun/star/task/XInteractionRetry.hpp>
-#endif
-#ifndef _COM_SUN_STAR_TASK_XINTERACTION_ABORT_HPP_
-#include <com/sun/star/task/XInteractionAbort.hpp>
-#endif
-#ifndef _COM_SUN_STAR_TASK_XINTERACTIONREQUEST_HPP_
-#include <com/sun/star/task/XInteractionRequest.hpp>
-#endif
+#if !defined INCLUDED_STOC_JAVAVM_INTERACT_HXX
+#define INCLUDED_STOC_JAVAVM_INTERACT_HXX
-#include "javavm.hxx"
+#include "com/sun/star/task/XInteractionRequest.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "rtl/ref.hxx"
-using namespace ::cppu;
-using namespace ::com::sun::star::task;
-using namespace ::com::sun::star::uno;
-namespace stoc_javavm
-{
-class InteractionAbort: public WeakImplHelper1<XInteractionAbort>
-{
- // Holds the JavaVirtualMachine_Impl. Calls on XInteractionAbort::select
- // in this class are delegated to JavaVirtualMachine_Impl.
- WeakReference<XInterface> m_xJVM;
- JavaVirtualMachine_Impl *m_pJVM;
-public:
- InteractionAbort( const WeakReference<XInterface>& xJVM, JavaVirtualMachine_Impl* _pJVM);
- //com.sun.star.task.XInteractionAbort
- virtual void SAL_CALL select( ) throw (RuntimeException);
-};
+namespace com { namespace sun { namespace star { namespace task {
+ class XInteractionContinuation;
+} } } }
-class InteractionRetry: public WeakImplHelper1<XInteractionRetry>
+namespace stoc_javavm {
+
+class InteractionRequest:
+ public cppu::WeakImplHelper1< com::sun::star::task::XInteractionRequest >
{
- // Holds the JavaVirtualMachine_Impl. Calls on XInteractionAbort::select
- // in this class are delegated to JavaVirtualMachine_Impl.
- WeakReference<XInterface> m_xJVM;
- JavaVirtualMachine_Impl *m_pJVM;
public:
- InteractionRetry( const WeakReference<XInterface>& xJVM, JavaVirtualMachine_Impl* _pJVM);
- //com.sun.star.task.XInteractionAbort
- virtual void SAL_CALL select( ) throw (RuntimeException);
-};
+ explicit InteractionRequest(com::sun::star::uno::Any const & rRequest);
-class InteractionRequest: public WeakImplHelper1<XInteractionRequest>
-{
- // Holds the JavaVirtualMachine_Impl. Calls on XInteractionAbort::select
- // in this class are delegated to JavaVirtualMachine_Impl.
- WeakReference<XInterface> m_xJVM;
- JavaVirtualMachine_Impl *m_pJVM;
- Any m_anyRequest;
- Sequence< Reference<XInteractionContinuation> > m_seqContinuations;
- Sequence< Reference<XInteractionContinuation> > * m_pseqContinuations;
+ virtual com::sun::star::uno::Any SAL_CALL getRequest()
+ throw (com::sun::star::uno::RuntimeException);
-public:
- InteractionRequest( const Reference<XInterface>& xJVM,
- JavaVirtualMachine_Impl* _pJVM, Any& _request);
- virtual Any SAL_CALL getRequest( ) throw (RuntimeException);
- virtual Sequence< Reference< XInteractionContinuation > >
- SAL_CALL getContinuations( ) throw (RuntimeException);
+ virtual com::sun::star::uno::Sequence< com::sun::star::uno::Reference<
+ com::sun::star::task::XInteractionContinuation > > SAL_CALL
+ getContinuations() throw (com::sun::star::uno::RuntimeException);
+
+ bool retry() const;
+
+private:
+ class RetryContinuation;
+
+ InteractionRequest(InteractionRequest &); // not implemented
+ void operator =(InteractionRequest); // not implemented
+
+ virtual ~InteractionRequest();
+
+ com::sun::star::uno::Any m_aRequest;
+ com::sun::star::uno::Sequence< com::sun::star::uno::Reference<
+ com::sun::star::task::XInteractionContinuation > > m_aContinuations;
+ rtl::Reference< RetryContinuation > m_xRetryContinuation;
};
-} // end namespace
-#endif
+}
+#endif // INCLUDED_STOC_JAVAVM_INTERACT_HXX
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index 1c9a3c1bb92a..be99c544d11c 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javavm.cxx,v $
*
- * $Revision: 1.49 $
+ * $Revision: 1.50 $
*
- * last change: $Author: jl $ $Date: 2002-12-03 11:38:42 $
+ * last change: $Author: sb $ $Date: 2002-12-06 10:48:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,13 +59,14 @@
*
************************************************************************/
-/** Code generation bug within Sun CC 5.2 on solaris sparc
- Please check the following code against your compiler version before enabling
- the optimization (when the program runs correct, it should print
- 1
- 2
- ), otherwise nothing. The bug has crashed the
- initVMConfiguration function, which can be found in this file.
+/*
+ Code generation bug within Sun CC 5.2 on solaris sparc
+ Please check the following code against your compiler version before enabling
+ the optimization (when the program runs correct, it should print
+ 1
+ 2
+ ), otherwise nothing. The bug has crashed the
+ initVMConfiguration function, which can be found in this file.
#include <stdio.h>
@@ -101,69 +102,59 @@ int main( int argc, char * argv[])
}
*/
-#ifdef UNX
-#include <signal.h>
-#endif
+#include "javavm.hxx"
+
+#include "interact.hxx"
+#include "jvmargs.hxx"
+
+#include "com/sun/star/beans/PropertyState.hpp"
+#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/container/XContainer.hpp"
+#include "com/sun/star/java/JavaDisabledException.hpp"
+#include "com/sun/star/java/JavaNotConfiguredException.hpp"
+#include "com/sun/star/java/JavaVMCreationFailureException.hpp"
+#include "com/sun/star/java/MissingJavaRuntimeException.hpp"
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/XEventListener.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "com/sun/star/registry/XSimpleRegistry.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "cppuhelper/exc_hlp.hxx"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "jvmaccess/virtualmachine.hxx"
+#include "osl/file.hxx"
+#include "osl/thread.h"
+#include "rtl/bootstrap.hxx"
+#include "rtl/process.h"
+#include "rtl/string.h"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/current_context.hxx"
+#include "uno/environment.h"
+#include "uno/lbnames.h"
+
+#include "jni.h"
+
#include <setjmp.h>
+#include <signal.h>
+#include <stack>
#include <string.h>
#include <time.h>
-#include <osl/diagnose.h>
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <rtl/process.h>
-#include <rtl/alloc.h>
-#include <rtl/ustrbuf.hxx>
-#include <rtl/bootstrap.hxx>
-#ifndef _OSL_CONDITN_HXX_
-#include <osl/conditn.hxx>
-#endif
-#ifndef _THREAD_HXX_
-#include <osl/thread.hxx>
-#endif
-#include <cppuhelper/factory.hxx>
-#include <cppuhelper/implementationentry.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/registry/XRegistryKey.hpp>
-#include <com/sun/star/registry/XSimpleRegistry.hpp>
-#include <com/sun/star/registry/InvalidRegistryException.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/container/XContainer.hpp>
-#include <bridges/java/jvmcontext.hxx>
-#ifndef _COM_SUN_STAR_TASK_XINTERACTION_ABORT_HPP_
-#include <com/sun/star/task/XInteractionAbort.hpp>
-#endif
-#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
-#include <com/sun/star/task/XInteractionHandler.hpp>
-#endif
-#ifndef _COM_SUN_STAR_TASK_XINTERACTIONREQUEST_HPP_
-#include <com/sun/star/task/XInteractionRequest.hpp>
-#endif
-#ifndef _COM_SUN_STAR_JAVA_JAVADISABLEDEXCEPTION_HPP_
-#include <com/sun/star/java/JavaDisabledException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_JAVA_MISSINGJAVARUNTIMEEXCEPTION_HPP_
-#include <com/sun/star/java/MissingJavaRuntimeException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_JAVA_JAVAVMCREATIONFAILUREEXCEPTION_HPP_
-#include <com/sun/star/java/JavaVMCreationFailureException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_JAVA_JAVANOTCONFIGUREDEXCEPTION_HPP_
-#include <com/sun/star/java/JavaNotConfiguredException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETRUNTIMEEXCEPTION_HPP_
-#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UNO_XCURRENTCONTEXT_HPP_
-#include <com/sun/star/uno/XCurrentContext.hpp>
-#endif
-#ifndef _UNO_CURRENT_CONTEXT_HXX_
-#include <uno/current_context.hxx>
-#endif
-#include "jvmargs.hxx"
-#include "javavm.hxx"
-#include "interact.hxx"
// Properties of the javavm can be put
// as a komma separated list in this
@@ -183,758 +174,199 @@ int main( int argc, char * argv[])
#define TIMEZONE "MET"
#endif
-#define OUSTR(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x))
+namespace css = com::sun::star;
-#define INTERACTION_HANDLER_NAME "java-vm.interaction-handler"
+using stoc_javavm::JavaVirtualMachine;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::java;
-using namespace com::sun::star::registry;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::container;
-using namespace com::sun::star::task;
-using namespace rtl;
-using namespace cppu;
-using namespace osl;
+namespace {
-static void abort_handler();
-jmp_buf jmp_jvm_abort;
-sal_Bool g_bInGetJavaVM;
+class SingletonFactory:
+ private cppu::WeakImplHelper1< css::lang::XEventListener >
+{
+public:
+ static css::uno::Reference< css::uno::XInterface > getSingleton(
+ css::uno::Reference< css::uno::XComponentContext > const & rContext);
-namespace stoc_javavm {
+private:
+ SingletonFactory(SingletonFactory &); // not implemented
+ void operator =(SingletonFactory); // not implemented
-static void getINetPropsFromConfig(JVM * pjvm,
- const Reference<XMultiComponentFactory> & xSMgr,
- const Reference<XComponentContext> &xCtx ) throw (Exception);
+ inline SingletonFactory() {}
+ virtual inline ~SingletonFactory() {}
-Mutex* javavm_getMutex()
-{
- static Mutex* pMutex= NULL;
+ virtual void SAL_CALL disposing(css::lang::EventObject const &)
+ throw (css::uno::RuntimeException);
- if( ! pMutex)
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pMutex)
- {
- static Mutex aMutex;
- pMutex= &aMutex;
- }
- }
- return pMutex;
-}
+ static void dispose();
+ // TODO ok to keep these static?
+ static osl::Mutex m_aMutex;
+ static css::uno::Reference< css::uno::XInterface > m_xSingleton;
+ static bool m_bDisposed;
+};
-static Sequence< OUString > javavm_getSupportedServiceNames()
+css::uno::Reference< css::uno::XInterface > SingletonFactory::getSingleton(
+ css::uno::Reference< css::uno::XComponentContext > const & rContext)
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
+ css::uno::Reference< css::uno::XInterface > xSingleton;
+ css::uno::Reference< css::lang::XComponent > xComponent;
{
- MutexGuard guard( javavm_getMutex() );
- if( !pNames )
+ osl::MutexGuard aGuard(m_aMutex);
+ if (!m_xSingleton.is())
{
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUSTR(
- "com.sun.star.java.JavaVirtualMachine");
- pNames = &seqNames;
+ if (m_bDisposed)
+ throw css::lang::DisposedException();
+ xComponent = css::uno::Reference< css::lang::XComponent >(
+ rContext, css::uno::UNO_QUERY_THROW);
+ m_xSingleton = static_cast< cppu::OWeakObject * >(
+ new JavaVirtualMachine(rContext));
}
+ xSingleton = m_xSingleton;
}
- return *pNames;
-}
-
-static OUString javavm_getImplementationName()
-{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( javavm_getMutex() );
- if( ! pImplName )
+ if (xComponent.is())
+ try
{
- static OUString implName(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.comp.stoc.JavaVirtualMachine") );
- pImplName = &implName;
+ xComponent->addEventListener(new SingletonFactory);
}
- }
- return *pImplName;
-}
-
-static jint JNICALL vm_vfprintf( FILE *fp, const char *format, va_list args ) {
-#ifdef DEBUG
- char buff[1024];
-
- vsprintf( buff, format, args );
-
- OSL_TRACE("%s", buff);
- return strlen(buff);
-#else
- return 0;
-#endif
-}
-
-static void JNICALL vm_exit(jint code) {
- OSL_TRACE("vm_exit: %d\n", code);
-}
-
-static void JNICALL vm_abort() {
- OSL_TRACE("vm_abort\n");
- abort();
+ catch (...)
+ {
+ dispose();
+ throw;
+ }
+ return xSingleton;
}
-typedef ::std::hash_map<sal_uInt32, sal_uInt32> UINT32_UINT32_HashMap;
-
-class JavaVirtualMachine_Impl;
-
-class OCreatorThread : public Thread {
- JavaVirtualMachine_Impl * _pJavaVirtualMachine_Impl;
- JavaVM * _pJVM;
-
- Condition _start_Condition;
- Condition _wait_Condition;
-
- JVM _jvm;
- RuntimeException _runtimeException;
- WrappedTargetRuntimeException wrappedException;
-
-protected:
- virtual void SAL_CALL run() throw();
-
-public:
- OCreatorThread(JavaVirtualMachine_Impl * pJavaVirtualMachine_Impl) throw();
- JavaVM * createJavaVM(const JVM & jvm) throw (RuntimeException);
- void disposeJavaVM() throw();
-
-};
-
-
-OCreatorThread::OCreatorThread(JavaVirtualMachine_Impl * pJavaVirtualMachine_Impl) throw()
- : _pJVM(NULL)
+void SAL_CALL SingletonFactory::disposing(css::lang::EventObject const &)
+ throw (css::uno::RuntimeException)
{
- _pJavaVirtualMachine_Impl = pJavaVirtualMachine_Impl;
+ dispose();
}
-void OCreatorThread::run() throw()
+void SingletonFactory::dispose()
{
- _start_Condition.wait();
- _start_Condition.reset();
- try {
- _pJVM = _pJavaVirtualMachine_Impl->createJavaVM(_jvm);
- }
- catch(WrappedTargetRuntimeException& wrappedExc)
- {
- wrappedException= wrappedExc;
- }
- catch(RuntimeException & runtimeException)
- {
- _runtimeException = runtimeException;
- }
-
- _wait_Condition.set();
-
- if (_pJVM) {
-#if defined(WNT) || defined(OS2)
- suspend();
-
-#else
- _start_Condition.wait();
- _start_Condition.reset();
-
- _pJavaVirtualMachine_Impl->disposeJavaVM();
-
- _wait_Condition.set();
-#endif
- }
-}
-
-JavaVM * OCreatorThread::createJavaVM(const JVM & jvm ) throw(RuntimeException) {
- _jvm = jvm;
-
- if (!_pJVM )
+ css::uno::Reference< css::lang::XComponent > xComponent;
{
- create();
-
- _start_Condition.set();
-
- _wait_Condition.wait();
- _wait_Condition.reset();
-
- if(!_pJVM)
- {
- if( wrappedException.TargetException.getValue() != 0)
- throw wrappedException;
- else
- throw _runtimeException;
- }
+ osl::MutexGuard aGuard(m_aMutex);
+ xComponent = css::uno::Reference< css::lang::XComponent >(
+ m_xSingleton, css::uno::UNO_QUERY);
+ m_xSingleton.clear();
+ m_bDisposed = true;
}
-
- return _pJVM;
-}
-
-void OCreatorThread::disposeJavaVM() throw() {
- _start_Condition.set(); // start disposing vm
-
-#ifdef UNX
- _wait_Condition.wait(); // wait until disposed
- _wait_Condition.reset();
-#endif
+ if (xComponent.is())
+ xComponent->dispose();
}
+osl::Mutex SingletonFactory::m_aMutex;
+css::uno::Reference< css::uno::XInterface > SingletonFactory::m_xSingleton;
+bool SingletonFactory::m_bDisposed = false;
-
-// XServiceInfo
-OUString SAL_CALL JavaVirtualMachine_Impl::getImplementationName() throw(RuntimeException)
+rtl::OUString serviceGetImplementationName()
{
- return javavm_getImplementationName();
-}
-
-// XServiceInfo
-sal_Bool SAL_CALL JavaVirtualMachine_Impl::supportsService(const OUString& ServiceName) throw(RuntimeException) {
- Sequence<OUString> aSNL = getSupportedServiceNames();
- const OUString * pArray = aSNL.getConstArray();
-
- for (sal_Int32 i = 0; i < aSNL.getLength(); ++ i)
- if (pArray[i] == ServiceName)
- return sal_True;
-
- return sal_False;
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.stoc.JavaVirtualMachine"));
}
-// XServiceInfo
-Sequence<OUString> SAL_CALL JavaVirtualMachine_Impl::getSupportedServiceNames() throw(RuntimeException)
-{
- return javavm_getSupportedServiceNames();
-}
-// XContainerListener
-void SAL_CALL JavaVirtualMachine_Impl::elementInserted( const ContainerEvent& Event )
- throw (RuntimeException)
+rtl::OUString serviceGetServiceName()
{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.java.JavaVirtualMachine"));
}
-// XContainerListener
-void SAL_CALL JavaVirtualMachine_Impl::elementRemoved( const ContainerEvent& Event )
- throw (RuntimeException)
+css::uno::Sequence< rtl::OUString > serviceGetSupportedServiceNames()
{
+ return css::uno::Sequence< rtl::OUString >(&serviceGetServiceName(), 1);
}
-// XContainerListener
-// If a user changes the setting, for example for proxy settings, then this function
-// will be called from the configuration manager. Even if the .xml file does not contain
-// an entry yet and that entry has to be inserted, this function will be called.
-// We call java.lang.System.setProperty for the new values
-void SAL_CALL JavaVirtualMachine_Impl::elementReplaced( const ContainerEvent& Event )
- throw (RuntimeException)
+css::uno::Reference< css::uno::XInterface > SAL_CALL serviceCreateInstance(
+ css::uno::Reference< css::uno::XComponentContext > const & rContext)
+ SAL_THROW((css::uno::Exception))
{
- MutexGuard aGuard( javavm_getMutex());
- OUString sAccessor;
- Event.Accessor >>= sAccessor;
- OUString sPropertyName;
- OUString sPropertyValue;
- OUString sPropertyName2;
- sal_Bool bSecurityChanged= sal_False;
- sal_Bool bDone= sal_False;
-
- if (sAccessor == OUSTR("ooInetFTPProxyName"))
- {
- sPropertyName= OUSTR("ftp.proxyHost");
- Event.Element >>= sPropertyValue;
- }
- else if (sAccessor == OUSTR("ooInetFTPProxyPort"))
- {
- sPropertyName= OUSTR("ftp.proxyPort");
- sPropertyValue= OUString::valueOf( *(sal_Int32*)Event.Element.getValue());
- }
- else if (sAccessor == OUSTR("ooInetHTTPProxyName"))
- {
- sPropertyName= OUSTR("http.proxyHost");
- Event.Element >>= sPropertyValue;
- }
- else if (sAccessor == OUSTR("ooInetHTTPProxyPort"))
- {
- sPropertyName= OUSTR("http.proxyPort");
- sPropertyValue= OUString::valueOf( *(sal_Int32*)Event.Element.getValue());
- }
- else if (sAccessor == OUSTR("ooInetNoProxy"))
- {
- sPropertyName= OUSTR("ftp.nonProxyHosts");
- sPropertyName2= OUSTR("http.nonProxyHosts");
- Event.Element >>= sPropertyValue;
- sPropertyValue= sPropertyValue.replace((sal_Unicode)';', (sal_Unicode)'|');
- }
-/* else if (sAccessor == OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetSOCKSProxyName")))
- {
- sPropertyName= OUString(RTL_CONSTASCII_USTRINGPARAM("socksProxyHost"));
- Event.Element >>= sPropertyValue;
- }
- else if (sAccessor == OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetSOCKSProxyPort")))
- {
- sPropertyName= OUString(RTL_CONSTASCII_USTRINGPARAM("socksProxyPort"));
- sPropertyValue= OUString::valueOf( *(sal_Int32*)Event.Element.getValue());
- }
-*/ else if (sAccessor == OUSTR("ooInetProxyType"))
- {
- //Proxy none, manually
- sal_Int32 value;
- Event.Element >>= value;
- setINetSettingsInVM( (sal_Bool) value);
- bDone= sal_True;
- }
- else if (sAccessor == OUSTR("NetAccess"))
- {
- bSecurityChanged= sal_True;
- sPropertyName= OUSTR("appletviewer.security.mode");
- sal_Int32 val;
- if( Event.Element >>= val)
- {
- switch( val)
- {
- case 0: sPropertyValue= OUSTR("unrestricted");
- break;
- case 1: sPropertyValue= OUSTR("none");
- break;
- case 2: sPropertyValue= OUSTR("host");
- break;
- }
- }
- else
- return;
- }
- else if (sAccessor == OUSTR("Security"))
- {
- bSecurityChanged= sal_True;
- sPropertyName= OUSTR("stardiv.security.disableSecurity");
- sal_Bool val;
- if( Event.Element >>= val)
- {
- if( val)
- sPropertyValue= OUSTR("false");
- else
- sPropertyValue= OUSTR("true");
- }
- else
- return;
- }
- else
- return;
+ // Only one single instance of this service is ever constructed, and is
+ // available until the component context used to create this instance is
+ // disposed. Afterwards, this function throws a DisposedException (as do
+ // all relevant methods on the single service instance).
+ return SingletonFactory::getSingleton(rContext);
+}
- if ( ! bDone && _pVMContext && _pVMContext->_pJavaVM)
- {
- JNIEnv* pJNIEnv= NULL;
- sal_Bool bThreadAttached= sal_False;
- jint ret= _pVMContext->_pJavaVM->AttachCurrentThread((void **)&pJNIEnv, (void*)NULL);
- OSL_ENSURE( !ret,"JavaVM could not attach current thread to VM");
- if ( ! _pVMContext->isThreadAttached())
- {
- bThreadAttached= sal_True;
- }
+cppu::ImplementationEntry const aServiceImplementation[]
+ = { { serviceCreateInstance,
+ serviceGetImplementationName,
+ serviceGetSupportedServiceNames,
+ cppu::createSingleComponentFactory,
+ 0, 0 },
+ { 0, 0, 0, 0, 0, 0 } };
- // call java.lang.System.setProperty
- // String setProperty( String key, String value)
- jclass jcSystem= pJNIEnv->FindClass("java/lang/System");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass java/lang/System"), Reference<XInterface>());
- jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetStaticMethodID java.lang.System.setProperty"), Reference<XInterface>());
-
- jstring jsPropName= pJNIEnv->NewString( sPropertyName.getStr(), sPropertyName.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
-
- // remove the property if it does not have a value ( user left the dialog field empty)
- // or if the port is set to 0
- sPropertyValue= sPropertyValue.trim();
- if( sPropertyValue.getLength() == 0 ||
- (sPropertyName.equals( OUSTR("ftp.proxyPort")) ||
- sPropertyName.equals( OUSTR("http.proxyPort")) /*||
- sPropertyName.equals( OUString( RTL_CONSTASCII_USTRINGPARAM("socksProxyPort")))*/) &&
- sPropertyValue.equals(OUSTR("0")))
- {
- // call java.lang.System.getProperties
- jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetStaticMethodID java.lang.System.getProperties"), Reference<XInterface>());
- jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.getProperties"), Reference<XInterface>());
- // call java.util.Properties.remove
- jclass jcProperties= pJNIEnv->FindClass("java/util/Properties");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass java/util/Properties"), Reference<XInterface>());
- jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetMethodID java.util.Properties.remove"), Reference<XInterface>());
- jobject joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName);
-
- // special calse for ftp.nonProxyHosts and http.nonProxyHosts. The office only
- // has a value for two java properties
- if (sPropertyName2.getLength() > 0)
- {
- jstring jsPropName2= pJNIEnv->NewString( sPropertyName2.getStr(), sPropertyName2.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jobject joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName2);
- }
- }
- else
- {
- // Change the Value of the property
- jstring jsPropValue= pJNIEnv->NewString( sPropertyValue.getStr(), sPropertyValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
-
- // special calse for ftp.nonProxyHosts and http.nonProxyHosts. The office only
- // has a value for two java properties
- if (sPropertyName2.getLength() > 0)
- {
- jstring jsPropName= pJNIEnv->NewString( sPropertyName2.getStr(), sPropertyName2.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPropValue= pJNIEnv->NewString( sPropertyValue.getStr(), sPropertyValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
- }
-
- // If the settings for Security and NetAccess changed then we have to notify the SandboxSecurity
- // SecurityManager
- // call System.getSecurityManager()
- if (bSecurityChanged)
- {
- jmethodID jmGetSecur= pJNIEnv->GetStaticMethodID( jcSystem,"getSecurityManager","()Ljava/lang/SecurityManager;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetStaticMethodID java.lang.System.getSecurityManager"), Reference<XInterface>());
- jobject joSecur= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetSecur);
- if (joSecur != 0)
- {
- // Make sure the SecurityManager is our SandboxSecurity
- // FindClass("com.sun.star.lib.sandbox.SandboxSecurityManager" only worked at the first time
- // this code was executed. Maybe it is a security feature. However, all attempts to debug the
- // SandboxSecurity class (maybe the VM invokes checkPackageAccess) failed.
-// jclass jcSandboxSec= pJNIEnv->FindClass("com.sun.star.lib.sandbox.SandboxSecurity");
-// if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass com.sun.star.lib.sandbox.SandboxSecurity"), Reference<XInterface>());
-// jboolean bIsSand= pJNIEnv->IsInstanceOf( joSecur, jcSandboxSec);
- // The SecurityManagers class Name must be com.sun.star.lib.sandbox.SandboxSecurity
- jclass jcSec= pJNIEnv->GetObjectClass( joSecur);
- jclass jcClass= pJNIEnv->FindClass("java/lang/Class");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass java.lang.Class"), Reference<XInterface>());
- jmethodID jmName= pJNIEnv->GetMethodID( jcClass,"getName","()Ljava/lang/String;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetMethodID java.lang.Class.getName"), Reference<XInterface>());
- jstring jsClass= (jstring) pJNIEnv->CallObjectMethod( jcSec, jmName);
- const jchar* jcharName= pJNIEnv->GetStringChars( jsClass, NULL);
- OUString sName( jcharName);
- jboolean bIsSandbox;
- if (sName == OUSTR("com.sun.star.lib.sandbox.SandboxSecurity"))
- bIsSandbox= JNI_TRUE;
- else
- bIsSandbox= JNI_FALSE;
- pJNIEnv->ReleaseStringChars( jsClass, jcharName);
-
- if (bIsSandbox == JNI_TRUE)
- {
- // call SandboxSecurity.reset
- jmethodID jmReset= pJNIEnv->GetMethodID( jcSec,"reset","()V");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset"), Reference<XInterface>());
- pJNIEnv->CallVoidMethod( joSecur, jmReset);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset"), Reference<XInterface>());
- }
- }
- }
- if (bThreadAttached)
- {
- jint ret= _pVMContext->_pJavaVM->DetachCurrentThread();
- OSL_ENSURE( !ret,"JavaVM could not detach current thread to VM");
- }
- }
-}
+typedef std::stack< jvmaccess::VirtualMachine::AttachGuard * > GuardStack;
-// param true: all Inet setting are set as Java Properties on a live VM.
-// false: the Java net properties are set to empty value.
-void JavaVirtualMachine_Impl::setINetSettingsInVM( sal_Bool set_reset)
+void destroyAttachGuards(void * pData)
{
- MutexGuard aGuard( javavm_getMutex());
- try
- {
- if (_pVMContext && _pVMContext->_pJavaVM)
+ GuardStack * pStack = static_cast< GuardStack * >(pData);
+ if (pStack != 0)
{
- JNIEnv* pJNIEnv= NULL;
- sal_Bool bThreadAttached= sal_False;
- jint ret= _pVMContext->_pJavaVM->AttachCurrentThread((void **)&pJNIEnv, (void*)NULL);
- OSL_ENSURE( !ret,"JavaVM could not attach current thread to VM");
- if ( ! _pVMContext->isThreadAttached())
- {
- bThreadAttached= sal_True;
- }
-
- // The Java Properties
- OUString sFtpProxyHost(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyHost") );
- OUString sFtpProxyPort(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyPort") );
- OUString sFtpNonProxyHosts (RTL_CONSTASCII_USTRINGPARAM("ftp.nonProxyHosts"));
- OUString sHttpProxyHost(RTL_CONSTASCII_USTRINGPARAM("http.proxyHost") );
- OUString sHttpProxyPort(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort") );
- OUString sHttpNonProxyHosts(RTL_CONSTASCII_USTRINGPARAM("http.nonProxyHosts"));
-// OUString sSocksProxyHost(RTL_CONSTASCII_USTRINGPARAM("socksProxyHost"));
-// OUString sSocksProxyPort(RTL_CONSTASCII_USTRINGPARAM("socksProxyPort"));
- // creat Java Properties as JNI strings
- jstring jsFtpProxyHost= pJNIEnv->NewString( sFtpProxyHost.getStr(), sFtpProxyHost.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsFtpProxyPort= pJNIEnv->NewString( sFtpProxyPort.getStr(), sFtpProxyPort.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsFtpNonProxyHosts= pJNIEnv->NewString( sFtpNonProxyHosts.getStr(), sFtpNonProxyHosts.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsHttpProxyHost= pJNIEnv->NewString( sHttpProxyHost.getStr(), sHttpProxyHost.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsHttpProxyPort= pJNIEnv->NewString( sHttpProxyPort.getStr(), sHttpProxyPort.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsHttpNonProxyHosts= pJNIEnv->NewString( sHttpNonProxyHosts.getStr(), sHttpNonProxyHosts.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
-// jstring jsSocksProxyHost= pJNIEnv->NewString( sSocksProxyHost.getStr(), sSocksProxyHost.getLength());
-// if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR(""), Reference<XInterface>());
-// jstring jsSocksProxyPort= pJNIEnv->NewString( sSocksProxyPort.getStr(), sSocksProxyPort.getLength());
-// if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR(""), Reference<XInterface>());
-
- // prepare java.lang.System.setProperty
- jclass jcSystem= pJNIEnv->FindClass("java/lang/System");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass java/lang/System"), Reference<XInterface>());
- jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetStaticMethodID java.lang.System.setProperty"), Reference<XInterface>());
-
- // call java.lang.System.getProperties
- jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetStaticMethodID java.lang.System.getProperties"), Reference<XInterface>());
- jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.getProperties"), Reference<XInterface>());
- // prepare java.util.Properties.remove
- jclass jcProperties= pJNIEnv->FindClass("java/util/Properties");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass java/util/Properties"), Reference<XInterface>());
-
- if (set_reset)
- {
- // Set all network properties with the VM
- JVM jvm;
- getINetPropsFromConfig( &jvm, _xSMgr, _xCtx);
- const ::std::vector< OUString> & Props = jvm.getProperties();
- typedef ::std::vector< OUString >::const_iterator C_IT;
-
- for( C_IT i= Props.begin(); i != Props.end(); i++)
- {
- OUString prop= *i;
- sal_Int32 index= prop.indexOf( (sal_Unicode)'=');
- OUString propName= prop.copy( 0, index);
- OUString propValue= prop.copy( index + 1);
-
- if( propName.equals( sFtpProxyHost))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpProxyHost, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
- else if( propName.equals( sFtpProxyPort))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpProxyPort, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
- else if( propName.equals( sFtpNonProxyHosts))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpNonProxyHosts, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
- else if( propName.equals( sHttpProxyHost))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpProxyHost, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
- else if( propName.equals( sHttpProxyPort))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpProxyPort, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
- else if( propName.equals( sHttpNonProxyHosts))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:NewString"), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpNonProxyHosts, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:CallStaticObjectMethod java.lang.System.setProperty"), Reference<XInterface>());
- }
-/* else if( propName.equals( sSocksProxyHost))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("")), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsSocksProxyHost, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("")), Reference<XInterface>());
- }
- else if( propName.equals( sSocksProxyPort))
- {
- jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("")), Reference<XInterface>());
- jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsSocksProxyPort, jsVal);
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("")), Reference<XInterface>());
- }
-*/ }
- }
- else
- {
- // call java.util.Properties.remove
- jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;");
- if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:GetMethodID java.util.Property.remove"), Reference<XInterface>());
- jobject joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpProxyHost);
- joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpProxyPort);
- joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpNonProxyHosts);
- joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpProxyHost);
- joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpProxyPort);
- joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpNonProxyHosts);
-// joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsSocksProxyHost);
-// joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsSocksProxyPort);
- }
-
- if (bThreadAttached)
+ while (!pStack->empty())
{
- jint ret= _pVMContext->_pJavaVM->DetachCurrentThread();
- OSL_ENSURE( !ret,"JavaVM could not detach current thread to VM");
+ delete pStack->top();
+ pStack->pop();
}
- }
- }
- catch( RuntimeException& e)
- {e;
- }
-
-}
-// XEventListenerListener
-void SAL_CALL JavaVirtualMachine_Impl::disposing( const EventObject& Source )
- throw (RuntimeException)
-{
- // In case the configuration manager wants to shut down
- if (_xConfigurationAccess.is() && Source.Source == _xConfigurationAccess)
- {
- Reference< XContainer > xContainer(_xConfigurationAccess, UNO_QUERY);
- if (xContainer.is())
- xContainer->removeContainerListener( static_cast< XContainerListener* >(this));
- _xConfigurationAccess= 0;
- }
- // In case the configuration manager wants to shut down
- if (_xConfigurationAccess2.is() && Source.Source == _xConfigurationAccess2)
- {
- Reference< XContainer > xContainer(_xConfigurationAccess2, UNO_QUERY);
- if (xContainer.is())
- xContainer->removeContainerListener( static_cast< XContainerListener* >(this));
- _xConfigurationAccess2= 0;
- }
-
- // If the service manager calls us then we are about to be shut down, therefore
- // unregister everywhere. Currently this service is only registered with the
- // configuration manager
- Reference< XInterface > xIntMgr( _xSMgr, UNO_QUERY);
- if (Source.Source == xIntMgr)
- {
- Reference< XContainer > xContainer(_xConfigurationAccess, UNO_QUERY);
- if (xContainer.is())
- xContainer->removeContainerListener( static_cast< XContainerListener* >(this));
-
- Reference< XContainer > xContainer2(_xConfigurationAccess2, UNO_QUERY);
- if (xContainer2.is())
- xContainer2->removeContainerListener( static_cast< XContainerListener* >(this));
+ delete pStack;
}
}
-static void getDefaultLocaleFromConfig(JVM * pjvm,
- const Reference<XMultiComponentFactory> & xSMgr,
- const Reference<XComponentContext> &xCtx ) throw(Exception)
+bool askForRetry(css::uno::Any const & rException)
{
- Reference<XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
- OUSTR("com.sun.star.configuration.ConfigurationRegistry"),
- xCtx );
- if(!xConfRegistry.is()) throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"), Reference<XInterface>());
-
- Reference<XSimpleRegistry> xConfRegistry_simple(xConfRegistry, UNO_QUERY);
- if(!xConfRegistry_simple.is()) throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"), Reference<XInterface>());
-
- xConfRegistry_simple->open(OUSTR("org.openoffice.Setup"), sal_True, sal_False);
- Reference<XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
-
- // read locale
- Reference<XRegistryKey> locale = xRegistryRootKey->openKey(OUSTR("L10N/ooLocale"));
- if(locale.is() && locale->getStringValue().getLength()) {
- OUString language;
- OUString country;
-
- sal_Int32 index = locale->getStringValue().indexOf((sal_Unicode) '-');
-
- if(index >= 0) {
- language = locale->getStringValue().copy(0, index);
- country = locale->getStringValue().copy(index + 1);
-
- if(language.getLength()) {
- OUString prop(RTL_CONSTASCII_USTRINGPARAM("user.language="));
- prop += language;
-
- pjvm->pushProp(prop);
- }
-
- if(country.getLength()) {
- OUString prop(RTL_CONSTASCII_USTRINGPARAM("user.region="));
- prop += country;
-
- pjvm->pushProp(prop);
- }
+ css::uno::Reference< css::uno::XCurrentContext > xContext(
+ css::uno::getCurrentContext());
+ if (xContext.is())
+ {
+ css::uno::Reference< css::task::XInteractionHandler > xHandler;
+ xContext->getValueByName(rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "java-vm.interaction-handler")))
+ >>= xHandler;
+ if (xHandler.is())
+ {
+ rtl::Reference< stoc_javavm::InteractionRequest > xRequest(
+ new stoc_javavm::InteractionRequest(rException));
+ xHandler->handle(xRequest.get());
+ return xRequest->retry();
}
}
-
- xConfRegistry_simple->close();
-}
-
-static void setTimeZone(JVM * pjvm) throw() {
- /* A Bug in the Java function
- ** struct Hjava_util_Properties * java_lang_System_initProperties(
- ** struct Hjava_lang_System *this,
- ** struct Hjava_util_Properties *props);
- ** This function doesn't detect MEZ, MET or "W. Europe Standard Time"
- */
- struct tm *tmData;
- time_t clock = time(NULL);
- tzset();
- tmData = localtime(&clock);
-#ifdef MACOSX
- char * p = tmData->tm_zone;
-#else
- char * p = tzname[0];
-#endif
-
- if (!strcmp(TIMEZONE, p))
- pjvm->pushProp(OUString::createFromAscii("user.timezone=ECT"));
+ return false;
}
// Only gets the properties if the "Proxy Server" entry in the option dialog is
// set to manual (i.e. not to none)
-static void getINetPropsFromConfig(JVM * pjvm,
- const Reference<XMultiComponentFactory> & xSMgr,
- const Reference<XComponentContext> &xCtx ) throw (Exception)
+void getINetPropsFromConfig(stoc_javavm::JVM * pjvm,
+ const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr,
+ const css::uno::Reference<css::uno::XComponentContext> &xCtx ) throw (css::uno::Exception)
{
- Reference<XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
- OUSTR("com.sun.star.configuration.ConfigurationRegistry"),
+ css::uno::Reference<css::uno::XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationRegistry")),
xCtx );
- if(!xConfRegistry.is()) throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"), Reference<XInterface>());
+ if(!xConfRegistry.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")), 0);
- Reference<XSimpleRegistry> xConfRegistry_simple(xConfRegistry, UNO_QUERY);
- if(!xConfRegistry_simple.is()) throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"), Reference<XInterface>());
+ css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple(xConfRegistry, css::uno::UNO_QUERY);
+ if(!xConfRegistry_simple.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")), 0);
- xConfRegistry_simple->open(OUSTR("org.openoffice.Inet"), sal_True, sal_False);
- Reference<XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
+ xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Inet")), sal_True, sal_False);
+ css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
// if ooInetProxyType is not 0 then read the settings
- Reference<XRegistryKey> proxyEnable= xRegistryRootKey->openKey(OUSTR("Settings/ooInetProxyType"));
+ css::uno::Reference<css::registry::XRegistryKey> proxyEnable= xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetProxyType")));
if( proxyEnable.is() && 0 != proxyEnable->getLongValue())
{
// read ftp proxy name
- Reference<XRegistryKey> ftpProxy_name = xRegistryRootKey->openKey(OUSTR("Settings/ooInetFTPProxyName"));
+ css::uno::Reference<css::registry::XRegistryKey> ftpProxy_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetFTPProxyName")));
if(ftpProxy_name.is() && ftpProxy_name->getStringValue().getLength()) {
- OUString ftpHost = OUSTR("ftp.proxyHost=");
+ rtl::OUString ftpHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyHost="));
ftpHost += ftpProxy_name->getStringValue();
// read ftp proxy port
- Reference<XRegistryKey> ftpProxy_port = xRegistryRootKey->openKey(OUSTR("Settings/ooInetFTPProxyPort"));
+ css::uno::Reference<css::registry::XRegistryKey> ftpProxy_port = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetFTPProxyPort")));
if(ftpProxy_port.is() && ftpProxy_port->getLongValue()) {
- OUString ftpPort = OUSTR("ftp.proxyPort=");
- ftpPort += OUString::valueOf(ftpProxy_port->getLongValue());
+ rtl::OUString ftpPort = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyPort="));
+ ftpPort += rtl::OUString::valueOf(ftpProxy_port->getLongValue());
pjvm->pushProp(ftpHost);
pjvm->pushProp(ftpPort);
@@ -942,16 +374,16 @@ static void getINetPropsFromConfig(JVM * pjvm,
}
// read http proxy name
- Reference<XRegistryKey> httpProxy_name = xRegistryRootKey->openKey(OUSTR("Settings/ooInetHTTPProxyName"));
+ css::uno::Reference<css::registry::XRegistryKey> httpProxy_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetHTTPProxyName")));
if(httpProxy_name.is() && httpProxy_name->getStringValue().getLength()) {
- OUString httpHost = OUSTR("http.proxyHost=");
+ rtl::OUString httpHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyHost="));
httpHost += httpProxy_name->getStringValue();
// read http proxy port
- Reference<XRegistryKey> httpProxy_port = xRegistryRootKey->openKey(OUSTR("Settings/ooInetHTTPProxyPort"));
+ css::uno::Reference<css::registry::XRegistryKey> httpProxy_port = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetHTTPProxyPort")));
if(httpProxy_port.is() && httpProxy_port->getLongValue()) {
- OUString httpPort = OUSTR("http.proxyPort=");
- httpPort += OUString::valueOf(httpProxy_port->getLongValue());
+ rtl::OUString httpPort = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort="));
+ httpPort += rtl::OUString::valueOf(httpProxy_port->getLongValue());
pjvm->pushProp(httpHost);
pjvm->pushProp(httpPort);
@@ -959,11 +391,11 @@ static void getINetPropsFromConfig(JVM * pjvm,
}
// read nonProxyHosts
- Reference<XRegistryKey> nonProxies_name = xRegistryRootKey->openKey(OUSTR("Settings/ooInetNoProxy"));
+ css::uno::Reference<css::registry::XRegistryKey> nonProxies_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetNoProxy")));
if(nonProxies_name.is() && nonProxies_name->getStringValue().getLength()) {
- OUString httpNonProxyHosts = OUSTR("http.nonProxyHosts=");
- OUString ftpNonProxyHosts= OUSTR("ftp.nonProxyHosts=");
- OUString value= nonProxies_name->getStringValue();
+ rtl::OUString httpNonProxyHosts = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.nonProxyHosts="));
+ rtl::OUString ftpNonProxyHosts= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.nonProxyHosts="));
+ rtl::OUString value= nonProxies_name->getStringValue();
// replace the separator ";" by "|"
value= value.replace((sal_Unicode)';', (sal_Unicode)'|');
@@ -994,6 +426,52 @@ static void getINetPropsFromConfig(JVM * pjvm,
xConfRegistry_simple->close();
}
+void getDefaultLocaleFromConfig(stoc_javavm::JVM * pjvm,
+ const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr,
+ const css::uno::Reference<css::uno::XComponentContext> &xCtx ) throw(css::uno::Exception)
+{
+ css::uno::Reference<css::uno::XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationRegistry")),
+ xCtx );
+ if(!xConfRegistry.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")), 0);
+
+ css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple(xConfRegistry, css::uno::UNO_QUERY);
+ if(!xConfRegistry_simple.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")), 0);
+
+ xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")), sal_True, sal_False);
+ css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
+
+ // read locale
+ css::uno::Reference<css::registry::XRegistryKey> locale = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale")));
+ if(locale.is() && locale->getStringValue().getLength()) {
+ rtl::OUString language;
+ rtl::OUString country;
+
+ sal_Int32 index = locale->getStringValue().indexOf((sal_Unicode) '-');
+
+ if(index >= 0) {
+ language = locale->getStringValue().copy(0, index);
+ country = locale->getStringValue().copy(index + 1);
+
+ if(language.getLength()) {
+ rtl::OUString prop(RTL_CONSTASCII_USTRINGPARAM("user.language="));
+ prop += language;
+
+ pjvm->pushProp(prop);
+ }
+
+ if(country.getLength()) {
+ rtl::OUString prop(RTL_CONSTASCII_USTRINGPARAM("user.region="));
+ prop += country;
+
+ pjvm->pushProp(prop);
+ }
+ }
+ }
+
+ xConfRegistry_simple->close();
+}
+
/* When the setup is started from an installation (not the first installation)
and Java is used then this function fails, because the ConfigurationRegistry service
is not available to the setup. That is, the javarc cannot be read and values from
@@ -1002,85 +480,88 @@ must not use the javarc either. Otherwise the LD_LIBRARY_PATH (set by javaldx) w
for a different java as the one the runtime lib is from. The runtime lib is set in
the setup (environment variable OO_JAVA_PROPERTIES).
*/
-static void getJavaPropsFromConfig(JVM * pjvm,
- const Reference<XMultiComponentFactory> & xSMgr,
- const Reference<XComponentContext> &xCtx) throw(Exception)
+void getJavaPropsFromConfig(stoc_javavm::JVM * pjvm,
+ const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr,
+ const css::uno::Reference<css::uno::XComponentContext> &xCtx) throw(css::uno::Exception)
{
- Reference<XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
- OUSTR("com.sun.star.configuration.ConfigurationRegistry"),
+ css::uno::Reference<css::uno::XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationRegistry")),
xCtx);
if(!xConfRegistry.is())
- throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"),
- Reference<XInterface>());
- Reference<XSimpleRegistry> xConfRegistry_simple(xConfRegistry, UNO_QUERY);
+ throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")),
+ 0);
+ css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple(xConfRegistry, css::uno::UNO_QUERY);
if(!xConfRegistry_simple.is())
- throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"),
- Reference<XInterface>());
- xConfRegistry_simple->open(OUSTR("org.openoffice.Setup"), sal_True, sal_False);
+ throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")),
+ 0);
+ xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")), sal_True, sal_False);
- Reference<XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
+ css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
- Reference<XRegistryKey> key_InstallPath = xRegistryRootKey->openKey(
- OUSTR("Office/ooSetupInstallPath"));
+ css::uno::Reference<css::registry::XRegistryKey> key_InstallPath = xRegistryRootKey->openKey(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office/ooSetupInstallPath")));
if(!key_InstallPath.is())
- throw RuntimeException(OUSTR("javavm.cxx: can not find key: " \
- "Office/InstallPath in org.openoffice.UserProfile"),
- Reference<XInterface>());
- OUString rcPath = key_InstallPath->getStringValue();
+ throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: can not find key: " \
+ "Office/InstallPath in org.openoffice.UserProfile")),
+ 0);
+ rtl::OUString rcPath = key_InstallPath->getStringValue();
key_InstallPath->closeKey();
xRegistryRootKey->closeKey();
- OUString urlrcPath;
- if( File::E_None != File::getFileURLFromSystemPath( rcPath, urlrcPath ) )
- throw RuntimeException(OUSTR("javavm.cxx: could not convert a system path to URL"),
- Reference<XInterface>());
+ rtl::OUString urlrcPath;
+ if( osl::File::E_None != osl::File::getFileURLFromSystemPath( rcPath, urlrcPath ) )
+ throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: could not convert a system path to URL")),
+ 0);
- urlrcPath += OUSTR("/config/" INI_FILE);
+ urlrcPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/config/" INI_FILE));
- File *pIniFile= new File(urlrcPath);
- if( pIniFile->open(OpenFlag_Read) != File::E_None)
+ // TODO change pIniFile, pIni2 from plain pointers to auto_ptrs or stack
+ // variables; at least pIniFile is sometimes not deleted
+
+ osl::File *pIniFile= new osl::File(urlrcPath);
+ if( pIniFile->open(OpenFlag_Read) != osl::File::E_None)
{
// Probably network installation. A workstation installation does not need to have its own javarc.
// Then we use the one from the network insallation ( <install-di>/share/config/javarc)
- xConfRegistry_simple->open(OUSTR("org.openoffice.Office.Common"), sal_True, sal_False);
- Reference<XRegistryKey> xRegistryCommonRootKey = xConfRegistry_simple->getRootKey();
-
- Reference<XRegistryKey> key_NetInstallPath = xRegistryCommonRootKey->openKey(
- OUSTR("Path/Current/OfficeInstall"));
- if(!key_NetInstallPath.is()) throw RuntimeException(
- OUSTR("javavm.cxx: can not find key: Office/InstallPath in org.openoffice.UserProfile"),
- Reference<XInterface>());
+ xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common")), sal_True, sal_False);
+ css::uno::Reference<css::registry::XRegistryKey> xRegistryCommonRootKey = xConfRegistry_simple->getRootKey();
+
+ css::uno::Reference<css::registry::XRegistryKey> key_NetInstallPath = xRegistryCommonRootKey->openKey(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Path/Current/OfficeInstall")));
+ if(!key_NetInstallPath.is()) throw css::uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: can not find key: Office/InstallPath in org.openoffice.UserProfile")),
+ 0);
rcPath = key_NetInstallPath->getStringValue();
// convert to file url
- if( osl_File_E_None != File::getFileURLFromSystemPath( rcPath, urlrcPath ) )
+ if( osl_File_E_None != osl::File::getFileURLFromSystemPath( rcPath, urlrcPath ) )
{
urlrcPath = rcPath;
}
- urlrcPath += OUSTR("/share/config/" INI_FILE);
+ urlrcPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/share/config/" INI_FILE));
key_NetInstallPath->closeKey();
- File *pIni2= new File(urlrcPath);
- if(pIni2->open(OpenFlag_Read) != File::E_None)
+ osl::File *pIni2= new osl::File(urlrcPath);
+ if(pIni2->open(OpenFlag_Read) != osl::File::E_None)
{
- throw JavaNotConfiguredException (
- OUSTR("javavm.cxx: can not find " INI_FILE ),
- Reference<XInterface>());
+ throw css::java::JavaNotConfiguredException (
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: can not find " INI_FILE )),
+ 0);
}
else
pIniFile= pIni2;
}
//Find the Java Section
- OString sJavaSection("[Java]");
+ rtl::OString sJavaSection("[Java]");
bool bSectionFound= false;
while(1)
{
- ByteSequence seq;
- if(pIniFile->readLine(seq) == File::E_None)
+ rtl::ByteSequence seq;
+ if(pIniFile->readLine(seq) == osl::File::E_None)
{
- OString line((sal_Char*)seq.getArray(),seq.getLength());
+ rtl::OString line((sal_Char*)seq.getArray(),seq.getLength());
if(line.match(sJavaSection, 0))
{
bSectionFound= true;
@@ -1092,18 +573,20 @@ static void getJavaPropsFromConfig(JVM * pjvm,
break;
}
+ // TODO encoding of ini file???
+
//Read each line from the Java section
if(bSectionFound)
{
while(1)
{
- ByteSequence seq;
+ rtl::ByteSequence seq;
sal_Bool bEOF;
- OUString usProp;
- if(pIniFile->readLine(seq) == File::E_None)
+ rtl::OUString usProp;
+ if(pIniFile->readLine(seq) == osl::File::E_None)
{
//check if another Section starts
- OString line((sal_Char*)seq.getArray(), seq.getLength());
+ rtl::OString line((sal_Char*)seq.getArray(), seq.getLength());
if(line.indexOf('[') == 0)
break;
//check if there is '=' after the first word
@@ -1134,7 +617,7 @@ static void getJavaPropsFromConfig(JVM * pjvm,
}
// Ok, store the line
line.trim();
- usProp= OStringToOUString(line, osl_getThreadTextEncoding());
+ usProp= rtl::OStringToOUString(line, osl_getThreadTextEncoding());
pjvm->pushProp(usProp);
nextLine:
pIniFile->isEndOfFile(&bEOF);
@@ -1149,54 +632,146 @@ static void getJavaPropsFromConfig(JVM * pjvm,
}
}
-static const Bootstrap & getBootstrapHandle()
+void getJavaPropsFromEnvironment(stoc_javavm::JVM * pjvm) throw() {
+
+ const char * pClassPath = getenv("CLASSPATH");
+ if( pClassPath )
+ {
+ pjvm->addSystemClasspath( rtl::OUString::createFromAscii(pClassPath) );
+ }
+ pjvm->setRuntimeLib(rtl::OUString::createFromAscii(DEF_JAVALIB));
+ pjvm->setEnabled(1);
+
+ // See if properties have been set and parse them
+ const char * pOOjavaProperties = getenv(PROPERTIES_ENV);
+ if(pOOjavaProperties) {
+ rtl::OUString properties(rtl::OUString::createFromAscii(pOOjavaProperties));
+
+ sal_Int32 index;
+ sal_Int32 lastIndex = 0;
+
+ do {
+ index = properties.indexOf((sal_Unicode)',', lastIndex);
+ rtl::OUString token = (index == -1) ? properties.copy(lastIndex) : properties.copy(lastIndex, index - lastIndex);
+
+ lastIndex = index + 1;
+
+ pjvm->pushProp(token);
+ }
+ while(index > -1);
+ }
+}
+
+void getJavaPropsFromSafetySettings(stoc_javavm::JVM * pjvm,
+ const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr,
+ const css::uno::Reference<css::uno::XComponentContext> &xCtx) throw(css::uno::Exception)
+{
+ css::uno::Reference<css::uno::XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationRegistry")),
+ xCtx);
+ if(!xConfRegistry.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")), 0);
+
+ css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple(xConfRegistry, css::uno::UNO_QUERY);
+ if(!xConfRegistry_simple.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")), 0);
+
+ xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Java")), sal_True, sal_False);
+ css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
+
+ if (xRegistryRootKey.is())
+ {
+ css::uno::Reference<css::registry::XRegistryKey> key_Enable = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VirtualMachine/Enable")));
+ if (key_Enable.is())
+ {
+ sal_Bool bEnableVal= (sal_Bool) key_Enable->getLongValue();
+ pjvm->setEnabled( bEnableVal);
+ }
+ css::uno::Reference<css::registry::XRegistryKey> key_UserClasspath = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VirtualMachine/UserClassPath")));
+ if (key_UserClasspath.is())
+ {
+ rtl::OUString sClassPath= key_UserClasspath->getStringValue();
+ pjvm->addUserClasspath( sClassPath);
+ }
+ css::uno::Reference<css::registry::XRegistryKey> key_NetAccess= xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VirtualMachine/NetAccess")));
+ if (key_NetAccess.is())
+ {
+ sal_Int32 val= key_NetAccess->getLongValue();
+ rtl::OUString sVal;
+ switch( val)
+ {
+ case 0: sVal= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unrestricted"));
+ break;
+ case 1: sVal= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("none"));
+ break;
+ case 2: sVal= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("host"));
+ break;
+ }
+ rtl::OUString sProperty( RTL_CONSTASCII_USTRINGPARAM("appletviewer.security.mode="));
+ sProperty= sProperty + sVal;
+ pjvm->pushProp(sProperty);
+ }
+ css::uno::Reference<css::registry::XRegistryKey> key_CheckSecurity= xRegistryRootKey->openKey(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VirtualMachine/Security")));
+ if( key_CheckSecurity.is())
+ {
+ sal_Bool val= (sal_Bool) key_CheckSecurity->getLongValue();
+ rtl::OUString sProperty(RTL_CONSTASCII_USTRINGPARAM("stardiv.security.disableSecurity="));
+ if( val)
+ sProperty= sProperty + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("false"));
+ else
+ sProperty= sProperty + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("true"));
+ pjvm->pushProp( sProperty);
+ }
+ }
+ xConfRegistry_simple->close();
+}
+
+const rtl::Bootstrap & getBootstrapHandle()
{
static rtl::Bootstrap *pBootstrap = 0;
if( !pBootstrap )
{
- OUString exe;
+ rtl::OUString exe;
osl_getExecutableFile( &(exe.pData) );
sal_Int32 nIndex = exe.lastIndexOf( '/' );
- OUString ret;
+ rtl::OUString ret;
if( exe.getLength() && nIndex != -1 )
{
- OUStringBuffer buf( exe.getLength() + 10 );
+ rtl::OUStringBuffer buf( exe.getLength() + 10 );
buf.append( exe.getStr() , nIndex +1 ).appendAscii( SAL_CONFIGFILE("uno") );
ret = buf.makeStringAndClear();
}
#ifdef DEBUG
- OString o = OUStringToOString( ret , RTL_TEXTENCODING_ASCII_US );
+ rtl::OString o = rtl::OUStringToOString( ret , RTL_TEXTENCODING_ASCII_US );
printf( "JavaVM: Used ininame %s\n" , o.getStr() );
#endif
- static Bootstrap bootstrap( ret );
+ static rtl::Bootstrap bootstrap( ret );
pBootstrap = &bootstrap;
}
return *pBootstrap;
}
-
-static OUString retrieveComponentClassPath( const sal_Char *pVariableName )
+rtl::OUString retrieveComponentClassPath( const sal_Char *pVariableName )
{
- OUString ret;
- OUStringBuffer buf( 128 );
+ rtl::OUString ret;
+ rtl::OUStringBuffer buf( 128 );
buf.appendAscii( "$" ).appendAscii( pVariableName );
- OUString path( buf.makeStringAndClear() );
+ rtl::OUString path( buf.makeStringAndClear() );
- const Bootstrap & handle = getBootstrapHandle();
+ const rtl::Bootstrap & handle = getBootstrapHandle();
rtl_bootstrap_expandMacros_from_handle( *(void**)&handle , &(path.pData) );
if( path.getLength() )
{
buf.append( path ).appendAscii( "/java_classpath" );
- OUString fileName( buf.makeStringAndClear() );
+ rtl::OUString fileName( buf.makeStringAndClear() );
sal_Char * p = 0;
- DirectoryItem item;
- if( DirectoryItem::E_None == DirectoryItem::get( fileName , item ) )
+ osl::DirectoryItem item;
+ if( osl::DirectoryItem::E_None == osl::DirectoryItem::get( fileName , item ) )
{
- FileStatus status ( osl_FileStatus_Mask_FileSize );
- if( FileBase::E_None == item.getFileStatus( status ) )
+ osl::FileStatus status ( osl_FileStatus_Mask_FileSize );
+ if( osl::FileBase::E_None == item.getFileStatus( status ) )
{
sal_Int64 nSize = status.getFileSize();
if( nSize )
@@ -1204,14 +779,14 @@ static OUString retrieveComponentClassPath( const sal_Char *pVariableName )
sal_Char * p = (sal_Char * ) rtl_allocateMemory( (sal_uInt32)nSize +1 );
if( p )
{
- File file( fileName );
- if( File::E_None == file.open( OpenFlag_Read ) )
+ osl::File file( fileName );
+ if( osl::File::E_None == file.open( OpenFlag_Read ) )
{
sal_uInt64 nRead;
- if( File::E_None == file.read( p , (sal_uInt64)nSize , nRead )
+ if( osl::File::E_None == file.read( p , (sal_uInt64)nSize , nRead )
&& (sal_uInt64)nSize == nRead )
{
- buf = OUStringBuffer( 1024 );
+ buf = rtl::OUStringBuffer( 1024 );
sal_Int32 nIndex = 0;
sal_Bool bPrepend = sal_False;
@@ -1220,12 +795,12 @@ static OUString retrieveComponentClassPath( const sal_Char *pVariableName )
while( nIndex < nSize && p[nIndex] == ' ' ) nIndex ++;
sal_Int32 nStart = nIndex;
while( nIndex < nSize && p[nIndex] != ' ' ) nIndex ++;
- OUString relativeUrl( &(p[nStart]), nIndex-nStart, RTL_TEXTENCODING_ASCII_US);
+ rtl::OUString relativeUrl( &(p[nStart]), nIndex-nStart, RTL_TEXTENCODING_ASCII_US); // TODO encoding???
relativeUrl = relativeUrl.trim();
if (0 < relativeUrl.getLength())
{
- OUString fileurlElement;
- OUString systemPathElement;
+ rtl::OUString fileurlElement;
+ rtl::OUString systemPathElement;
OSL_VERIFY(
osl_File_E_None ==
@@ -1258,115 +833,42 @@ static OUString retrieveComponentClassPath( const sal_Char *pVariableName )
}
#ifdef DEBUG
fprintf( stderr, "JavaVM: classpath retrieved from $%s: %s\n", pVariableName,
- OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US).getStr());
+ rtl::OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US).getStr());
#endif
return ret;
}
-static void getJavaPropsFromSafetySettings(JVM * pjvm,
- const Reference<XMultiComponentFactory> & xSMgr,
- const Reference<XComponentContext> &xCtx) throw(Exception)
-{
- Reference<XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
- OUSTR("com.sun.star.configuration.ConfigurationRegistry"),
- xCtx);
- if(!xConfRegistry.is()) throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"), Reference<XInterface>());
-
- Reference<XSimpleRegistry> xConfRegistry_simple(xConfRegistry, UNO_QUERY);
- if(!xConfRegistry_simple.is()) throw RuntimeException(OUSTR("javavm.cxx: couldn't get ConfigurationRegistry"), Reference<XInterface>());
-
- xConfRegistry_simple->open(OUSTR("org.openoffice.Office.Java"), sal_True, sal_False);
- Reference<XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
-
- if (xRegistryRootKey.is())
- {
- Reference<XRegistryKey> key_Enable = xRegistryRootKey->openKey(OUSTR("VirtualMachine/Enable"));
- if (key_Enable.is())
- {
- sal_Bool bEnableVal= (sal_Bool) key_Enable->getLongValue();
- pjvm->setEnabled( bEnableVal);
- }
- Reference<XRegistryKey> key_UserClasspath = xRegistryRootKey->openKey(OUSTR("VirtualMachine/UserClassPath"));
- if (key_UserClasspath.is())
- {
- OUString sClassPath= key_UserClasspath->getStringValue();
- pjvm->addUserClasspath( sClassPath);
- }
- Reference<XRegistryKey> key_NetAccess= xRegistryRootKey->openKey(OUSTR("VirtualMachine/NetAccess"));
- if (key_NetAccess.is())
- {
- sal_Int32 val= key_NetAccess->getLongValue();
- OUString sVal;
- switch( val)
- {
- case 0: sVal= OUSTR("unrestricted");
- break;
- case 1: sVal= OUSTR("none");
- break;
- case 2: sVal= OUSTR("host");
- break;
- }
- OUString sProperty( RTL_CONSTASCII_USTRINGPARAM("appletviewer.security.mode="));
- sProperty= sProperty + sVal;
- pjvm->pushProp(sProperty);
- }
- Reference<XRegistryKey> key_CheckSecurity= xRegistryRootKey->openKey(
- OUSTR("VirtualMachine/Security"));
- if( key_CheckSecurity.is())
- {
- sal_Bool val= (sal_Bool) key_CheckSecurity->getLongValue();
- OUString sProperty(RTL_CONSTASCII_USTRINGPARAM("stardiv.security.disableSecurity="));
- if( val)
- sProperty= sProperty + OUSTR("false");
- else
- sProperty= sProperty + OUSTR("true");
- pjvm->pushProp( sProperty);
- }
- }
- xConfRegistry_simple->close();
-}
-
-
-static void getJavaPropsFromEnvironment(JVM * pjvm) throw() {
-
- const char * pClassPath = getenv("CLASSPATH");
- if( pClassPath )
- {
- pjvm->addSystemClasspath( OUString::createFromAscii(pClassPath) );
- }
- pjvm->setRuntimeLib(OUString::createFromAscii(DEF_JAVALIB));
- pjvm->setEnabled(1);
-
- // See if properties have been set and parse them
- const char * pOOjavaProperties = getenv(PROPERTIES_ENV);
- if(pOOjavaProperties) {
- OUString properties(OUString::createFromAscii(pOOjavaProperties));
-
- sal_Int32 index;
- sal_Int32 lastIndex = 0;
-
- do {
- index = properties.indexOf((sal_Unicode)',', lastIndex);
- OUString token = (index == -1) ? properties.copy(lastIndex) : properties.copy(lastIndex, index - lastIndex);
-
- lastIndex = index + 1;
+static void setTimeZone(stoc_javavm::JVM * pjvm) throw() {
+ /* A Bug in the Java function
+ ** struct Hjava_util_Properties * java_lang_System_initProperties(
+ ** struct Hjava_lang_System *this,
+ ** struct Hjava_util_Properties *props);
+ ** This function doesn't detect MEZ, MET or "W. Europe Standard Time"
+ */
+ struct tm *tmData;
+ time_t clock = time(NULL);
+ tzset();
+ tmData = localtime(&clock);
+#ifdef MACOSX
+ char * p = tmData->tm_zone;
+#else
+ char * p = tzname[0];
+#endif
- pjvm->pushProp(token);
- }
- while(index > -1);
- }
+ if (!strcmp(TIMEZONE, p))
+ pjvm->pushProp(rtl::OUString::createFromAscii("user.timezone=ECT"));
}
-static void initVMConfiguration(JVM * pjvm,
- const Reference<XMultiComponentFactory> & xSMgr,
- const Reference<XComponentContext > &xCtx) throw(Exception) {
- JVM jvm;
+void initVMConfiguration(stoc_javavm::JVM * pjvm,
+ const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr,
+ const css::uno::Reference<css::uno::XComponentContext > &xCtx) throw(css::uno::Exception) {
+ stoc_javavm::JVM jvm;
try {
getINetPropsFromConfig(&jvm, xSMgr, xCtx);
}
- catch(Exception & exception) {
+ catch(css::uno::Exception & exception) {
#ifdef DEBUG
- OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
+ rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("javavm.cxx: can not get INetProps cause of >%s<", message.getStr());
#endif
}
@@ -1374,29 +876,29 @@ static void initVMConfiguration(JVM * pjvm,
try {
getDefaultLocaleFromConfig(&jvm, xSMgr,xCtx);
}
- catch(Exception & exception) {
+ catch(css::uno::Exception & exception) {
#ifdef DEBUG
- OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
+ rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("javavm.cxx: can not get locale cause of >%s<", message.getStr());
#endif
}
sal_Bool bPropsFail= sal_False;
sal_Bool bPropsFail2= sal_False;
- JavaNotConfiguredException confexc;
+ css::java::JavaNotConfiguredException confexc;
try
{
getJavaPropsFromConfig(&jvm, xSMgr,xCtx);
}
- catch(JavaNotConfiguredException& e)
+ catch(css::java::JavaNotConfiguredException& e)
{
confexc= e;
bPropsFail= sal_True;
}
- catch(Exception & exception)
+ catch(css::uno::Exception & exception)
{
#ifdef DEBUG
- OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
+ rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("javavm.cxx: couldn't use configuration cause of >%s<", message.getStr());
#endif
bPropsFail2= sal_True;
@@ -1407,16 +909,16 @@ static void initVMConfiguration(JVM * pjvm,
getJavaPropsFromEnvironment(&jvm);
// at this point we have to find out if there is a classpath. If not
// we'll throw the exception, because Java is misconfigured and won't run.
- OUString usRuntimeLib= jvm.getRuntimeLib();
- OUString usUserClasspath= jvm.getUserClasspath();
- OUString usSystemClasspath= jvm.getSystemClasspath();
+ rtl::OUString usRuntimeLib= jvm.getRuntimeLib();
+ rtl::OUString usUserClasspath= jvm.getUserClasspath();
+ rtl::OUString usSystemClasspath= jvm.getSystemClasspath();
if( usUserClasspath.getLength() == 0 && usSystemClasspath.getLength() == 0)
{
if (bPropsFail)
throw confexc;
- throw JavaNotConfiguredException(OUSTR("There is neither a java.ini (or javarc) " \
+ throw css::java::JavaNotConfiguredException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("There is neither a java.ini (or javarc) " \
"and there are no environment variables set which " \
- "contain configuration data"), Reference<XInterface>());
+ "contain configuration data")), 0);
}
}
@@ -1424,20 +926,20 @@ static void initVMConfiguration(JVM * pjvm,
try {
getJavaPropsFromSafetySettings(&jvm, xSMgr, xCtx);
}
- catch(Exception & exception) {
+ catch(css::uno::Exception & exception) {
#ifdef DEBUG
- OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
+ rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("javavm.cxx: couldn't get safety settings because of >%s<", message.getStr());
#endif
}
jvm.addSystemClasspath( retrieveComponentClassPath( "UNO_SHARE_PACKAGES_CACHE" ) );
jvm.addUserClasspath( retrieveComponentClassPath( "UNO_USER_PACKAGES_CACHE" ) );
-//For a non product office we use the flags -ea
+//For a non product office we use the flag -ea
// we cannot use -Xcheck:jni, because this prevents debugging (j2re1.4.1_01, netbeans 3.4)
#ifdef _DEBUG
if(!getenv( "DISABLE_SAL_DBGBOX" ) )
- jvm.pushProp(OUSTR("-ea"));
+ jvm.pushProp(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-ea")));
#endif
@@ -1449,485 +951,856 @@ static void initVMConfiguration(JVM * pjvm,
// pjvm->setAbort(vm_abort);
}
-JavaVirtualMachine_Impl::JavaVirtualMachine_Impl(const Reference< XComponentContext > &xCtx) throw()
- : _pVMContext(NULL)
- , _pJava_environment(NULL)
- , _xSMgr( xCtx->getServiceManager() )
- , _xCtx( xCtx )
- ,m_bInteractionAbort(sal_False)
- ,m_bInteractionRetry(sal_False)
- ,m_bDontCreateJVM(sal_False)
-
-{
- pCreatorThread= new OCreatorThread(this);
-}
+jmp_buf jmp_jvm_abort;
+sig_atomic_t g_bInGetJavaVM = 0;
-JavaVirtualMachine_Impl::~JavaVirtualMachine_Impl() throw()
+void abort_handler()
{
- if (_pVMContext)
- {
- if( pCreatorThread)
- {
- pCreatorThread->disposeJavaVM();
- delete pCreatorThread;
- }
-
- }
- if (_xConfigurationAccess.is())
- {
- Reference< XContainer > xContainer(_xConfigurationAccess, UNO_QUERY);
- if (xContainer.is())
- xContainer->removeContainerListener( static_cast< XContainerListener* >(this));
- }
- if (_xConfigurationAccess2.is())
+ // If we are within JNI_CreateJavaVM then we jump back into getJavaVM
+ if( g_bInGetJavaVM != 0 )
{
- Reference< XContainer > xContainer(_xConfigurationAccess2, UNO_QUERY);
- if (xContainer.is())
- xContainer->removeContainerListener( static_cast< XContainerListener* >(this));
+ fprintf( stderr, "JavaVM: JNI_CreateJavaVM called _exit, caught by abort_handler in javavm.cxx\n");
+ longjmp( jmp_jvm_abort, 0);
}
+}
- if (_xSMgr.is())
- {
- Reference< XComponent > xComp(_xSMgr, UNO_QUERY);
- if (xComp.is())
- xComp->removeEventListener( static_cast< XEventListener* >(this));
- }
}
+extern "C" void SAL_CALL
+component_getImplementationEnvironment(sal_Char const ** pEnvTypeName,
+ uno_Environment **)
+{
+ *pEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
-JavaVM * JavaVirtualMachine_Impl::createJavaVM(const JVM & jvm) throw(RuntimeException)
+extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager,
+ void * pRegistryKey)
{
- JavaVM * pJavaVM;
- // On linux we load jvm with RTLD_GLOBAL. This is necessary for debugging, because
- // libjdwp.so need a symbol (fork1) from libjvm which it only gets if the jvm is loaded
- // witd RTLD_GLOBAL. On Solaris libjdwp.so is correctly linked with libjvm.so
-#ifdef LINUX
- if(!_javaLib.load(jvm.getRuntimeLib(), SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_NOW))
-#else
- if(!_javaLib.load(jvm.getRuntimeLib()))
-#endif
+ if (cppu::component_writeInfoHelper(pServiceManager, pRegistryKey,
+ aServiceImplementation))
{
- //Java installation was deleted or moved
- OUString libURL;
- if( File::getFileURLFromSystemPath( jvm.getJavaHome(), libURL) != File::E_None)
- libURL= OUSTR("");
- MissingJavaRuntimeException exc(
- OUSTR("JavaVirtualMachine_Impl::createJavaVM, Java runtime library cannot be found"),
- Reference<XInterface>(), libURL);
- WrappedTargetRuntimeException wt;
- wt.TargetException<<= exc;
- throw wt;
- }
-
-#ifdef UNX
- OUString javaHome(RTL_CONSTASCII_USTRINGPARAM("JAVA_HOME="));
- javaHome += jvm.getJavaHome();
- const OUString & vmType = jvm.getVMType();
-
- if(!vmType.equals(OUSTR("JRE")))
+ try
{
- javaHome += OUSTR("/jre");
+ css::uno::Reference< css::registry::XRegistryKey >(
+ reinterpret_cast< css::registry::XRegistryKey * >(
+ pRegistryKey)->
+ createKey(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.stoc.JavaVirtualMachine"
+ "/UNO/SINGLETONS/"
+ "com.sun.star.java.theJavaVirtualMachine"))))->
+ setStringValue(serviceGetServiceName());
+ return true;
}
-
- OString osJavaHome = OUStringToOString(javaHome, osl_getThreadTextEncoding());
- putenv(strdup(osJavaHome.getStr()));
-#endif
-
- JNI_InitArgs_Type * initArgs = (JNI_InitArgs_Type *)_javaLib.getSymbol(
- OUSTR("JNI_GetDefaultJavaVMInitArgs"));
- JNI_CreateVM_Type * pCreateJavaVM = (JNI_CreateVM_Type *)_javaLib.getSymbol(
- OUSTR("JNI_CreateJavaVM"));
- if (!initArgs || !pCreateJavaVM)
+ catch (css::uno::Exception &)
{
- // The java installation is somehow corrupted
- JavaVMCreationFailureException exc(
- OUSTR("JavaVirtualMachine_Impl::createJavaVM, could not find symbol " \
- "JNI_GetDefaultJavaVMInitArgs or JNI_CreateJavaVM"),
- Reference<XInterface>(), 1);
-
- WrappedTargetRuntimeException wt;
- wt.TargetException<<= exc;
- throw wt;
+ OSL_ENSURE(false, "com.sun.star.uno.Exception caught");
}
+ }
+ return false;
+}
- JNIEnv * pJNIEnv = NULL;
+extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName,
+ void * pServiceManager,
+ void * pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(pImplName, pServiceManager,
+ pRegistryKey,
+ aServiceImplementation);
+}
- // Try VM 1.1
- JDK1_1InitArgs vm_args;
- vm_args.version= 0x00010001;
- jint ret= initArgs(&vm_args);
- jvm.setArgs(&vm_args);
+// There is no component_canUnload, as the library cannot be unloaded.
+
+JavaVirtualMachine::JavaVirtualMachine(
+ css::uno::Reference< css::uno::XComponentContext > const & rContext):
+ JavaVirtualMachine_Impl(*static_cast< osl::Mutex * >(this)),
+ m_xContext(rContext),
+ m_bDisposed(false),
+ m_bDontCreateJvm(false),
+ m_aAttachGuards(destroyAttachGuards) // TODO check for validity
+{}
+
+void SAL_CALL
+JavaVirtualMachine::initialize(css::uno::Sequence< css::uno::Any > const &
+ rArguments)
+ throw (css::uno::Exception)
+{
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ if (m_xVirtualMachine.is())
+ throw css::uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "bad call to initialize")),
+ static_cast< cppu::OWeakObject * >(this));
+ OSL_ENSURE(sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *),
+ "Pointer cannot be represented as sal_Int64");
+ sal_Int64 nPointer = reinterpret_cast< sal_Int64 >(
+ static_cast< jvmaccess::VirtualMachine * >(0));
+ if (rArguments.getLength() == 1)
+ rArguments[0] >>= nPointer;
+ m_xVirtualMachine = reinterpret_cast< jvmaccess::VirtualMachine * >(
+ nPointer);
+ if (!m_xVirtualMachine.is())
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "sequence of exactly one any containing a hyper"
+ " representing a non-null pointer to a"
+ " jvmaccess::VirtualMachine required")),
+ static_cast< cppu::OWeakObject * >(this), 0);
+}
+
+rtl::OUString SAL_CALL JavaVirtualMachine::getImplementationName()
+ throw (css::uno::RuntimeException)
+{
+ return serviceGetImplementationName();
+}
+
+sal_Bool SAL_CALL
+JavaVirtualMachine::supportsService(rtl::OUString const & rServiceName)
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Sequence< rtl::OUString > aNames(getSupportedServiceNames());
+ for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
+ if (aNames[i] == rServiceName)
+ return true;
+ return false;
+}
- jint err;
- err= pCreateJavaVM(&pJavaVM, &pJNIEnv, &vm_args);
+css::uno::Sequence< rtl::OUString > SAL_CALL
+JavaVirtualMachine::getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+{
+ return serviceGetSupportedServiceNames();
+}
- if( err != 0)
+css::uno::Any SAL_CALL
+JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
+ throw (css::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ css::uno::Sequence< sal_Int8 > aId(16);
+ rtl_getGlobalProcessId(reinterpret_cast< sal_uInt8 * >(aId.getArray()));
+ // This method can return either a pointer to m_xVirtualMachine, or, for
+ // backwards compatibility, the underlying JavaVM pointer. If the passed in
+ // rProcessId has a 17th byte of value zero, a pointer to m_xVirtualMachine
+ // is returned. If the passed in rProcessId has only 16 bytes, the
+ // underlying JavaVM pointer is returned.
+ bool bReturnVirtualMachine
+ = rProcessId.getLength() == 17 && rProcessId[16] == 0;
+ css::uno::Sequence< sal_Int8 > aProcessId(rProcessId);
+ if (bReturnVirtualMachine)
+ aProcessId.realloc(16);
+ if (aId == aProcessId)
+ {
+ while (!m_xVirtualMachine.is()) // retry until successful
{
- // Try VM 1.2
+ stoc_javavm::JVM aJvm;
+ try
+ {
+ initVMConfiguration(&aJvm, m_xContext->getServiceManager(),
+ m_xContext);
+ }
+ catch (css::java::JavaNotConfiguredException & rException)
+ {
+ if (!askForRetry(css::uno::makeAny(rException)))
+ throw;
+ continue; // retry
+ }
- // The office sets a signal handler at startup. That causes a crash
- // with java 1.3 under Solaris. To make it work, we set back the
- // handler
-#ifdef UNX
- struct sigaction act;
- act.sa_handler=SIG_DFL;
- act.sa_flags= 0;
- sigaction( SIGSEGV, &act, NULL);
- sigaction( SIGPIPE, &act, NULL);
- sigaction( SIGBUS, &act, NULL);
- sigaction( SIGILL, &act, NULL);
- sigaction( SIGFPE, &act, NULL);
+ // This is the second attempt to create Java. m_bDontCreateJvm is
+ // set which means instantiating the JVM might crash.
+ if (m_bDontCreateJvm)
+ throw css::uno::RuntimeException();
-#endif
- sal_uInt16 cprops= jvm.getProperties().size();
-
- JavaVMInitArgs vm_args2;
-
- // we have "addOpt" additional properties to those kept in the JVM struct
- sal_Int32 addOpt=2;
- JavaVMOption * options= new JavaVMOption[cprops + addOpt];
- OString sClassPath= OString("-Djava.class.path=") + vm_args.classpath;
- options[0].optionString= (char*)sClassPath.getStr();
- options[0].extraInfo= NULL;
-
- // We set an abort handler which is called when the VM calls _exit during
- // JNI_CreateJavaVM. This happens when the LD_LIBRARY_PATH does not contain
- // all some directories of the Java installation. This is necessary for
- // linux j2re1.3, 1.4 and Solaris j2re1.3. With a j2re1.4 on Solaris the
- // LD_LIBRARY_PATH need not to be set anymore.
- options[1].optionString= "abort";
- options[1].extraInfo= (void* )abort_handler;
-
- OString * arProps= new OString[cprops];
-
- /*If there are entries in the Java section of the java.ini/javarc which are meant
- to be java system properties then they get a "-D" at the beginning of the string.
- Entries which start with "-" are regarded as java options as they are passed at
- the command-line. If those entries appear under the Java section then there are
- used as they are. For example, the entry "-ea" would be uses as
- JavaVMOption.optionString.
- */
- OString sJavaOption("-");
- for( sal_uInt16 x= 0; x< cprops; x++)
+ if (!aJvm.isEnabled())
{
- OString sOption(vm_args.properties[x]);
- if (!sOption.matchIgnoreAsciiCase(sJavaOption, 0))
- arProps[x]= OString("-D") + vm_args.properties[x];
- else
- arProps[x]= vm_args.properties[x];
- options[x+addOpt].optionString= (char*)arProps[x].getStr();
- options[x+addOpt].extraInfo= NULL;
+ css::java::JavaDisabledException aException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::getJavaVM failed because"
+ " Java is deactivated in the configuration")),
+ static_cast< cppu::OWeakObject * >(this));
+ if (!askForRetry(css::uno::makeAny(aException)))
+ throw aException;
+ continue; // retry
}
- vm_args2.version= 0x00010002;
- vm_args2.options= options;
- vm_args2.nOptions= cprops + addOpt;
- vm_args2.ignoreUnrecognized= JNI_TRUE;
-
- /* We set a global flag which is used by the abort handler in order to
- determine whether it is should use longjmp to get back into this function.
- That is, the abort handler determines if it is on the same stack as this function
- and then jumps back into this function.
- */
- g_bInGetJavaVM= sal_True;
- memset( jmp_jvm_abort, 0, sizeof(jmp_jvm_abort));
- int jmpval= setjmp( jmp_jvm_abort );
- /* If jmpval is not "0" then this point was reached by a longjmp in the
- abort_handler, which was called indirectly by JNI_CreateVM.
- */
- if( jmpval == 0)
+
+ JNIEnv * pMainThreadEnv;
+ try
{
- //returns negative number on failure
- err= pCreateJavaVM(&pJavaVM, &pJNIEnv, &vm_args2);
- g_bInGetJavaVM= sal_False;
- // Necessary to make debugging work. This thread will be suspended when this function
- // returns.
- if( err == 0)
- pJavaVM->DetachCurrentThread();
+ m_pJavaVm = createJavaVM(aJvm, &pMainThreadEnv);
}
- else
- // set err to a positive number, so as or recognize that an abort (longjmp)
- //occurred
- err= 1;
+ catch (css::lang::WrappedTargetRuntimeException & rException)
+ {
+ // Depending on platform and kind of error, it might be best not
+ // to create a JVM again, because it might crash the
+ // application:
+ if (rException.TargetException.isExtractableTo(
+ getCppuType(
+ static_cast<
+ css::java::JavaNotConfiguredException * >(0))))
+ {
+#if defined LINUX
+ // Because of LD_LIBRARY_PATH, even javaldx --use-links does
+ // not work sometimes:
+ m_bDontCreateJvm = true;
+#endif // LINUX
+ }
+ else if (rException.TargetException.isExtractableTo(
+ getCppuType(
+ static_cast<
+ css::java::MissingJavaRuntimeException * >(
+ 0))))
+ {
+#if defined LINUX
+ // Because of LD_LIBRARY_PATH, even javaldx --use-links does
+ // not work sometimes:
+ m_bDontCreateJvm = true;
+#endif // LINUX
+ }
+ else if (rException.TargetException.isExtractableTo(
+ getCppuType(
+ static_cast<
+ css::java::JavaVMCreationFailureException * >(
+ 0))))
+ m_bDontCreateJvm = true;
+
+ if (!askForRetry(rException.TargetException))
+ {
+ if (rException.TargetException.isExtractableTo(
+ getCppuType(
+ static_cast<
+ css::java::JavaNotConfiguredException * >(
+ 0)))
+ || rException.TargetException.isExtractableTo(
+ getCppuType(
+ static_cast<
+ css::java::MissingJavaRuntimeException * >(
+ 0)))
+ || rException.TargetException.isExtractableTo(
+ getCppuType(
+ static_cast<
+ css::java::JavaVMCreationFailureException * >(
+ 0))))
+ cppu::throwException(rException.TargetException);
+ throw;
+ }
+ continue; // retry
+ }
+
+ m_xVirtualMachine = new jvmaccess::VirtualMachine(
+ m_pJavaVm, JNI_VERSION_1_2, true, pMainThreadEnv);
- delete [] options;
- delete [] arProps;
+ // Necessary to make debugging work. This thread will be
+ // suspended when this function returns.
+ m_pJavaVm->DetachCurrentThread();
+
+ // Listen for changes in the configuration (e.g. proxy settings):
+ // TODO this is done too late; changes to the configuration done
+ // after the above call to initVMConfiguration are lost
+ registerConfigChangesListener();
}
- if(err != 0)
+ if (bReturnVirtualMachine)
{
- OUString message;
- if( err < 0)
- {
- message= OUSTR(
- "JavaVirtualMachine_Impl::createJavaVM - can not create VM, cause of err:");
- message += OUString::valueOf((sal_Int32)err);
- }
- else if( err > 0)
- message= OUSTR(
- "JavaVirtualMachine_Impl::createJavaVM - can not create VM, abort handler was called");
- JavaVMCreationFailureException exc(message,
- Reference<XInterface>(), err);
- WrappedTargetRuntimeException wt;
- wt.TargetException<<= exc;
- throw wt;
+ // Return a non-refcounted pointer to m_xVirtualMachine. It is
+ // guaranteed that this pointer is valid for the caller as long as
+ // the caller's reference to this XJavaVM service is valid; the
+ // caller should convert this non-refcounted pointer into a
+ // refcounted one as soon as possible.
+ OSL_ENSURE(sizeof (sal_Int64)
+ >= sizeof (jvmaccess::VirtualMachine *),
+ "Pointer cannot be represented as sal_Int64");
+ return css::uno::makeAny(reinterpret_cast< sal_Int64 >(
+ m_xVirtualMachine.get()));
}
- return pJavaVM;
+ else
+ {
+ if (sizeof (m_pJavaVm) <= sizeof (sal_Int32))
+ return css::uno::makeAny(reinterpret_cast< sal_Int32 >(
+ m_pJavaVm));
+ else if (sizeof (m_pJavaVm) <= sizeof (sal_Int64))
+ return css::uno::makeAny(reinterpret_cast< sal_Int64 >(
+ m_pJavaVm));
+ OSL_ENSURE(false, "Pointer cannot be represented as sal_Int64");
+ }
+ }
+ return css::uno::Any();
}
-// XJavaVM
-Any JavaVirtualMachine_Impl::getJavaVM(const Sequence<sal_Int8> & processId) throw (RuntimeException) {
- MutexGuard guarg(javavm_getMutex());
- Sequence<sal_Int8> localProcessID(16);
- rtl_getGlobalProcessId( (sal_uInt8*) localProcessID.getArray() );
+sal_Bool SAL_CALL JavaVirtualMachine::isVMStarted()
+ throw (css::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ return m_xVirtualMachine.is();
+}
- if (localProcessID == processId && !_pVMContext)
+sal_Bool SAL_CALL JavaVirtualMachine::isVMEnabled()
+ throw (css::uno::RuntimeException)
+{
{
- uno_Environment ** ppEnviroments = NULL;
- sal_Int32 size = 0;
- OUString java(OUString::createFromAscii("java"));
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ }
+ stoc_javavm::JVM aJvm;
+ initVMConfiguration(&aJvm, m_xContext->getServiceManager(), m_xContext);
+ return aJvm.isEnabled();
+}
- uno_getRegisteredEnvironments(&ppEnviroments, &size, (uno_memAlloc)malloc, java.pData);
+sal_Bool SAL_CALL JavaVirtualMachine::isThreadAttached()
+ throw (css::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ // TODO isThreadAttached only returns true if the thread was attached via
+ // registerThread:
+ GuardStack * pStack
+ = static_cast< GuardStack * >(m_aAttachGuards.getData());
+ return pStack != 0 && !pStack->empty();
+}
- if(size)
- { // do we found an existing java environment?
- OSL_TRACE("javavm.cxx: found an existing environment");
+void SAL_CALL JavaVirtualMachine::registerThread()
+ throw (css::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ if (!m_xVirtualMachine.is())
+ throw css::uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::registerThread:"
+ " null VirtualMachine")),
+ static_cast< cppu::OWeakObject * >(this));
+ GuardStack * pStack
+ = static_cast< GuardStack * >(m_aAttachGuards.getData());
+ if (pStack == 0)
+ {
+ pStack = new GuardStack;
+ m_aAttachGuards.setData(pStack);
+ }
+ try
+ {
+ pStack->push(
+ new jvmaccess::VirtualMachine::AttachGuard(m_xVirtualMachine));
+ }
+ catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ throw css::uno::RuntimeException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::registerThread: jvmaccess::"
+ "VirtualMachine::AttachGuard::CreationException")),
+ static_cast< cppu::OWeakObject * >(this));
+ }
+}
- _pJava_environment = ppEnviroments[0];
- _pJava_environment->acquire(_pJava_environment);
- _pVMContext = (JavaVMContext *)_pJava_environment->pContext;
+void SAL_CALL JavaVirtualMachine::revokeThread()
+ throw (css::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(*this);
+ if (m_bDisposed)
+ throw css::lang::DisposedException(
+ rtl::OUString(), static_cast< cppu::OWeakObject * >(this));
+ if (!m_xVirtualMachine.is())
+ throw css::uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::revokeThread:"
+ " null VirtualMachine")),
+ static_cast< cppu::OWeakObject * >(this));
+ GuardStack * pStack
+ = static_cast< GuardStack * >(m_aAttachGuards.getData());
+ if (pStack == 0 || pStack->empty())
+ throw css::uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::revokeThread:"
+ " no matching registerThread")),
+ static_cast< cppu::OWeakObject * >(this));
+ delete pStack->top();
+ pStack->pop();
+}
- for(sal_Int32 i = 0; i < size; ++ i)
- ppEnviroments[i]->release(ppEnviroments[i]);
+void SAL_CALL
+JavaVirtualMachine::disposing(css::lang::EventObject const & rSource)
+ throw (css::uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(*this);
+ if (rSource.Source == m_xInetConfiguration)
+ m_xInetConfiguration.clear();
+ if (rSource.Source == m_xJavaConfiguration)
+ m_xJavaConfiguration.clear();
+}
- free(ppEnviroments);
- }
+void SAL_CALL JavaVirtualMachine::elementInserted(
+ css::container::ContainerEvent const & rEvent)
+ throw (css::uno::RuntimeException)
+{}
+
+void SAL_CALL JavaVirtualMachine::elementRemoved(
+ css::container::ContainerEvent const & rEvent)
+ throw (css::uno::RuntimeException)
+{}
+
+// If a user changes the setting, for example for proxy settings, then this
+// function will be called from the configuration manager. Even if the .xml
+// file does not contain an entry yet and that entry has to be inserted, this
+// function will be called. We call java.lang.System.setProperty for the new
+// values.
+void SAL_CALL JavaVirtualMachine::elementReplaced(
+ css::container::ContainerEvent const & rEvent)
+ throw (css::uno::RuntimeException)
+{
+ // TODO Using the new value stored in rEvent is wrong here. If two threads
+ // receive different elementReplaced calls in quick succession, it is
+ // unspecified which changes the JVM's system properties last. A correct
+ // solution must atomically (i.e., protected by a mutex) read the latest
+ // value from the configuration and set it as a system property at the JVM.
+
+ rtl::OUString aAccessor;
+ rEvent.Accessor >>= aAccessor;
+ rtl::OUString aPropertyName;
+ rtl::OUString aPropertyName2;
+ rtl::OUString aPropertyValue;
+ bool bSecurityChanged = false;
+ if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ooInetProxyType")))
+ {
+ // Proxy none, manually
+ sal_Int32 value;
+ rEvent.Element >>= value;
+ setINetSettingsInVM(value != 0);
+ return;
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "ooInetHTTPProxyName")))
+ {
+ aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "http.proxyHost"));
+ rEvent.Element >>= aPropertyValue;
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "ooInetHTTPProxyPort")))
+ {
+ aPropertyName
+ = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort"));
+ sal_Int32 n = 0;
+ rEvent.Element >>= n;
+ aPropertyValue = rtl::OUString::valueOf(n);
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "ooInetFTPProxyName")))
+ {
+ aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "ftp.proxyHost"));
+ rEvent.Element >>= aPropertyValue;
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "ooInetFTPProxyPort")))
+ {
+ aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "ftp.proxyPort"));
+ sal_Int32 n = 0;
+ rEvent.Element >>= n;
+ aPropertyValue = rtl::OUString::valueOf(n);
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "ooInetNoProxy")))
+ {
+ aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "http.nonProxyHosts"));
+ aPropertyName2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "ftp.nonProxyHosts"));
+ rEvent.Element >>= aPropertyValue;
+ aPropertyValue = aPropertyValue.replace(';', '|');
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("NetAccess")))
+ {
+ aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "appletviewer.security.mode"));
+ sal_Int32 n;
+ if (rEvent.Element >>= n)
+ switch (n)
+ {
+ case 0:
+ aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "unrestricted"));
+ break;
+ case 1:
+ aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "none"));
+ break;
+ case 2:
+ aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "host"));
+ break;
+ }
else
- {
- JVM *pJvm= NULL;
- JavaVM * pJavaVM;
- retry:
- if( pJvm)
- delete pJvm;
- pJvm= new JVM;
+ return;
+ bSecurityChanged = true;
+ }
+ else if (aAccessor.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Security")))
+ {
+ aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
+ "stardiv.security.disableSecurity"));
+ sal_Bool b;
+ if (rEvent.Element >>= b)
+ if (b)
+ aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "false"));
+ else
+ aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "true"));
+ else
+ return;
+ bSecurityChanged = true;
+ }
+ else
+ return;
- try
+ rtl::Reference< jvmaccess::VirtualMachine > xVirtualMachine;
+ {
+ osl::MutexGuard aGuard(*this);
+ xVirtualMachine = m_xVirtualMachine;
+ }
+ if (xVirtualMachine.is())
+ {
+ try
+ {
+ jvmaccess::VirtualMachine::AttachGuard aAttachGuard(
+ xVirtualMachine);
+ JNIEnv * pJNIEnv = aAttachGuard.getEnvironment();
+
+ // call java.lang.System.setProperty
+ // String setProperty( String key, String value)
+ jclass jcSystem= pJNIEnv->FindClass("java/lang/System");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/lang/System")), 0);
+ jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.setProperty")), 0);
+
+ jstring jsPropName= pJNIEnv->NewString( aPropertyName.getStr(), aPropertyName.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+
+ // remove the property if it does not have a value ( user left the dialog field empty)
+ // or if the port is set to 0
+ aPropertyValue= aPropertyValue.trim();
+ if( aPropertyValue.getLength() == 0 ||
+ (aPropertyName.equals( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyPort"))) ||
+ aPropertyName.equals( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort"))) /*||
+ aPropertyName.equals( OUString( RTL_CONSTASCII_USTRINGPARAM("socksProxyPort")))*/) &&
+ aPropertyValue.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))))
{
- initVMConfiguration(pJvm, _xSMgr, _xCtx);
+ // call java.lang.System.getProperties
+ jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.getProperties")), 0);
+ jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.getProperties")), 0);
+ // call java.util.Properties.remove
+ jclass jcProperties= pJNIEnv->FindClass("java/util/Properties");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/util/Properties")), 0);
+ jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID java.util.Properties.remove")), 0);
+ jobject joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName);
+
+ // special calse for ftp.nonProxyHosts and http.nonProxyHosts. The office only
+ // has a value for two java properties
+ if (aPropertyName2.getLength() > 0)
+ {
+ jstring jsPropName2= pJNIEnv->NewString( aPropertyName2.getStr(), aPropertyName2.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jobject joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName2);
+ }
}
- catch( JavaNotConfiguredException & e)
+ else
{
- Any anyExc;
- anyExc <<= e;
- SelectedAction action= doClientInteraction( anyExc);
- switch( action)
+ // Change the Value of the property
+ jstring jsPropValue= pJNIEnv->NewString( aPropertyValue.getStr(), aPropertyValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+
+ // special calse for ftp.nonProxyHosts and http.nonProxyHosts. The office only
+ // has a value for two java properties
+ if (aPropertyName2.getLength() > 0)
{
- case action_abort:
- if( pJvm)
- delete pJvm;
- throw e;
- case action_retry: goto retry;
- default: goto retry;
+ jstring jsPropName= pJNIEnv->NewString( aPropertyName2.getStr(), aPropertyName2.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPropValue= pJNIEnv->NewString( aPropertyValue.getStr(), aPropertyValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
}
}
- if (pJvm->isEnabled() && !m_bDontCreateJVM)
+ // If the settings for Security and NetAccess changed then we have to notify the SandboxSecurity
+ // SecurityManager
+ // call System.getSecurityManager()
+ if (bSecurityChanged)
{
- // create the java vm
- try {
- // If there is an exception in createJavaVM then the client
- // is notified through XInteractionHandler. If they decide to
- // retry the action then createJavaVM does a longjmp to this
- // point
- pJavaVM = pCreatorThread->createJavaVM( * pJvm);
- }
- catch(WrappedTargetRuntimeException& e)
+ jmethodID jmGetSecur= pJNIEnv->GetStaticMethodID( jcSystem,"getSecurityManager","()Ljava/lang/SecurityManager;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.getSecurityManager")), 0);
+ jobject joSecur= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetSecur);
+ if (joSecur != 0)
{
- //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)
- {
- delete pJvm;
- pJvm= NULL;
- }
-
- SelectedAction action= doClientInteraction( e.TargetException);
- switch( action)
- {
- case action_abort:
+ // Make sure the SecurityManager is our SandboxSecurity
+ // FindClass("com.sun.star.lib.sandbox.SandboxSecurityManager" only worked at the first time
+ // this code was executed. Maybe it is a security feature. However, all attempts to debug the
+ // SandboxSecurity class (maybe the VM invokes checkPackageAccess) failed.
+// jclass jcSandboxSec= pJNIEnv->FindClass("com.sun.star.lib.sandbox.SandboxSecurity");
+// if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass com.sun.star.lib.sandbox.SandboxSecurity"), Reference<XInterface>());
+// jboolean bIsSand= pJNIEnv->IsInstanceOf( joSecur, jcSandboxSec);
+ // The SecurityManagers class Name must be com.sun.star.lib.sandbox.SandboxSecurity
+ jclass jcSec= pJNIEnv->GetObjectClass( joSecur);
+ jclass jcClass= pJNIEnv->FindClass("java/lang/Class");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java.lang.Class")), 0);
+ jmethodID jmName= pJNIEnv->GetMethodID( jcClass,"getName","()Ljava/lang/String;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID java.lang.Class.getName")), 0);
+ jstring jsClass= (jstring) pJNIEnv->CallObjectMethod( jcSec, jmName);
+ const jchar* jcharName= pJNIEnv->GetStringChars( jsClass, NULL);
+ rtl::OUString sName( jcharName);
+ jboolean bIsSandbox;
+ if (sName == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lib.sandbox.SandboxSecurity")))
+ bIsSandbox= JNI_TRUE;
+ else
+ bIsSandbox= JNI_FALSE;
+ pJNIEnv->ReleaseStringChars( jsClass, jcharName);
+
+ if (bIsSandbox == JNI_TRUE)
{
-
- if( valueType == getCppuType((JavaNotConfiguredException*)0))
- {
- JavaNotConfiguredException exc;
- e.TargetException >>= exc;
- throw exc;
- }
- else if( valueType == getCppuType((MissingJavaRuntimeException*)0))
- {
- MissingJavaRuntimeException exc;
- e.TargetException >>= exc;
- throw exc;
- }
- else if( valueType == getCppuType((JavaVMCreationFailureException*)0))
- {
- JavaVMCreationFailureException exc;
- e.TargetException >>= exc;
- throw exc;
- }
- }
- case action_retry: goto retry;
- default: goto retry;
+ // call SandboxSecurity.reset
+ jmethodID jmReset= pJNIEnv->GetMethodID( jcSec,"reset","()V");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset")), 0);
+ pJNIEnv->CallVoidMethod( joSecur, jmReset);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset")), 0);
}
}
- catch(RuntimeException & e)
- {
- e;
- // When the creation of the VM failed then we ensure that on the next
- // getJavaVM call a new attempt is made to create it. Therefore we
- // must get rid of the running thread and prepare a new one.
- delete pCreatorThread;
- pCreatorThread= new OCreatorThread(this);
- if( pJvm)
- delete pJvm;
- throw;
- }
- // create a context
- _pVMContext = new JavaVMContext(pJavaVM);
- // register the java vm at the uno runtime
- uno_getEnvironment(&_pJava_environment, java.pData, _pVMContext);
- // listen for changes in the configuration, e.g. proxy settings.
- registerConfigChangesListener();
- }
- 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
- // throw a JavaDisableException.
- JavaDisabledException exc(OUSTR("JavaVirtualMachine_Impl::getJavaVM " \
- "failed because Java is deactivated in the configuration"),
- Reference< XInterface >());
- Any anyExc;
- anyExc <<= exc;
- SelectedAction action= doClientInteraction( anyExc);
- switch( action)
- {
- case action_abort:
- if( pJvm)
- delete pJvm;
- throw exc;
- case action_retry: goto retry;
- 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;
+ }
+ catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ throw css::uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "jvmaccess::VirtualMachine::AttachGuard::"
+ "CreationException")),
+ 0);
}
}
+}
- Any any;
- if(_pVMContext)
- {
- if(sizeof(_pVMContext->_pJavaVM) == sizeof(sal_Int32)) { // 32 bit system?
- sal_Int32 nP = (sal_Int32)_pVMContext->_pJavaVM;
- any <<= nP;
+JavaVirtualMachine::~JavaVirtualMachine()
+{
+ if (m_xInetConfiguration.is())
+ // We should never get here, but just in case...
+ try
+ {
+ m_xInetConfiguration->removeContainerListener(this);
}
- else if(sizeof(_pVMContext->_pJavaVM) == sizeof(sal_Int64)) { // 64 bit system?
- sal_Int64 nP = (sal_Int64)_pVMContext->_pJavaVM;
- any <<= nP;
+ catch (css::uno::Exception &)
+ {
+ OSL_ENSURE(false, "com.sun.star.uno.Exception caught");
+ }
+ if (m_xJavaConfiguration.is())
+ // We should never get here, but just in case...
+ try
+ {
+ m_xJavaConfiguration->removeContainerListener(this);
+ }
+ catch (css::uno::Exception &)
+ {
+ OSL_ENSURE(false, "com.sun.star.uno.Exception caught");
}
- }
-
- return any;
}
-// XJavaVM
-sal_Bool JavaVirtualMachine_Impl::isVMStarted(void) throw(RuntimeException) {
- return _pVMContext != NULL;
+void SAL_CALL JavaVirtualMachine::disposing()
+{
+ css::uno::Reference< css::container::XContainer > xContainer1;
+ css::uno::Reference< css::container::XContainer > xContainer2;
+ {
+ osl::MutexGuard aGuard(*this);
+ m_bDisposed = true;
+ xContainer1 = m_xInetConfiguration;
+ m_xInetConfiguration.clear();
+ xContainer2 = m_xJavaConfiguration;
+ m_xJavaConfiguration.clear();
+ }
+ if (xContainer1.is())
+ xContainer1->removeContainerListener(this);
+ if (xContainer2.is())
+ xContainer2->removeContainerListener(this);
}
-// XJavaVM
-sal_Bool JavaVirtualMachine_Impl::isVMEnabled(void) throw(RuntimeException) {
- JVM jvm;
-
- initVMConfiguration(&jvm, _xSMgr, _xCtx);
+JavaVM * JavaVirtualMachine::createJavaVM(stoc_javavm::JVM const & jvm,
+ JNIEnv ** pMainThreadEnv)
+{
+ // On linux we load jvm with RTLD_GLOBAL. This is necessary for debugging, because
+ // libjdwp.so need a symbol (fork1) from libjvm which it only gets if the jvm is loaded
+ // witd RTLD_GLOBAL. On Solaris libjdwp.so is correctly linked with libjvm.so
+#ifdef LINUX
+ if(!m_aJavaLib.load(jvm.getRuntimeLib(), SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_NOW))
+#else
+ if(!m_aJavaLib.load(jvm.getRuntimeLib()))
+#endif
+ {
+ //Java installation was deleted or moved
+ rtl::OUString libURL;
+ if( osl::File::getFileURLFromSystemPath( jvm.getJavaHome(), libURL) != osl::File::E_None)
+ libURL= rtl::OUString();
+ css::java::MissingJavaRuntimeException exc(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaVirtualMachine::createJavaVM, Java runtime library cannot be found")),
+ 0, libURL);
+ css::lang::WrappedTargetRuntimeException wt;
+ wt.TargetException<<= exc;
+ throw wt;
+ }
- return jvm.isEnabled();
-}
+#ifdef UNX
+ rtl::OUString javaHome(RTL_CONSTASCII_USTRINGPARAM("JAVA_HOME="));
+ javaHome += jvm.getJavaHome();
+ const rtl::OUString & vmType = jvm.getVMType();
-// XJavaThreadRegister_11
-sal_Bool JavaVirtualMachine_Impl::isThreadAttached(void) throw (RuntimeException) {
- if(!_pVMContext)
- throw RuntimeException(OUSTR("JavaVirtualMachine_Impl::isThreadAttached - not vm context"), Reference<XInterface>());
+ if(!vmType.equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JRE"))))
+ {
+ javaHome += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/jre"));
+ }
- return _pVMContext->isThreadAttached();
-}
+ rtl::OString osJavaHome = rtl::OUStringToOString(javaHome, osl_getThreadTextEncoding()); // TODO encoding???
+ putenv(strdup(osJavaHome.getStr()));
+#endif
-// XJavaThreadRegister_11
-void JavaVirtualMachine_Impl::registerThread(void) throw (RuntimeException) {
- if(!_pVMContext)
- throw RuntimeException(OUSTR("JavaVirtualMachine_Impl::registerThread - not vm context"), Reference<XInterface>());
+ JNI_CreateVM_Type * pCreateJavaVM = (JNI_CreateVM_Type *)m_aJavaLib.getSymbol(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI_CreateJavaVM")));
+ if (!pCreateJavaVM)
+ {
+ // The java installation is somehow corrupted
+ css::java::JavaVMCreationFailureException exc(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaVirtualMachine::createJavaVM, could not find symbol " \
+ "JNI_GetDefaultJavaVMInitArgs or JNI_CreateJavaVM")),
+ 0, 1);
- _pVMContext->registerThread();
-}
+ css::lang::WrappedTargetRuntimeException wt;
+ wt.TargetException<<= exc;
+ throw wt;
+ }
-// XJavaThreadRegister_11
-void JavaVirtualMachine_Impl::revokeThread(void) throw (RuntimeException) {
- if(!_pVMContext)
- throw RuntimeException(OUSTR("JavaVirtualMachine_Impl::revokeThread - not vm context"), Reference<XInterface>());
+ // The office sets a signal handler at startup. That causes a crash
+ // with java 1.3 under Solaris. To make it work, we set back the
+ // handler
+#ifdef UNX
+ struct sigaction act;
+ act.sa_handler=SIG_DFL;
+ act.sa_flags= 0;
+ sigaction( SIGSEGV, &act, NULL);
+ sigaction( SIGPIPE, &act, NULL);
+ sigaction( SIGBUS, &act, NULL);
+ sigaction( SIGILL, &act, NULL);
+ sigaction( SIGFPE, &act, NULL);
+#endif
- _pVMContext->revokeThread();
-}
+ sal_uInt16 cprops= jvm.getProperties().size();
+
+ JavaVMInitArgs vm_args;
+
+ // we have "addOpt" additional properties to those kept in the JVM struct
+ sal_Int32 addOpt=2;
+ JavaVMOption * options= new JavaVMOption[cprops + addOpt];
+ rtl::OString sClassPath= rtl::OString("-Djava.class.path=")
+ + rtl::OUStringToOString(jvm.getClassPath(),
+ osl_getThreadTextEncoding());
+ // TODO encoding???
+ options[0].optionString= (char*)sClassPath.getStr();
+ options[0].extraInfo= NULL;
+
+ // We set an abort handler which is called when the VM calls _exit during
+ // JNI_CreateJavaVM. This happens when the LD_LIBRARY_PATH does not contain
+ // all some directories of the Java installation. This is necessary for
+ // linux j2re1.3, 1.4 and Solaris j2re1.3. With a j2re1.4 on Solaris the
+ // LD_LIBRARY_PATH need not to be set anymore.
+ options[1].optionString= "abort";
+ options[1].extraInfo= (void* )abort_handler;
+
+ rtl::OString * arProps= new rtl::OString[cprops];
+
+ /*If there are entries in the Java section of the java.ini/javarc which are meant
+ to be java system properties then they get a "-D" at the beginning of the string.
+ Entries which start with "-" are regarded as java options as they are passed at
+ the command-line. If those entries appear under the Java section then there are
+ used as they are. For example, the entry "-ea" would be uses as
+ JavaVMOption.optionString.
+ */
+ rtl::OString sJavaOption("-");
+ for( sal_uInt16 x= 0; x< cprops; x++)
+ {
+ rtl::OString sOption(rtl::OUStringToOString(jvm.getProperties()[x],
+ RTL_TEXTENCODING_ASCII_US));
+ // TODO encoding???
+ if (!sOption.matchIgnoreAsciiCase(sJavaOption, 0))
+ arProps[x]= rtl::OString("-D") + sOption;
+ else
+ arProps[x]= sOption;
+ options[x+addOpt].optionString= (char*)arProps[x].getStr();
+ options[x+addOpt].extraInfo= NULL;
+ }
+ vm_args.version= JNI_VERSION_1_2;
+ vm_args.options= options;
+ vm_args.nOptions= cprops + addOpt;
+ vm_args.ignoreUnrecognized= JNI_TRUE;
+
+ /* We set a global flag which is used by the abort handler in order to
+ determine whether it is should use longjmp to get back into this function.
+ That is, the abort handler determines if it is on the same stack as this function
+ and then jumps back into this function.
+ */
+ g_bInGetJavaVM = 1;
+ jint err;
+ JavaVM * pJavaVM;
+ memset( jmp_jvm_abort, 0, sizeof(jmp_jvm_abort));
+ int jmpval= setjmp( jmp_jvm_abort );
+ /* If jmpval is not "0" then this point was reached by a longjmp in the
+ abort_handler, which was called indirectly by JNI_CreateVM.
+ */
+ if( jmpval == 0)
+ {
+ //returns negative number on failure
+ err= pCreateJavaVM(&pJavaVM, pMainThreadEnv, &vm_args);
+ g_bInGetJavaVM = 0;
+ }
+ else
+ // set err to a positive number, so as or recognize that an abort (longjmp)
+ //occurred
+ err= 1;
+ delete [] options;
+ delete [] arProps;
-// JavaVirtualMachine_Impl_CreateInstance()
-static Reference<XInterface> SAL_CALL JavaVirtualMachine_Impl_createInstance(const Reference<XComponentContext> & xCtx)
- throw (RuntimeException)
-{
- Reference< XInterface > xRet;
+ if(err != 0)
{
- MutexGuard guard( javavm_getMutex() );
- // The javavm is never destroyed !
- static Reference< XInterface > *pStaticRef = 0;
- if( pStaticRef )
+ rtl::OUString message;
+ if( err < 0)
{
- xRet = *pStaticRef;
+ message= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::createJavaVM - can not create VM, cause of err:"));
+ message += rtl::OUString::valueOf((sal_Int32)err);
}
- else
- {
- xRet = *new JavaVirtualMachine_Impl( xCtx);
- pStaticRef = new Reference< XInterface> ( xRet );
- }
+ else if( err > 0)
+ message= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "JavaVirtualMachine::createJavaVM - can not create VM, abort handler was called"));
+ css::java::JavaVMCreationFailureException exc(message,
+ 0, err);
+ css::lang::WrappedTargetRuntimeException wt;
+ wt.TargetException<<= exc;
+ throw wt;
}
-
- return xRet;
+ return pJavaVM;
}
/*We listen to changes in the configuration. For example, the user changes the proxy
@@ -1936,170 +1809,208 @@ static Reference<XInterface> SAL_CALL JavaVirtualMachine_Impl_createInstance(con
through JNI.
To receive notifications this class implements XContainerListener.
*/
-void JavaVirtualMachine_Impl::registerConfigChangesListener()
+void JavaVirtualMachine::registerConfigChangesListener()
{
try
{
- Reference< XMultiServiceFactory > xConfigProvider(
- _xSMgr->createInstanceWithContext( OUSTR(
- "com.sun.star.configuration.ConfigurationProvider"), _xCtx), UNO_QUERY);
+ css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
+ m_xContext->getServiceManager()->createInstanceWithContext( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationProvider")), m_xContext), css::uno::UNO_QUERY);
if (xConfigProvider.is())
{
// We register this instance as listener to changes in org.openoffice.Inet/Settings
// arguments for ConfigurationAccess
- Sequence< Any > aArguments(2);
- aArguments[0] <<= PropertyValue(
- OUSTR("nodepath"),
+ css::uno::Sequence< css::uno::Any > aArguments(2);
+ aArguments[0] <<= css::beans::PropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
0,
- makeAny(OUSTR("org.openoffice.Inet/Settings")),
- PropertyState_DIRECT_VALUE);
+ css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Inet/Settings"))),
+ css::beans::PropertyState_DIRECT_VALUE);
// depth: -1 means unlimited
- aArguments[1] <<= PropertyValue(
- OUSTR("depth"),
+ aArguments[1] <<= css::beans::PropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")),
0,
- makeAny( (sal_Int32)-1),
- PropertyState_DIRECT_VALUE);
+ css::uno::makeAny( (sal_Int32)-1),
+ css::beans::PropertyState_DIRECT_VALUE);
- _xConfigurationAccess= xConfigProvider->createInstanceWithArguments(
- OUSTR("com.sun.star.configuration.ConfigurationAccess"),
- aArguments);
- Reference< XContainer > xContainer(_xConfigurationAccess, UNO_QUERY);
+ m_xInetConfiguration
+ = css::uno::Reference< css::container::XContainer >(
+ xConfigProvider->createInstanceWithArguments(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess")),
+ aArguments),
+ css::uno::UNO_QUERY);
- if (xContainer.is())
- xContainer->addContainerListener( static_cast< XContainerListener* >(this));
+ if (m_xInetConfiguration.is())
+ m_xInetConfiguration->addContainerListener(this);
// now register as listener to changes in org.openoffice.Java/VirtualMachine
- Sequence< Any > aArguments2(2);
- aArguments2[0] <<= PropertyValue(
- OUSTR("nodepath"),
+ css::uno::Sequence< css::uno::Any > aArguments2(2);
+ aArguments2[0] <<= css::beans::PropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
0,
- makeAny(OUSTR("org.openoffice.Office.Java/VirtualMachine")),
- PropertyState_DIRECT_VALUE);
+ css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Java/VirtualMachine"))),
+ css::beans::PropertyState_DIRECT_VALUE);
// depth: -1 means unlimited
- aArguments2[1] <<= PropertyValue(
- OUSTR("depth"),
+ aArguments2[1] <<= css::beans::PropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")),
0,
- makeAny( (sal_Int32)-1),
- PropertyState_DIRECT_VALUE);
-
- _xConfigurationAccess2= xConfigProvider->createInstanceWithArguments(
- OUSTR("com.sun.star.configuration.ConfigurationAccess"),
- aArguments2);
-
- Reference< XContainer > xContainer2(_xConfigurationAccess2, UNO_QUERY);
-
- if (xContainer2.is())
- xContainer2->addContainerListener( static_cast< XContainerListener* >(this));
-
- // The JavaVM service is registered as listener with the configuration service. That
- // service therefore keeps a reference of JavaVM. We need to unregister JavaVM with the
- // configuration service, otherwise the ref count of JavaVM won't drop to zero.
- Reference< XComponent > xComp( _xSMgr, UNO_QUERY);
- if (xComp.is())
- {
- xComp->addEventListener( static_cast< XEventListener* >(this));
- }
+ css::uno::makeAny( (sal_Int32)-1),
+ css::beans::PropertyState_DIRECT_VALUE);
+
+ m_xJavaConfiguration
+ = css::uno::Reference< css::container::XContainer >(
+ xConfigProvider->createInstanceWithArguments(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess")),
+ aArguments2),
+ css::uno::UNO_QUERY);
+
+ if (m_xJavaConfiguration.is())
+ m_xJavaConfiguration->addContainerListener(this);
}
- }catch( Exception & e)
+ }catch( css::uno::Exception & e)
{
#ifdef DEBUG
- OString message = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
+ rtl::OString message = rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("javavm.cxx: could not set up listener for Configuration because of >%s<", message.getStr());
#endif
}
}
-JavaVirtualMachine_Impl::SelectedAction JavaVirtualMachine_Impl::doClientInteraction( Any& except)
+// param true: all Inet setting are set as Java Properties on a live VM.
+// false: the Java net properties are set to empty value.
+void JavaVirtualMachine::setINetSettingsInVM(bool set_reset)
{
- Reference<XCurrentContext> context= getCurrentContext();
- if( context.is())
+ osl::MutexGuard aGuard(*this);
+ try
{
- Any val= context->getValueByName(OUSTR(INTERACTION_HANDLER_NAME));
-
- Reference<XInteractionHandler> handler;
- val >>= handler;
- if( handler.is())
+ if (m_xVirtualMachine.is())
{
- Reference<XInterface> xIntJVM( static_cast<XWeak*>(this), UNO_QUERY);
- Reference<XInteractionRequest> request(
- new InteractionRequest(xIntJVM,
- static_cast<JavaVirtualMachine_Impl*>(this),except));
-
- m_bInteractionAbort= sal_False;
- m_bInteractionRetry= sal_False;
- handler->handle(request);
-
- if( m_bInteractionAbort)
- return action_abort;
- else if( m_bInteractionRetry)
- return action_retry;
- }
- }
- return action_abort;
-}
-void JavaVirtualMachine_Impl::selectAbort( )
-{
- m_bInteractionAbort= sal_True;
-}
+ jvmaccess::VirtualMachine::AttachGuard aAttachGuard(
+ m_xVirtualMachine);
+ JNIEnv * pJNIEnv = aAttachGuard.getEnvironment();
+
+ // The Java Properties
+ rtl::OUString sFtpProxyHost(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyHost") );
+ rtl::OUString sFtpProxyPort(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyPort") );
+ rtl::OUString sFtpNonProxyHosts (RTL_CONSTASCII_USTRINGPARAM("ftp.nonProxyHosts"));
+ rtl::OUString sHttpProxyHost(RTL_CONSTASCII_USTRINGPARAM("http.proxyHost") );
+ rtl::OUString sHttpProxyPort(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort") );
+ rtl::OUString sHttpNonProxyHosts(RTL_CONSTASCII_USTRINGPARAM("http.nonProxyHosts"));
+
+ // creat Java Properties as JNI strings
+ jstring jsFtpProxyHost= pJNIEnv->NewString( sFtpProxyHost.getStr(), sFtpProxyHost.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsFtpProxyPort= pJNIEnv->NewString( sFtpProxyPort.getStr(), sFtpProxyPort.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsFtpNonProxyHosts= pJNIEnv->NewString( sFtpNonProxyHosts.getStr(), sFtpNonProxyHosts.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsHttpProxyHost= pJNIEnv->NewString( sHttpProxyHost.getStr(), sHttpProxyHost.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsHttpProxyPort= pJNIEnv->NewString( sHttpProxyPort.getStr(), sHttpProxyPort.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsHttpNonProxyHosts= pJNIEnv->NewString( sHttpNonProxyHosts.getStr(), sHttpNonProxyHosts.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+
+ // prepare java.lang.System.setProperty
+ jclass jcSystem= pJNIEnv->FindClass("java/lang/System");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/lang/System")), 0);
+ jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.setProperty")), 0);
-void JavaVirtualMachine_Impl::selectRetry( )
-{
- m_bInteractionRetry= sal_True;
-}
+ // call java.lang.System.getProperties
+ jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.getProperties")), 0);
+ jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.getProperties")), 0);
+ // prepare java.util.Properties.remove
+ jclass jcProperties= pJNIEnv->FindClass("java/util/Properties");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/util/Properties")), 0);
+ if (set_reset)
+ {
+ // Set all network properties with the VM
+ JVM jvm;
+ getINetPropsFromConfig( &jvm, m_xContext->getServiceManager(), m_xContext);
+ const ::std::vector< rtl::OUString> & Props = jvm.getProperties();
+ typedef ::std::vector< rtl::OUString >::const_iterator C_IT;
+ for( C_IT i= Props.begin(); i != Props.end(); i++)
+ {
+ rtl::OUString prop= *i;
+ sal_Int32 index= prop.indexOf( (sal_Unicode)'=');
+ rtl::OUString propName= prop.copy( 0, index);
+ rtl::OUString propValue= prop.copy( index + 1);
-void JavaVirtualMachine_Impl::disposeJavaVM() throw() {
- if (_pVMContext){
-// pJavaVM->DestroyJavaVM();
-// _pJavaVM = NULL;
+ if( propName.equals( sFtpProxyHost))
+ {
+ jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpProxyHost, jsVal);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+ }
+ else if( propName.equals( sFtpProxyPort))
+ {
+ jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpProxyPort, jsVal);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+ }
+ else if( propName.equals( sFtpNonProxyHosts))
+ {
+ jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpNonProxyHosts, jsVal);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+ }
+ else if( propName.equals( sHttpProxyHost))
+ {
+ jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpProxyHost, jsVal);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+ }
+ else if( propName.equals( sHttpProxyPort))
+ {
+ jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpProxyPort, jsVal);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+ }
+ else if( propName.equals( sHttpNonProxyHosts))
+ {
+ jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength());
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")), 0);
+ jstring jsPrevValue= (jstring)pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpNonProxyHosts, jsVal);
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")), 0);
+ }
+ }
+ }
+ else
+ {
+ // call java.util.Properties.remove
+ jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;");
+ if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID java.util.Property.remove")), 0);
+ jobject joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpProxyHost);
+ joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpProxyPort);
+ joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpNonProxyHosts);
+ joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpProxyHost);
+ joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpProxyPort);
+ joPrev= pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpNonProxyHosts);
+ }
+ }
}
-}
-}
-
-using namespace stoc_javavm;
-
-static struct ImplementationEntry g_entries[] =
-{
+ catch (css::uno::RuntimeException &)
{
- JavaVirtualMachine_Impl_createInstance, javavm_getImplementationName,
- javavm_getSupportedServiceNames, createSingleComponentFactory,
- 0 , 0
- },
- { 0, 0, 0, 0, 0, 0 }
-};
-
-extern "C"
-{
-// NOTE: component_canUnload is not exported, as the library cannot be unloaded.
-
-//==================================================================================================
-void SAL_CALL component_getImplementationEnvironment(
- const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
-{
- *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
-}
-//==================================================================================================
-sal_Bool SAL_CALL component_writeInfo(
- void * pServiceManager, void * pRegistryKey )
-{
- return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries );
-}
-//==================================================================================================
-void * SAL_CALL component_getFactory(
- const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
-{
- return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
-}
-}
-
-void abort_handler()
-{
- // If we are within JNI_CreateJavaVM then we jump back into getJavaVM
- if( g_bInGetJavaVM )
+ OSL_ENSURE(false, "RuntimeException");
+ }
+ catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &)
{
- fprintf( stderr, "JavaVM: JNI_CreateJavaVM called _exit, caught by abort_handler in javavm.cxx\n");
- longjmp( jmp_jvm_abort, 0);
+ OSL_ENSURE(false,
+ "jvmaccess::VirtualMachine::AttachGuard::CreationException");
}
}
diff --git a/stoc/source/javavm/javavm.hxx b/stoc/source/javavm/javavm.hxx
index ba02cd363f6c..24732f20d7fd 100644
--- a/stoc/source/javavm/javavm.hxx
+++ b/stoc/source/javavm/javavm.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javavm.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jl $ $Date: 2002-09-25 15:37:50 $
+ * last change: $Author: sb $ $Date: 2002-12-06 10:48:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,126 +58,146 @@
*
*
************************************************************************/
-#ifndef _JVM_JAVAVM_HXX_
-#define _JVM_JAVAVM_HXX_
-#ifndef _CPPUHELPER_IMPLBASE4_HXX_
-#include <cppuhelper/implbase4.hxx>
-#endif
-#ifndef _COM_SUN_STAR_JAVA_XJAVAVM_HPP_
-#include <com/sun/star/java/XJavaVM.hpp>
-#endif
-#ifndef _COM_SUN_STAR_JAVA_XJAVATHREADREGISTER_11_HPP_
-#include <com/sun/star/java/XJavaThreadRegister_11.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
-#include <com/sun/star/uno/XComponentContext.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_
-#include <com/sun/star/container/XContainerListener.hpp>
-#endif
+
+#if !defined INCLUDED_STOC_JAVAVM_JAVAVM_HXX
+#define INCLUDED_STOC_JAVAVM_JAVAVM_HXX
+
+#include "jvmargs.hxx"
+
+#include "com/sun/star/container/XContainerListener.hpp"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/java/XJavaThreadRegister_11.hpp"
+#include "com/sun/star/java/XJavaVM.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "cppuhelper/compbase5.hxx"
+#include "osl/module.hxx"
+#include "osl/thread.hxx"
+#include "rtl/ref.hxx"
+
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
-#ifndef _OSL_MODULE_HXX_
-#include <osl/module.hxx>
-#endif
-#ifndef _UNO_ENVIRONMENT_HXX_
-#include <uno/environment.h>
-#endif
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif
-#ifndef __VMHOLDER
-#include <bridges/java/jvmcontext.hxx>
-#endif
-//#include <jni.h>
-#include "jvmargs.hxx"
-using namespace ::cppu;
-using namespace ::osl;
-using namespace ::rtl;
-using namespace ::com::sun::star::java;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::container;
-
-namespace stoc_javavm
+namespace com { namespace sun { namespace star {
+ namespace container { class XContainer; }
+ namespace uno { class XComponentContext; }
+} } }
+namespace jvmaccess { class VirtualMachine; }
+
+namespace stoc_javavm {
+
+// The MS compiler needs a typedef here, so the JavaVirtualMachine ctor can call
+// its base class ctor:
+typedef
+cppu::WeakComponentImplHelper5< com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo,
+ com::sun::star::java::XJavaVM,
+ com::sun::star::java::XJavaThreadRegister_11,
+ com::sun::star::container::XContainerListener >
+JavaVirtualMachine_Impl;
+
+class JavaVirtualMachine: private osl::Mutex, public JavaVirtualMachine_Impl
{
+public:
+ explicit JavaVirtualMachine(
+ com::sun::star::uno::Reference<
+ com::sun::star::uno::XComponentContext > const & rContext);
-Mutex* javavm_getMutex();
-class OCreatorThread;
-
-class JavaVirtualMachine_Impl : public WeakImplHelper4< XJavaVM, XJavaThreadRegister_11,
- XServiceInfo, XContainerListener >
-{
- OCreatorThread * pCreatorThread;
- uno_Environment * _pJava_environment;
- JavaVMContext * _pVMContext;
-
- Reference<XComponentContext> _xCtx;
- Reference<XMultiComponentFactory > _xSMgr;
+ // XInitialization
+ virtual void SAL_CALL
+ initialize(com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
+ rArguments)
+ throw (com::sun::star::uno::Exception);
- // For Inet settings
- Reference<XInterface> _xConfigurationAccess;
- // for Java settings
- Reference<XInterface> _xConfigurationAccess2;
- Module _javaLib;
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (com::sun::star::uno::RuntimeException);
- void registerConfigChangesListener();
+ virtual sal_Bool SAL_CALL
+ supportsService(rtl::OUString const & rServiceName)
+ throw (com::sun::star::uno::RuntimeException);
- sal_Bool m_bInteractionAbort;
- sal_Bool m_bInteractionRetry;
+ virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
+ getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
- // 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();
+ // XJavaVM
+ virtual com::sun::star::uno::Any SAL_CALL
+ getJavaVM(com::sun::star::uno::Sequence< sal_Int8 > const & rProcessId)
+ throw (com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isVMStarted()
+ throw (com::sun::star::uno::RuntimeException);
- // XJavaVM
- virtual Any SAL_CALL getJavaVM(const Sequence<sal_Int8> & processID) throw(RuntimeException);
- virtual sal_Bool SAL_CALL isVMStarted(void) throw( RuntimeException);
- virtual sal_Bool SAL_CALL isVMEnabled(void) throw( RuntimeException);
+ virtual sal_Bool SAL_CALL isVMEnabled()
+ throw (com::sun::star::uno::RuntimeException);
// XJavaThreadRegister_11
- virtual sal_Bool SAL_CALL isThreadAttached(void) throw(RuntimeException);
- virtual void SAL_CALL registerThread(void) throw(RuntimeException);
- virtual void SAL_CALL revokeThread(void) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL isThreadAttached()
+ throw (com::sun::star::uno::RuntimeException);
- // XServiceInfo
- virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
- virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException);
- virtual Sequence<OUString> SAL_CALL getSupportedServiceNames(void) throw(RuntimeException);
+ virtual void SAL_CALL registerThread()
+ throw (com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL revokeThread()
+ throw (com::sun::star::uno::RuntimeException);
// XContainerListener
- virtual void SAL_CALL elementInserted( const ContainerEvent& Event ) throw (RuntimeException);
- virtual void SAL_CALL elementRemoved( const ContainerEvent& Event ) throw (RuntimeException);
- virtual void SAL_CALL elementReplaced( const ContainerEvent& Event ) throw (RuntimeException);
+ virtual void SAL_CALL
+ disposing(com::sun::star::lang::EventObject const & rSource)
+ throw (com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ elementInserted(com::sun::star::container::ContainerEvent const & rEvent)
+ throw (com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ elementRemoved(com::sun::star::container::ContainerEvent const & rEvent)
+ throw (com::sun::star::uno::RuntimeException);
- // XEventListener
- virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+ virtual void SAL_CALL
+ elementReplaced(com::sun::star::container::ContainerEvent const & rEvent)
+ throw (com::sun::star::uno::RuntimeException);
- JavaVM * createJavaVM(const JVM & jvm) throw(RuntimeException);
- void disposeJavaVM() throw();
+private:
+ JavaVirtualMachine(JavaVirtualMachine &); // not implemented
+ void operator =(JavaVirtualMachine); // not implemented
+ virtual ~JavaVirtualMachine();
- //callback for the InteractionAbort object
- void selectAbort();
- //callback for the InteractionRetry object
- void selectRetry();
- enum SelectedAction {action_abort,action_retry};
-protected:
- void setINetSettingsInVM( sal_Bool set_reset);
+ virtual void SAL_CALL disposing();
- SelectedAction doClientInteraction(Any& exception);
+ JavaVM * createJavaVM(JVM const & jvm, JNIEnv ** pMainThreadEnv);
+ // throws com::sun::star::uno::RuntimeException
+ void registerConfigChangesListener();
+
+ void setINetSettingsInVM(bool set_reset);
+
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ // the following are controlled by the 'this' mutex:
+ bool m_bDisposed;
+ rtl::Reference< jvmaccess::VirtualMachine > m_xVirtualMachine;
+ JavaVM * m_pJavaVm;
+ // stored as an instance member for backwards compatibility in getJavaVM
+ bool m_bDontCreateJvm;
+ // If the first creation of Java failed and this flag is set then the
+ // next call to getJavaVM throws a RuntimException. This is useful when
+ // the second attempt to create Java might cause a crash.
+ com::sun::star::uno::Reference< com::sun::star::container::XContainer >
+ m_xInetConfiguration;
+ com::sun::star::uno::Reference< com::sun::star::container::XContainer >
+ m_xJavaConfiguration; // for Java settings
+ osl::Module m_aJavaLib;
+
+ osl::ThreadData m_aAttachGuards;
};
-} // end namespace
-#endif
+}
+
+#endif // INCLUDED_STOC_JAVAVM_JAVAVM_HXX
diff --git a/stoc/source/javavm/jen.xml b/stoc/source/javavm/jen.xml
index 45c241cff29b..4e130a359aba 100644
--- a/stoc/source/javavm/jen.xml
+++ b/stoc/source/javavm/jen.xml
@@ -28,6 +28,9 @@ the existing vm given back.
<type> com.sun.star.lang.XMultiServiceFactory </type>
<type> com.sun.star.lang.XComponent </type>
<type> com.sun.star.lang.WrappedTargetRuntimeException </type>
+ <type> com.sun.star.lang.DisposedException </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.lang.XInitialization </type>
<type> com.sun.star.registry.XSimpleRegistry </type>
<type> com.sun.star.lang.XSingleComponentFactory </type>
<type> com.sun.star.uno.XComponentContext </type>
@@ -52,8 +55,12 @@ the existing vm given back.
<project-build-dependency> cppu </project-build-dependency>
<project-build-dependency> tools </project-build-dependency>
<project-build-dependency> sal </project-build-dependency>
+ <project-build-dependency> jvmaccess </project-build-dependency>
+ <project-build-dependency> salhelper </project-build-dependency>
<runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency>
<runtime-module-dependency> cppu2 </runtime-module-dependency>
<runtime-module-dependency> tl(COM) </runtime-module-dependency>
<runtime-module-dependency> sal2 </runtime-module-dependency>
+ <runtime-module-dependency> jvmaccess3$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> salhelper3$(COM) </runtime-module-dependency>
</module-description>
diff --git a/stoc/source/javavm/jvmargs.cxx b/stoc/source/javavm/jvmargs.cxx
index 1e1f194ed22d..9f227b987ad1 100644
--- a/stoc/source/javavm/jvmargs.cxx
+++ b/stoc/source/javavm/jvmargs.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jvmargs.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: jl $ $Date: 2002-12-03 11:39:07 $
+ * last change: $Author: sb $ $Date: 2002-12-06 10:48:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,9 +67,6 @@
#endif
-#ifndef _OSL_FILE_H_
-#include <osl/file.h>
-#endif
#include <string.h>
@@ -77,6 +74,7 @@
#include <osl/diagnose.h>
#include <osl/thread.h>
+#include "osl/file.h"
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
@@ -310,73 +308,6 @@ OUString JVM::getUserClasspath()
_abort = abort;
}
- void JVM::setArgs(JDK1_1InitArgs * pargs) const throw() {
- OUString classpath = _systemClasspath;
- classpath += OUString(RTL_CONSTASCII_USTRINGPARAM(CLASSPATH_DELIMETER));
- classpath += _userClasspath;
-
-#ifdef DEBUG
- fprintf( stderr, "JavaVM: using classpath %s\n" , OUStringToOString(classpath, osl_getThreadTextEncoding()).getStr());
-#endif
- pargs->classpath = strdup(OUStringToOString(classpath, osl_getThreadTextEncoding()));
-
- if(_is_debugPort) {
- pargs->debugging = JNI_TRUE;
- pargs->debugPort = _debugPort;
- }
-
- if(_is_disableAsyncGC)
- pargs->disableAsyncGC = _disableAsyncGC;
-
- if(_is_enableClassGC)
- pargs->enableClassGC = _enableClassGC;
-
- if(_is_enableVerboseGC)
- pargs->enableVerboseGC = _enableVerboseGC;
-
- if(_is_checkSource)
- pargs->checkSource = _checkSource;
-
- if(_is_nativeStackSize)
- pargs->nativeStackSize = _nativeStackSize;
-
- if(_is_javaStackSize)
- pargs->javaStackSize = _javaStackSize;
-
- if(_is_minHeapSize) {
- // Workaround ! Der neue Wert wird nur uebernommen, wenn dieser ueber der
- // DefaultSize ( 1 MB ) liegt. Ein zu kleiner initialer HeapSize fuehrt unter Solaris Sparc zum Deadlock.
- if(_minHeapSize > (sal_uInt32) pargs->minHeapSize)
- pargs->minHeapSize = _minHeapSize;
- }
-
- if(_is_maxHeapSize)
- pargs->maxHeapSize = _maxHeapSize;
-
- if(_is_verifyMode)
- pargs->verifyMode = _verifyMode;
-
- if(_is_print)
- pargs->vfprintf = _print;
-
- if(_is_exit)
- pargs->exit = _exit;
-
- if(_is_abort)
- pargs->abort = _abort;
-
- size_t size = _props.size();
- pargs->properties = (char **)calloc(sizeof(const char *), size + 1);
-
- for(size_t i = 0; i < size; ++ i) {
- const OUString & str = _props[i];
-
- pargs->properties[i] = strdup(OUStringToOString(str, RTL_TEXTENCODING_ASCII_US));
- }
-
- pargs->properties[size] = NULL;
- }
-
void JVM::setRuntimeLib(const OUString & libName) throw() {
_runtimeLib = libName;
}
@@ -389,7 +320,20 @@ OUString JVM::getUserClasspath()
return _enabled;
}
- const ::std::vector< ::rtl::OUString > & JVM::getProperties() const
+ rtl::OUString JVM::getClassPath() const
+ {
+ rtl::OUStringBuffer aBuffer(_systemClasspath);
+ if (_userClasspath.getLength() > 0)
+ {
+ if (aBuffer.getLength() > 0)
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM(
+ CLASSPATH_DELIMETER));
+ aBuffer.append(_userClasspath);
+ }
+ return aBuffer.makeStringAndClear();
+ }
+
+ const ::std::vector< ::rtl::OUString > & JVM::getProperties() const
{
return _props;
}
diff --git a/stoc/source/javavm/jvmargs.hxx b/stoc/source/javavm/jvmargs.hxx
index fc14c2e0152d..d5f8c8238f04 100644
--- a/stoc/source/javavm/jvmargs.hxx
+++ b/stoc/source/javavm/jvmargs.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jvmargs.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jl $ $Date: 2002-08-08 10:39:54 $
+ * last change: $Author: sb $ $Date: 2002-12-06 10:48:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -165,12 +165,12 @@ namespace stoc_javavm {
void setAbort(JNIabort abort) throw();
void setRuntimeLib(const ::rtl::OUString & libName) throw();
- void setArgs(JDK1_1InitArgs * pargs) const throw();
-
const ::rtl::OUString & getRuntimeLib() const throw();
sal_Bool isEnabled() const throw();
const ::std::vector< ::rtl::OUString> & getProperties() const;
+ rtl::OUString getClassPath() const;
+
const ::rtl::OUString & getJavaHome() const throw();
const ::rtl::OUString & getVMType() const throw();
};
diff --git a/stoc/source/javavm/makefile.mk b/stoc/source/javavm/makefile.mk
index 7b289a076134..aff8d7f9fb2f 100644
--- a/stoc/source/javavm/makefile.mk
+++ b/stoc/source/javavm/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.14 $
+# $Revision: 1.15 $
#
-# last change: $Author: jbu $ $Date: 2002-08-13 16:12:55 $
+# last change: $Author: sb $ $Date: 2002-12-06 10:48:59 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -103,7 +103,9 @@ SHL1STDLIBS= \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(UNOLIB) \
- $(SALLIB)
+ $(SALLIB) \
+ $(JVMACCESSLIB) \
+ $(SALHELPERLIB)
.IF "$(GUI)"=="WNT"
SHL1STDLIBS += advapi32.lib