1/************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27#ifndef __com_sun_star_java_XJavaVM_idl__ 28#define __com_sun_star_java_XJavaVM_idl__ 29 30#ifndef __com_sun_star_uno_XInterface_idl__ 31#include <com/sun/star/uno/XInterface.idl> 32#endif 33 34//============================================================================= 35 36module com { module sun { module star { module java { 37 38//============================================================================= 39 40// DocMerge from xml: interface com::sun::star::java::XJavaVM 41/** must be implemented by the user of the XJavaVM. 42 43 @deprecated 44 A UNO interface seems to be at the wrong abstraction level for this 45 functionality (also, the C++ classes <code>jvmaccess::VirtualMachine</code> 46 and <code>jvmaccess::UnoVirtualMachine</code> used by 47 <member scope="com::sun::star::java">XJavaVM::getJavaVM</member> are not 48 part of the public C++ UNO runtime API). This should probably be replaced 49 by an appropriate C/C++ API. 50 */ 51published interface XJavaVM: com::sun::star::uno::XInterface 52{ 53 //------------------------------------------------------------------------- 54 55 // DocMerge from xml: method com::sun::star::java::XJavaVM::getJavaVM 56 /** returns the address of the Java Virtual Machine. 57 58 <p>If the VM is not already instantiated, it will be now.</p> 59 60 <p>If the <code>processID</code> is a normal 16-byte ID, the returned 61 <atom>any</atom> contains a JNI <code>JavaVM</code> pointer as a 62 <atom>long</atom> or <atom>hyper</atom> integer (depending on the 63 platform). If the <code>processID</code> does not match the current 64 process, or if the VM cannot be instantiated for whatever reason, a 65 <void/> <atom>any</atom> is returned.</p> 66 67 <p>If the <code>processID</code> has an additional 17th byte of 68 value <code>0</code>, the returned <atom>any</atom> contains a 69 non–reference-counted pointer to a (reference-counted) instance of 70 the C++ <code>jvmaccess::VirtualMachine</code> class, always represented 71 as a <atom>hyper</atom> integer. The pointer is guaranteed to be valid 72 as long as the reference to this 73 <type scope="com::sun::star::java">XJavaVM</type> is valid (but the 74 pointer should be converted into a reference-counted reference as soon 75 as possible). Again, if the first 16 bytes of the 76 <code>processID</code> do not match the current process, or if the VM 77 cannot be instantiated for whatever reason, a <void/> <atom>any</atom> 78 is returned.</p> 79 80 <p>If the <code>processID</code> has an additional 17th byte of 81 value <code>1</code>, the returned <atom>any</atom> contains a 82 non–reference-counted pointer to a (reference-counted) instance of 83 the C++ <code>jvmaccess::UnoVirtualMachine</code> class, always 84 represented as a <atom>hyper</atom> integer. The pointer is guaranteed 85 to be valid as long as the reference to this 86 <type scope="com::sun::star::java">XJavaVM</type> is valid. Again, if 87 the first 16 bytes of the <code>processID</code> do not match the 88 current process, or if the VM cannot be instantiated for whatever 89 reason, a <void/> <atom>any</atom> is returned.</p> 90 91 <p>The first form (returning a JNI <code>JavaVM</code> pointer) is 92 mainly for backwards compatibility, new code should use the second form 93 (returning a pointer to a <code>jvmaccess::VirtualMachine</code>) if it 94 does not want to use the Java UNO environment, and it should use the 95 third form (returning a pointer to a 96 <code>jvmaccess::UnoVirtualMachine</code>) if it wants to use the Java 97 UNO environment. For example, one advantage of using 98 <code>jvmaccess::VirtualMachine</code> instead of the raw 99 <code>JavaVM</code> pointer is that whenever you attach a native thread 100 to the Java virtual machine, that thread's context 101 <code>ClassLoader</code> (see 102 <code>java.lang.Thread.getContextClassLoader</code>) will automatically 103 be set to a meaningful value.</p> 104 105 @param processID 106 The process ID of the caller's process, possibly extended by a 17th byte 107 of value <code>0</code> or <code>1</code>. 108 109 @return 110 On success, the <atom>any</atom> contains a pointer represented as 111 <atom>long</atom> or <atom>hyper</atom>, otherwise the <atom>any</atom> 112 is <void/>. 113 */ 114 any getJavaVM( [in] sequence<byte> processID ); 115 116 //------------------------------------------------------------------------- 117 118 // DocMerge from xml: method com::sun::star::java::XJavaVM::isVMStarted 119 /** returns <true/> if the VM is started successfully, otherwise <false/>. 120 */ 121 boolean isVMStarted(); 122 123 //------------------------------------------------------------------------- 124 125 // DocMerge from xml: method com::sun::star::java::XJavaVM::isVMEnabled 126 /** Returns <true/> if the VM is enabled. 127 128 <p>It is only possible to get the VM, if this method return 0. </p> 129 */ 130 boolean isVMEnabled(); 131 132}; 133 134//============================================================================= 135 136}; }; }; }; 137 138/*============================================================================= 139 140=============================================================================*/ 141#endif 142