1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unovirtualmachine.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "sal/config.h"
33 #include "jvmaccess/unovirtualmachine.hxx"
35 #include "osl/diagnose.h"
37 #include "jvmaccess/virtualmachine.hxx"
39 #if defined SOLAR_JAVA
45 UnoVirtualMachine::CreationException::CreationException() {}
47 UnoVirtualMachine::CreationException::CreationException(
48 CreationException
const &)
51 UnoVirtualMachine::CreationException::~CreationException() {}
53 UnoVirtualMachine::CreationException
&
54 UnoVirtualMachine::CreationException::operator =(CreationException
const &) {
58 UnoVirtualMachine::UnoVirtualMachine(
59 rtl::Reference
< jvmaccess::VirtualMachine
> const & virtualMachine
,
61 m_virtualMachine(virtualMachine
),
64 #if defined SOLAR_JAVA
67 jvmaccess::VirtualMachine::AttachGuard(m_virtualMachine
).
68 getEnvironment()->NewGlobalRef(static_cast< jobject
>(classLoader
));
69 } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException
&) {}
71 if (m_classLoader
== 0) {
72 throw CreationException();
76 rtl::Reference
< jvmaccess::VirtualMachine
>
77 UnoVirtualMachine::getVirtualMachine() const {
78 return m_virtualMachine
;
81 void * UnoVirtualMachine::getClassLoader() const {
85 UnoVirtualMachine::~UnoVirtualMachine() {
86 #if defined SOLAR_JAVA
88 jvmaccess::VirtualMachine::AttachGuard(m_virtualMachine
).
89 getEnvironment()->DeleteGlobalRef(
90 static_cast< jobject
>(m_classLoader
));
91 } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException
&) {
93 "jvmaccess::UnoVirtualMachine::~UnoVirtualMachine:"
94 " jvmaccess::VirtualMachine::AttachGuard::CreationException" );