diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-03-22 13:45:32 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-23 07:39:40 +0100 |
commit | 951a9342631129832e647bd8a303a959308bad65 (patch) | |
tree | 1d046eea32882b50fc5cfd4cc36eb5307b97051d /stoc | |
parent | 76a30ac646faf1c638736c10e834bb7b0ed243ef (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/javavm/javavm.component | 3 | ||||
-rw-r--r-- | stoc/source/javavm/javavm.cxx | 20 |
2 files changed, 4 insertions, 19 deletions
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 @@ <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="com.sun.star.comp.stoc.JavaVirtualMachine" - constructor="stoc_JavaVM_get_implementation"> + constructor="stoc_JavaVM_get_implementation" + single-instance="true"> <service name="com.sun.star.java.JavaVirtualMachine"/> <singleton name="com.sun.star.java.theJavaVirtualMachine"/> </implementation> 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<css::uno::Any> 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<cppu::OWeakObject*>(m_xSingleton.get()); + return static_cast<cppu::OWeakObject*>(new JavaVirtualMachine(context)); } |