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 #include "sal/config.h"
22 #include "jvmaccess/unovirtualmachine.hxx"
24 #include "osl/diagnose.h"
26 #include "jvmaccess/virtualmachine.hxx"
28 #if defined SOLAR_JAVA
34 UnoVirtualMachine::CreationException::CreationException() {}
36 UnoVirtualMachine::CreationException::CreationException(
37 CreationException
const &)
40 UnoVirtualMachine::CreationException::~CreationException() {}
42 UnoVirtualMachine::CreationException
&
43 UnoVirtualMachine::CreationException::operator =(CreationException
const &) {
47 UnoVirtualMachine::UnoVirtualMachine(
48 rtl::Reference
< jvmaccess::VirtualMachine
> const & virtualMachine
,
50 m_virtualMachine(virtualMachine
),
53 #if defined SOLAR_JAVA
56 jvmaccess::VirtualMachine::AttachGuard(m_virtualMachine
).
57 getEnvironment()->NewGlobalRef(static_cast< jobject
>(classLoader
));
58 } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException
&) {}
62 if (m_classLoader
== 0) {
63 throw CreationException();
67 rtl::Reference
< jvmaccess::VirtualMachine
>
68 UnoVirtualMachine::getVirtualMachine() const {
69 return m_virtualMachine
;
72 void * UnoVirtualMachine::getClassLoader() const {
76 UnoVirtualMachine::~UnoVirtualMachine() {
77 #if defined SOLAR_JAVA
79 jvmaccess::VirtualMachine::AttachGuard(m_virtualMachine
).
80 getEnvironment()->DeleteGlobalRef(
81 static_cast< jobject
>(m_classLoader
));
82 } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException
&) {
84 "jvmaccess::UnoVirtualMachine::~UnoVirtualMachine:"
85 " jvmaccess::VirtualMachine::AttachGuard::CreationException" );
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */