Line data Source code
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 : #include "sal/config.h"
21 :
22 : #include "jvmaccess/unovirtualmachine.hxx"
23 :
24 : #include "osl/diagnose.h"
25 :
26 : #include "jvmaccess/virtualmachine.hxx"
27 :
28 : #include "jni.h"
29 :
30 : namespace jvmaccess {
31 :
32 0 : UnoVirtualMachine::CreationException::CreationException() {}
33 :
34 0 : UnoVirtualMachine::CreationException::CreationException(
35 0 : CreationException const &)
36 0 : {}
37 :
38 0 : UnoVirtualMachine::CreationException::~CreationException() {}
39 :
40 : UnoVirtualMachine::CreationException &
41 0 : UnoVirtualMachine::CreationException::operator =(CreationException const &) {
42 0 : return *this;
43 : }
44 :
45 0 : UnoVirtualMachine::UnoVirtualMachine(
46 : rtl::Reference< jvmaccess::VirtualMachine > const & virtualMachine,
47 : void * classLoader):
48 : m_virtualMachine(virtualMachine),
49 0 : m_classLoader(0)
50 : {
51 : try {
52 : m_classLoader =
53 : jvmaccess::VirtualMachine::AttachGuard(m_virtualMachine).
54 0 : getEnvironment()->NewGlobalRef(static_cast< jobject >(classLoader));
55 0 : } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) {}
56 0 : if (m_classLoader == 0) {
57 0 : throw CreationException();
58 : }
59 0 : }
60 :
61 : rtl::Reference< jvmaccess::VirtualMachine >
62 0 : UnoVirtualMachine::getVirtualMachine() const {
63 0 : return m_virtualMachine;
64 : }
65 :
66 0 : void * UnoVirtualMachine::getClassLoader() const {
67 0 : return m_classLoader;
68 : }
69 :
70 0 : UnoVirtualMachine::~UnoVirtualMachine() {
71 : try {
72 : jvmaccess::VirtualMachine::AttachGuard(m_virtualMachine).
73 : getEnvironment()->DeleteGlobalRef(
74 0 : static_cast< jobject >(m_classLoader));
75 0 : } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) {
76 : OSL_TRACE(
77 : "jvmaccess::UnoVirtualMachine::~UnoVirtualMachine:"
78 : " jvmaccess::VirtualMachine::AttachGuard::CreationException" );
79 : }
80 0 : }
81 :
82 : }
83 :
84 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|