LibreOffice Module jvmaccess (master) 1
virtualmachine.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_JVMACCESS_VIRTUALMACHINE_HXX
21#define INCLUDED_JVMACCESS_VIRTUALMACHINE_HXX
22
24#include <rtl/ref.hxx>
26
27#if defined __clang__
28#pragma clang diagnostic push
29#pragma clang diagnostic ignored "-Wunknown-attributes"
30#endif
31#include <jni.h>
32#if defined __clang__
33#pragma clang diagnostic pop
34#endif
35
36namespace jvmaccess
37{
41{
42public:
54 {
55 public:
59 {
60 public:
62
64
65 CreationException& operator=(CreationException const&);
66 };
67
77
81
87 JNIEnv* getEnvironment() const { return m_pEnvironment; }
88
89 private:
90 AttachGuard(AttachGuard const&) = delete;
92
96 };
97
132 VirtualMachine(JavaVM* pVm, int nVersion, bool bDestroy, JNIEnv const* pMainThreadEnv);
133
134private:
137
138 virtual ~VirtualMachine() override;
139
140 JNIEnv* attachThread(bool* pAttached) const;
141
142 void detachThread() const;
143
144 JavaVM* m_pVm;
147
148 friend class AttachGuard; // to access attachThread, detachThread
149};
150}
151
152#endif // INCLUDED_JVMACCESS_VIRTUALMACHINE_HXX
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
An exception indicating failure to create an AttachGuard.
A helper to attach a thread to a Java virtual machine.
rtl::Reference< VirtualMachine > m_xMachine
JNIEnv * getEnvironment() const
Get a JNI environment pointer for the current thread.
AttachGuard(AttachGuard const &)=delete
AttachGuard & operator=(AttachGuard const &)=delete
An encapsulating wrapper around a Java virtual machine.
VirtualMachine(VirtualMachine const &)=delete
VirtualMachine & operator=(VirtualMachine const &)=delete
#define JVMACCESS_DLLPUBLIC