1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_JVMACCESS_UNOVIRTUALMACHINE_HXX
21 #define INCLUDED_JVMACCESS_UNOVIRTUALMACHINE_HXX
23 #include <jvmaccess/jvmaccessdllapi.h>
24 #include <sal/config.h>
25 #include <salhelper/simplereferenceobject.hxx>
26 #include <rtl/ref.hxx>
32 /** An encapsulating wrapper around a Java virtual machine and an appropriate
35 class JVMACCESS_DLLPUBLIC UnoVirtualMachine
: public salhelper::SimpleReferenceObject
{
37 /** An exception indicating failure to create a UnoVirtualMachine.
39 class JVMACCESS_DLLPUBLIC CreationException final
44 CreationException(CreationException
const &);
48 CreationException
& operator =(CreationException
const &);
51 /** Create a wrapper around a Java virtual machine and an appropriate UNO
55 A Java virtual machine wrapper. Must not be null.
58 A local or global JNI reference, relative to the given virtualMachine,
59 to an appropriate UNO class loader instance. Must not be null. This
60 parameter should be of type jobject, not void *, but the exact
61 definition of jobject is different for different JDK versions, so that
62 the mangled C++ name of the constructor would depend on the JDK version
65 @exception CreationException
66 Thrown in case creation fails (due to a JNI problem).
69 rtl::Reference
< jvmaccess::VirtualMachine
> const & virtualMachine
,
72 /** Get the Java virtual machine wrapper.
75 The Java virtual machine wrapper. Will never be null.
77 const rtl::Reference
< jvmaccess::VirtualMachine
>& getVirtualMachine() const;
79 /** Get the UNO class loader.
82 A global JNI reference to the UNO class loader. (The JNI reference must
83 not be deleted by client code.) Will never be null. This should be of
84 type jobject, not void *, but the exact definition of jobject is
85 different for different JDK versions, so that the mangled C++ name of
86 the function would depend on the JDK version used at compile time.
88 void * getClassLoader() const { return m_classLoader
;}
91 UnoVirtualMachine(UnoVirtualMachine
const &) = delete;
92 UnoVirtualMachine
& operator =(UnoVirtualMachine
const &) = delete;
94 virtual ~UnoVirtualMachine() override
;
96 rtl::Reference
< jvmaccess::VirtualMachine
> m_virtualMachine
;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */