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