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