From 951a9342631129832e647bd8a303a959308bad65 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 22 Mar 2021 13:45:32 +0200 Subject: use single-use attribute for JavaVirtualMachine instead of rtl::Instance, which means it will get cleaned up when UNO shuts down Change-Id: Iecf943584d71aac0ed147ff4b6fce49192ef2787 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112929 Tested-by: Jenkins Reviewed-by: Noel Grandin --- stoc/source/javavm/javavm.component | 3 ++- stoc/source/javavm/javavm.cxx | 20 ++------------------ 2 files changed, 4 insertions(+), 19 deletions(-) (limited to 'stoc') diff --git a/stoc/source/javavm/javavm.component b/stoc/source/javavm/javavm.component index 79d993ddd62c..71379052b89e 100644 --- a/stoc/source/javavm/javavm.component +++ b/stoc/source/javavm/javavm.component @@ -20,7 +20,8 @@ + constructor="stoc_JavaVM_get_implementation" + single-instance="true"> diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx index 19bce9f5f2cd..35fc0cb9c7d9 100644 --- a/stoc/source/javavm/javavm.cxx +++ b/stoc/source/javavm/javavm.cxx @@ -1471,29 +1471,13 @@ void JavaVirtualMachine::handleJniException(JNIEnv * environment) { } -static osl::Mutex m_aMutex; -static rtl::Reference< JavaVirtualMachine > m_xSingleton; - - -void JavaVirtualMachine::dispose() { - JavaVirtualMachine_Impl::dispose(); - osl::MutexGuard aGuard(m_aMutex); - m_xSingleton.clear(); -} +void JavaVirtualMachine::dispose() {} extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* stoc_JavaVM_get_implementation( css::uno::XComponentContext* context , css::uno::Sequence const&) { - // 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). - osl::MutexGuard aGuard(m_aMutex); - if (!m_xSingleton.is()) - m_xSingleton.set(new JavaVirtualMachine(context)); - m_xSingleton->acquire(); - return static_cast(m_xSingleton.get()); + return static_cast(new JavaVirtualMachine(context)); } -- cgit