1*408a4873SAndrew Rist/************************************************************** 2cdf0e10cSrcweir * 3*408a4873SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*408a4873SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*408a4873SAndrew Rist * distributed with this work for additional information 6*408a4873SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*408a4873SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*408a4873SAndrew Rist * "License"); you may not use this file except in compliance 9*408a4873SAndrew Rist * with the License. You may obtain a copy of the License at 10*408a4873SAndrew Rist * 11*408a4873SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*408a4873SAndrew Rist * 13*408a4873SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*408a4873SAndrew Rist * software distributed under the License is distributed on an 15*408a4873SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*408a4873SAndrew Rist * KIND, either express or implied. See the License for the 17*408a4873SAndrew Rist * specific language governing permissions and limitations 18*408a4873SAndrew Rist * under the License. 19*408a4873SAndrew Rist * 20*408a4873SAndrew Rist *************************************************************/ 21*408a4873SAndrew Rist 22*408a4873SAndrew Rist 23cdf0e10cSrcweir#ifndef __com_sun_star_java_XJavaVM_idl__ 24cdf0e10cSrcweir#define __com_sun_star_java_XJavaVM_idl__ 25cdf0e10cSrcweir 26cdf0e10cSrcweir#ifndef __com_sun_star_uno_XInterface_idl__ 27cdf0e10cSrcweir#include <com/sun/star/uno/XInterface.idl> 28cdf0e10cSrcweir#endif 29cdf0e10cSrcweir 30cdf0e10cSrcweir//============================================================================= 31cdf0e10cSrcweir 32cdf0e10cSrcweirmodule com { module sun { module star { module java { 33cdf0e10cSrcweir 34cdf0e10cSrcweir//============================================================================= 35cdf0e10cSrcweir 36cdf0e10cSrcweir// DocMerge from xml: interface com::sun::star::java::XJavaVM 37cdf0e10cSrcweir/** must be implemented by the user of the XJavaVM. 38cdf0e10cSrcweir 39cdf0e10cSrcweir @deprecated 40cdf0e10cSrcweir A UNO interface seems to be at the wrong abstraction level for this 41cdf0e10cSrcweir functionality (also, the C++ classes <code>jvmaccess::VirtualMachine</code> 42cdf0e10cSrcweir and <code>jvmaccess::UnoVirtualMachine</code> used by 43cdf0e10cSrcweir <member scope="com::sun::star::java">XJavaVM::getJavaVM</member> are not 44cdf0e10cSrcweir part of the public C++ UNO runtime API). This should probably be replaced 45cdf0e10cSrcweir by an appropriate C/C++ API. 46cdf0e10cSrcweir */ 47cdf0e10cSrcweirpublished interface XJavaVM: com::sun::star::uno::XInterface 48cdf0e10cSrcweir{ 49cdf0e10cSrcweir //------------------------------------------------------------------------- 50cdf0e10cSrcweir 51cdf0e10cSrcweir // DocMerge from xml: method com::sun::star::java::XJavaVM::getJavaVM 52cdf0e10cSrcweir /** returns the address of the Java Virtual Machine. 53cdf0e10cSrcweir 54cdf0e10cSrcweir <p>If the VM is not already instantiated, it will be now.</p> 55cdf0e10cSrcweir 56cdf0e10cSrcweir <p>If the <code>processID</code> is a normal 16-byte ID, the returned 57cdf0e10cSrcweir <atom>any</atom> contains a JNI <code>JavaVM</code> pointer as a 58cdf0e10cSrcweir <atom>long</atom> or <atom>hyper</atom> integer (depending on the 59cdf0e10cSrcweir platform). If the <code>processID</code> does not match the current 60cdf0e10cSrcweir process, or if the VM cannot be instantiated for whatever reason, a 61cdf0e10cSrcweir <void/> <atom>any</atom> is returned.</p> 62cdf0e10cSrcweir 63cdf0e10cSrcweir <p>If the <code>processID</code> has an additional 17th byte of 64cdf0e10cSrcweir value <code>0</code>, the returned <atom>any</atom> contains a 65cdf0e10cSrcweir non–reference-counted pointer to a (reference-counted) instance of 66cdf0e10cSrcweir the C++ <code>jvmaccess::VirtualMachine</code> class, always represented 67cdf0e10cSrcweir as a <atom>hyper</atom> integer. The pointer is guaranteed to be valid 68cdf0e10cSrcweir as long as the reference to this 69cdf0e10cSrcweir <type scope="com::sun::star::java">XJavaVM</type> is valid (but the 70cdf0e10cSrcweir pointer should be converted into a reference-counted reference as soon 71cdf0e10cSrcweir as possible). Again, if the first 16 bytes of the 72cdf0e10cSrcweir <code>processID</code> do not match the current process, or if the VM 73cdf0e10cSrcweir cannot be instantiated for whatever reason, a <void/> <atom>any</atom> 74cdf0e10cSrcweir is returned.</p> 75cdf0e10cSrcweir 76cdf0e10cSrcweir <p>If the <code>processID</code> has an additional 17th byte of 77cdf0e10cSrcweir value <code>1</code>, the returned <atom>any</atom> contains a 78cdf0e10cSrcweir non–reference-counted pointer to a (reference-counted) instance of 79cdf0e10cSrcweir the C++ <code>jvmaccess::UnoVirtualMachine</code> class, always 80cdf0e10cSrcweir represented as a <atom>hyper</atom> integer. The pointer is guaranteed 81cdf0e10cSrcweir to be valid as long as the reference to this 82cdf0e10cSrcweir <type scope="com::sun::star::java">XJavaVM</type> is valid. Again, if 83cdf0e10cSrcweir the first 16 bytes of the <code>processID</code> do not match the 84cdf0e10cSrcweir current process, or if the VM cannot be instantiated for whatever 85cdf0e10cSrcweir reason, a <void/> <atom>any</atom> is returned.</p> 86cdf0e10cSrcweir 87cdf0e10cSrcweir <p>The first form (returning a JNI <code>JavaVM</code> pointer) is 88cdf0e10cSrcweir mainly for backwards compatibility, new code should use the second form 89cdf0e10cSrcweir (returning a pointer to a <code>jvmaccess::VirtualMachine</code>) if it 90cdf0e10cSrcweir does not want to use the Java UNO environment, and it should use the 91cdf0e10cSrcweir third form (returning a pointer to a 92cdf0e10cSrcweir <code>jvmaccess::UnoVirtualMachine</code>) if it wants to use the Java 93cdf0e10cSrcweir UNO environment. For example, one advantage of using 94cdf0e10cSrcweir <code>jvmaccess::VirtualMachine</code> instead of the raw 95cdf0e10cSrcweir <code>JavaVM</code> pointer is that whenever you attach a native thread 96cdf0e10cSrcweir to the Java virtual machine, that thread's context 97cdf0e10cSrcweir <code>ClassLoader</code> (see 98cdf0e10cSrcweir <code>java.lang.Thread.getContextClassLoader</code>) will automatically 99cdf0e10cSrcweir be set to a meaningful value.</p> 100cdf0e10cSrcweir 101cdf0e10cSrcweir @param processID 102cdf0e10cSrcweir The process ID of the caller's process, possibly extended by a 17th byte 103cdf0e10cSrcweir of value <code>0</code> or <code>1</code>. 104cdf0e10cSrcweir 105cdf0e10cSrcweir @return 106cdf0e10cSrcweir On success, the <atom>any</atom> contains a pointer represented as 107cdf0e10cSrcweir <atom>long</atom> or <atom>hyper</atom>, otherwise the <atom>any</atom> 108cdf0e10cSrcweir is <void/>. 109cdf0e10cSrcweir */ 110cdf0e10cSrcweir any getJavaVM( [in] sequence<byte> processID ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir //------------------------------------------------------------------------- 113cdf0e10cSrcweir 114cdf0e10cSrcweir // DocMerge from xml: method com::sun::star::java::XJavaVM::isVMStarted 115cdf0e10cSrcweir /** returns <true/> if the VM is started successfully, otherwise <false/>. 116cdf0e10cSrcweir */ 117cdf0e10cSrcweir boolean isVMStarted(); 118cdf0e10cSrcweir 119cdf0e10cSrcweir //------------------------------------------------------------------------- 120cdf0e10cSrcweir 121cdf0e10cSrcweir // DocMerge from xml: method com::sun::star::java::XJavaVM::isVMEnabled 122cdf0e10cSrcweir /** Returns <true/> if the VM is enabled. 123cdf0e10cSrcweir 124cdf0e10cSrcweir <p>It is only possible to get the VM, if this method return 0. </p> 125cdf0e10cSrcweir */ 126cdf0e10cSrcweir boolean isVMEnabled(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir}; 129cdf0e10cSrcweir 130cdf0e10cSrcweir//============================================================================= 131cdf0e10cSrcweir 132cdf0e10cSrcweir}; }; }; }; 133cdf0e10cSrcweir 134cdf0e10cSrcweir/*============================================================================= 135cdf0e10cSrcweir 136cdf0e10cSrcweir=============================================================================*/ 137cdf0e10cSrcweir#endif 138