File: | stoc/source/javavm/javavm.cxx |
Location: | line 281, column 20 |
Description: | Called C++ object pointer is null |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||
12 | * contributor license agreements. See the NOTICE file distributed | |||
13 | * with this work for additional information regarding copyright | |||
14 | * ownership. The ASF licenses this file to you under the Apache | |||
15 | * License, Version 2.0 (the "License"); you may not use this file | |||
16 | * except in compliance with the License. You may obtain a copy of | |||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||
18 | */ | |||
19 | ||||
20 | ||||
21 | #include "javavm.hxx" | |||
22 | ||||
23 | #include "interact.hxx" | |||
24 | #include "jvmargs.hxx" | |||
25 | ||||
26 | #include "com/sun/star/beans/NamedValue.hpp" | |||
27 | #include "com/sun/star/beans/PropertyState.hpp" | |||
28 | #include "com/sun/star/beans/PropertyValue.hpp" | |||
29 | #include "com/sun/star/container/XContainer.hpp" | |||
30 | #include "com/sun/star/java/JavaNotFoundException.hpp" | |||
31 | #include "com/sun/star/java/InvalidJavaSettingsException.hpp" | |||
32 | #include "com/sun/star/java/RestartRequiredException.hpp" | |||
33 | #include "com/sun/star/java/JavaDisabledException.hpp" | |||
34 | #include "com/sun/star/java/JavaVMCreationFailureException.hpp" | |||
35 | #include "com/sun/star/lang/DisposedException.hpp" | |||
36 | #include "com/sun/star/lang/IllegalArgumentException.hpp" | |||
37 | #include "com/sun/star/lang/XEventListener.hpp" | |||
38 | #include "com/sun/star/lang/XMultiComponentFactory.hpp" | |||
39 | #include "com/sun/star/lang/XSingleComponentFactory.hpp" | |||
40 | #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" | |||
41 | #include "com/sun/star/registry/XRegistryKey.hpp" | |||
42 | #include "com/sun/star/registry/XSimpleRegistry.hpp" | |||
43 | #include "com/sun/star/task/XInteractionHandler.hpp" | |||
44 | #include "com/sun/star/uno/Exception.hpp" | |||
45 | #include "com/sun/star/uno/Reference.hxx" | |||
46 | #include "com/sun/star/uno/RuntimeException.hpp" | |||
47 | #include "com/sun/star/uno/Sequence.hxx" | |||
48 | #include "com/sun/star/uno/XComponentContext.hpp" | |||
49 | #include "com/sun/star/uno/XCurrentContext.hpp" | |||
50 | #include "com/sun/star/uno/XInterface.hpp" | |||
51 | #include "com/sun/star/util/XMacroExpander.hpp" | |||
52 | #include "com/sun/star/container/XNameAccess.hpp" | |||
53 | #include "cppuhelper/exc_hlp.hxx" | |||
54 | #include "cppuhelper/factory.hxx" | |||
55 | #include "cppuhelper/implbase1.hxx" | |||
56 | #include "cppuhelper/implementationentry.hxx" | |||
57 | #include "jvmaccess/classpath.hxx" | |||
58 | #include "jvmaccess/unovirtualmachine.hxx" | |||
59 | #include "jvmaccess/virtualmachine.hxx" | |||
60 | #include "osl/file.hxx" | |||
61 | #include "osl/thread.h" | |||
62 | #include "rtl/bootstrap.hxx" | |||
63 | #include "rtl/process.h" | |||
64 | #include "rtl/string.h" | |||
65 | #include "rtl/ustrbuf.hxx" | |||
66 | #include "rtl/ustring.h" | |||
67 | #include "rtl/ustring.hxx" | |||
68 | #include "rtl/uri.hxx" | |||
69 | #include "sal/types.h" | |||
70 | #include "uno/current_context.hxx" | |||
71 | #include "uno/environment.h" | |||
72 | #include "uno/lbnames.h" | |||
73 | #include "jvmfwk/framework.h" | |||
74 | #include "jni.h" | |||
75 | ||||
76 | #include <stack> | |||
77 | #include <string.h> | |||
78 | #include <time.h> | |||
79 | #include <memory> | |||
80 | #include <vector> | |||
81 | #include "boost/scoped_array.hpp" | |||
82 | #define OUSTR(x)rtl::OUString((&(x)[0]), ((sal_Int32)((sizeof (x) / sizeof ((x)[0]))-1)), (((rtl_TextEncoding) 11))) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x )(&(x)[0]), ((sal_Int32)((sizeof (x) / sizeof ((x)[0]))-1) ), (((rtl_TextEncoding) 11))) | |||
83 | ||||
84 | // Properties of the javavm can be put | |||
85 | // as a komma separated list in this | |||
86 | // environment variable | |||
87 | #define PROPERTIES_ENV"OO_JAVA_PROPERTIES" "OO_JAVA_PROPERTIES" | |||
88 | #ifdef UNIX1 | |||
89 | #define INI_FILE"javarc" "javarc" | |||
90 | #ifdef MACOSX | |||
91 | #define DEF_JAVALIB"libjvm.so" "JavaVM.framework" | |||
92 | #else | |||
93 | #define DEF_JAVALIB"libjvm.so" "libjvm.so" | |||
94 | #endif | |||
95 | #define TIMEZONE"MEZ" "MEZ" | |||
96 | #else | |||
97 | #define INI_FILE"javarc" "java.ini" | |||
98 | #define DEF_JAVALIB"libjvm.so" "jvm.dll" | |||
99 | #define TIMEZONE"MEZ" "MET" | |||
100 | #endif | |||
101 | ||||
102 | /* Within this implementation of the com.sun.star.java.JavaVirtualMachine | |||
103 | * service and com.sun.star.java.theJavaVirtualMachine singleton, the method | |||
104 | * com.sun.star.java.XJavaVM.getJavaVM relies on the following: | |||
105 | * 1 The string "$URE_INTERNAL_JAVA_DIR/" is expanded via the | |||
106 | * com.sun.star.util.theMacroExpander singleton into an internal (see the | |||
107 | * com.sun.star.uri.ExternalUriReferenceTranslator service), hierarchical URI | |||
108 | * reference relative to which the URE JAR files can be addressed. | |||
109 | * 2 The string "$URE_INTERNAL_JAVA_CLASSPATH" is either not expandable via the | |||
110 | * com.sun.star.util.theMacroExpander singleton | |||
111 | * (com.sun.star.lang.IllegalArgumentException), or is expanded via the | |||
112 | * com.sun.star.util.theMacroExpander singleton into a list of zero or more | |||
113 | * internal (see the com.sun.star.uri.ExternalUriReferenceTranslator service) | |||
114 | * URIs, where any space characters (U+0020) are ignored (and, in particular, | |||
115 | * separate adjacent URIs). | |||
116 | * If either of these requirements is not met, getJavaVM raises a | |||
117 | * com.sun.star.uno.RuntimeException. | |||
118 | */ | |||
119 | ||||
120 | namespace css = com::sun::star; | |||
121 | ||||
122 | using stoc_javavm::JavaVirtualMachine; | |||
123 | ||||
124 | namespace { | |||
125 | ||||
126 | ||||
127 | ||||
128 | class NoJavaIniException: public css::uno::Exception | |||
129 | { | |||
130 | }; | |||
131 | ||||
132 | class SingletonFactory: | |||
133 | private cppu::WeakImplHelper1< css::lang::XEventListener > | |||
134 | { | |||
135 | public: | |||
136 | static css::uno::Reference< css::uno::XInterface > getSingleton( | |||
137 | css::uno::Reference< css::uno::XComponentContext > const & rContext); | |||
138 | ||||
139 | private: | |||
140 | SingletonFactory(SingletonFactory &); // not implemented | |||
141 | void operator =(SingletonFactory); // not implemented | |||
142 | ||||
143 | inline SingletonFactory() {} | |||
144 | ||||
145 | virtual inline ~SingletonFactory() {} | |||
146 | ||||
147 | virtual void SAL_CALL disposing(css::lang::EventObject const &) | |||
148 | throw (css::uno::RuntimeException); | |||
149 | ||||
150 | static void dispose(); | |||
151 | ||||
152 | // TODO ok to keep these static? | |||
153 | static osl::Mutex m_aMutex; | |||
154 | static css::uno::Reference< css::uno::XInterface > m_xSingleton; | |||
155 | static bool m_bDisposed; | |||
156 | }; | |||
157 | ||||
158 | css::uno::Reference< css::uno::XInterface > SingletonFactory::getSingleton( | |||
159 | css::uno::Reference< css::uno::XComponentContext > const & rContext) | |||
160 | { | |||
161 | css::uno::Reference< css::uno::XInterface > xSingleton; | |||
162 | css::uno::Reference< css::lang::XComponent > xComponent; | |||
163 | { | |||
164 | osl::MutexGuard aGuard(m_aMutex); | |||
165 | if (!m_xSingleton.is()) | |||
166 | { | |||
167 | if (m_bDisposed) | |||
168 | throw css::lang::DisposedException(); | |||
169 | xComponent = css::uno::Reference< css::lang::XComponent >( | |||
170 | rContext, css::uno::UNO_QUERY_THROW); | |||
171 | m_xSingleton = static_cast< cppu::OWeakObject * >( | |||
172 | new JavaVirtualMachine(rContext)); | |||
173 | } | |||
174 | xSingleton = m_xSingleton; | |||
175 | } | |||
176 | if (xComponent.is()) | |||
177 | try | |||
178 | { | |||
179 | xComponent->addEventListener(new SingletonFactory); | |||
180 | } | |||
181 | catch (...) | |||
182 | { | |||
183 | dispose(); | |||
184 | throw; | |||
185 | } | |||
186 | return xSingleton; | |||
187 | } | |||
188 | ||||
189 | void SAL_CALL SingletonFactory::disposing(css::lang::EventObject const &) | |||
190 | throw (css::uno::RuntimeException) | |||
191 | { | |||
192 | dispose(); | |||
193 | } | |||
194 | ||||
195 | void SingletonFactory::dispose() | |||
196 | { | |||
197 | css::uno::Reference< css::lang::XComponent > xComponent; | |||
198 | { | |||
199 | osl::MutexGuard aGuard(m_aMutex); | |||
200 | xComponent = css::uno::Reference< css::lang::XComponent >( | |||
201 | m_xSingleton, css::uno::UNO_QUERY); | |||
202 | m_xSingleton.clear(); | |||
203 | m_bDisposed = true; | |||
204 | } | |||
205 | if (xComponent.is()) | |||
206 | xComponent->dispose(); | |||
207 | } | |||
208 | ||||
209 | osl::Mutex SingletonFactory::m_aMutex; | |||
210 | css::uno::Reference< css::uno::XInterface > SingletonFactory::m_xSingleton; | |||
211 | bool SingletonFactory::m_bDisposed = false; | |||
212 | ||||
213 | rtl::OUString serviceGetImplementationName() | |||
214 | { | |||
215 | return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.comp.stoc.JavaVirtualMachine")[0]), ((sal_Int32 )((sizeof ("com.sun.star.comp.stoc.JavaVirtualMachine") / sizeof (("com.sun.star.comp.stoc.JavaVirtualMachine")[0]))-1)), ((( rtl_TextEncoding) 11)) | |||
216 | "com.sun.star.comp.stoc.JavaVirtualMachine")(&("com.sun.star.comp.stoc.JavaVirtualMachine")[0]), ((sal_Int32 )((sizeof ("com.sun.star.comp.stoc.JavaVirtualMachine") / sizeof (("com.sun.star.comp.stoc.JavaVirtualMachine")[0]))-1)), ((( rtl_TextEncoding) 11))); | |||
217 | } | |||
218 | ||||
219 | css::uno::Sequence< rtl::OUString > serviceGetSupportedServiceNames() | |||
220 | { | |||
221 | rtl::OUString aServiceName( | |||
222 | RTL_CONSTASCII_USTRINGPARAM("com.sun.star.java.JavaVirtualMachine")(&("com.sun.star.java.JavaVirtualMachine")[0]), ((sal_Int32 )((sizeof ("com.sun.star.java.JavaVirtualMachine") / sizeof ( ("com.sun.star.java.JavaVirtualMachine")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
223 | return css::uno::Sequence< rtl::OUString >(&aServiceName, 1); | |||
224 | } | |||
225 | ||||
226 | css::uno::Reference< css::uno::XInterface > SAL_CALL serviceCreateInstance( | |||
227 | css::uno::Reference< css::uno::XComponentContext > const & rContext) | |||
228 | SAL_THROW((css::uno::Exception)) | |||
229 | { | |||
230 | // Only one single instance of this service is ever constructed, and is | |||
231 | // available until the component context used to create this instance is | |||
232 | // disposed. Afterwards, this function throws a DisposedException (as do | |||
233 | // all relevant methods on the single service instance). | |||
234 | return SingletonFactory::getSingleton(rContext); | |||
235 | } | |||
236 | ||||
237 | cppu::ImplementationEntry const aServiceImplementation[] | |||
238 | = { { serviceCreateInstance, | |||
239 | serviceGetImplementationName, | |||
240 | serviceGetSupportedServiceNames, | |||
241 | cppu::createSingleComponentFactory, | |||
242 | 0, 0 }, | |||
243 | { 0, 0, 0, 0, 0, 0 } }; | |||
244 | ||||
245 | typedef std::stack< jvmaccess::VirtualMachine::AttachGuard * > GuardStack; | |||
246 | ||||
247 | extern "C" { | |||
248 | ||||
249 | static void destroyAttachGuards(void * pData) | |||
250 | { | |||
251 | GuardStack * pStack = static_cast< GuardStack * >(pData); | |||
252 | if (pStack != 0) | |||
253 | { | |||
254 | while (!pStack->empty()) | |||
255 | { | |||
256 | delete pStack->top(); | |||
257 | pStack->pop(); | |||
258 | } | |||
259 | delete pStack; | |||
260 | } | |||
261 | } | |||
262 | ||||
263 | } | |||
264 | ||||
265 | bool askForRetry(css::uno::Any const & rException) | |||
266 | { | |||
267 | css::uno::Reference< css::uno::XCurrentContext > xContext( | |||
268 | css::uno::getCurrentContext()); | |||
269 | if (xContext.is()) | |||
270 | { | |||
271 | css::uno::Reference< css::task::XInteractionHandler > xHandler; | |||
272 | xContext->getValueByName(rtl::OUString( | |||
273 | RTL_CONSTASCII_USTRINGPARAM((&("java-vm.interaction-handler")[0]), ((sal_Int32)((sizeof ("java-vm.interaction-handler") / sizeof (("java-vm.interaction-handler" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
274 | "java-vm.interaction-handler")(&("java-vm.interaction-handler")[0]), ((sal_Int32)((sizeof ("java-vm.interaction-handler") / sizeof (("java-vm.interaction-handler" )[0]))-1)), (((rtl_TextEncoding) 11)))) | |||
275 | >>= xHandler; | |||
276 | if (xHandler.is()) | |||
277 | { | |||
278 | rtl::Reference< stoc_javavm::InteractionRequest > xRequest( | |||
279 | new stoc_javavm::InteractionRequest(rException)); | |||
280 | xHandler->handle(xRequest.get()); | |||
281 | return xRequest->retry(); | |||
| ||||
282 | } | |||
283 | } | |||
284 | return false; | |||
285 | } | |||
286 | ||||
287 | // Only gets the properties if the "Proxy Server" entry in the option dialog is | |||
288 | // set to manual (i.e. not to none) | |||
289 | void getINetPropsFromConfig(stoc_javavm::JVM * pjvm, | |||
290 | const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr, | |||
291 | const css::uno::Reference<css::uno::XComponentContext> &xCtx ) throw (css::uno::Exception) | |||
292 | { | |||
293 | css::uno::Reference<css::uno::XInterface> xConfRegistry = xSMgr->createInstanceWithContext( | |||
294 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationRegistry")(&("com.sun.star.configuration.ConfigurationRegistry")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationRegistry" ) / sizeof (("com.sun.star.configuration.ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
295 | xCtx ); | |||
296 | if(!xConfRegistry.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")(&("javavm.cxx: couldn't get ConfigurationRegistry")[0]), ((sal_Int32)((sizeof ("javavm.cxx: couldn't get ConfigurationRegistry" ) / sizeof (("javavm.cxx: couldn't get ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
297 | ||||
298 | css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple(xConfRegistry, css::uno::UNO_QUERY); | |||
299 | if(!xConfRegistry_simple.is()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")(&("javavm.cxx: couldn't get ConfigurationRegistry")[0]), ((sal_Int32)((sizeof ("javavm.cxx: couldn't get ConfigurationRegistry" ) / sizeof (("javavm.cxx: couldn't get ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
300 | ||||
301 | xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Inet")(&("org.openoffice.Inet")[0]), ((sal_Int32)((sizeof ("org.openoffice.Inet" ) / sizeof (("org.openoffice.Inet")[0]))-1)), (((rtl_TextEncoding ) 11))), sal_True((sal_Bool)1), sal_False((sal_Bool)0)); | |||
302 | css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey(); | |||
303 | ||||
304 | // if ooInetProxyType is not 0 then read the settings | |||
305 | css::uno::Reference<css::registry::XRegistryKey> proxyEnable= xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetProxyType")(&("Settings/ooInetProxyType")[0]), ((sal_Int32)((sizeof ( "Settings/ooInetProxyType") / sizeof (("Settings/ooInetProxyType" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
306 | if( proxyEnable.is() && 0 != proxyEnable->getLongValue()) | |||
307 | { | |||
308 | // read ftp proxy name | |||
309 | css::uno::Reference<css::registry::XRegistryKey> ftpProxy_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetFTPProxyName")(&("Settings/ooInetFTPProxyName")[0]), ((sal_Int32)((sizeof ("Settings/ooInetFTPProxyName") / sizeof (("Settings/ooInetFTPProxyName" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
310 | if(ftpProxy_name.is() && !ftpProxy_name->getStringValue().isEmpty()) { | |||
311 | rtl::OUString ftpHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyHost=")(&("ftp.proxyHost=")[0]), ((sal_Int32)((sizeof ("ftp.proxyHost=" ) / sizeof (("ftp.proxyHost=")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
312 | ftpHost += ftpProxy_name->getStringValue(); | |||
313 | ||||
314 | // read ftp proxy port | |||
315 | css::uno::Reference<css::registry::XRegistryKey> ftpProxy_port = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetFTPProxyPort")(&("Settings/ooInetFTPProxyPort")[0]), ((sal_Int32)((sizeof ("Settings/ooInetFTPProxyPort") / sizeof (("Settings/ooInetFTPProxyPort" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
316 | if(ftpProxy_port.is() && ftpProxy_port->getLongValue()) { | |||
317 | rtl::OUString ftpPort = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyPort=")(&("ftp.proxyPort=")[0]), ((sal_Int32)((sizeof ("ftp.proxyPort=" ) / sizeof (("ftp.proxyPort=")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
318 | ftpPort += rtl::OUString::valueOf(ftpProxy_port->getLongValue()); | |||
319 | ||||
320 | pjvm->pushProp(ftpHost); | |||
321 | pjvm->pushProp(ftpPort); | |||
322 | } | |||
323 | } | |||
324 | ||||
325 | // read http proxy name | |||
326 | css::uno::Reference<css::registry::XRegistryKey> httpProxy_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetHTTPProxyName")(&("Settings/ooInetHTTPProxyName")[0]), ((sal_Int32)((sizeof ("Settings/ooInetHTTPProxyName") / sizeof (("Settings/ooInetHTTPProxyName" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
327 | if(httpProxy_name.is() && !httpProxy_name->getStringValue().isEmpty()) { | |||
328 | rtl::OUString httpHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyHost=")(&("http.proxyHost=")[0]), ((sal_Int32)((sizeof ("http.proxyHost=" ) / sizeof (("http.proxyHost=")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
329 | httpHost += httpProxy_name->getStringValue(); | |||
330 | ||||
331 | // read http proxy port | |||
332 | css::uno::Reference<css::registry::XRegistryKey> httpProxy_port = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetHTTPProxyPort")(&("Settings/ooInetHTTPProxyPort")[0]), ((sal_Int32)((sizeof ("Settings/ooInetHTTPProxyPort") / sizeof (("Settings/ooInetHTTPProxyPort" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
333 | if(httpProxy_port.is() && httpProxy_port->getLongValue()) { | |||
334 | rtl::OUString httpPort = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort=")(&("http.proxyPort=")[0]), ((sal_Int32)((sizeof ("http.proxyPort=" ) / sizeof (("http.proxyPort=")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
335 | httpPort += rtl::OUString::valueOf(httpProxy_port->getLongValue()); | |||
336 | ||||
337 | pjvm->pushProp(httpHost); | |||
338 | pjvm->pushProp(httpPort); | |||
339 | } | |||
340 | } | |||
341 | ||||
342 | // read https proxy name | |||
343 | css::uno::Reference<css::registry::XRegistryKey> httpsProxy_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetHTTPSProxyName")(&("Settings/ooInetHTTPSProxyName")[0]), ((sal_Int32)((sizeof ("Settings/ooInetHTTPSProxyName") / sizeof (("Settings/ooInetHTTPSProxyName" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
344 | if(httpsProxy_name.is() && !httpsProxy_name->getStringValue().isEmpty()) { | |||
345 | rtl::OUString httpsHost = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https.proxyHost=")(&("https.proxyHost=")[0]), ((sal_Int32)((sizeof ("https.proxyHost=" ) / sizeof (("https.proxyHost=")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
346 | httpsHost += httpsProxy_name->getStringValue(); | |||
347 | ||||
348 | // read https proxy port | |||
349 | css::uno::Reference<css::registry::XRegistryKey> httpsProxy_port = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetHTTPSProxyPort")(&("Settings/ooInetHTTPSProxyPort")[0]), ((sal_Int32)((sizeof ("Settings/ooInetHTTPSProxyPort") / sizeof (("Settings/ooInetHTTPSProxyPort" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
350 | if(httpsProxy_port.is() && httpsProxy_port->getLongValue()) { | |||
351 | rtl::OUString httpsPort = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https.proxyPort=")(&("https.proxyPort=")[0]), ((sal_Int32)((sizeof ("https.proxyPort=" ) / sizeof (("https.proxyPort=")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
352 | httpsPort += rtl::OUString::valueOf(httpsProxy_port->getLongValue()); | |||
353 | ||||
354 | pjvm->pushProp(httpsHost); | |||
355 | pjvm->pushProp(httpsPort); | |||
356 | } | |||
357 | } | |||
358 | ||||
359 | // read nonProxyHosts | |||
360 | css::uno::Reference<css::registry::XRegistryKey> nonProxies_name = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Settings/ooInetNoProxy")(&("Settings/ooInetNoProxy")[0]), ((sal_Int32)((sizeof ("Settings/ooInetNoProxy" ) / sizeof (("Settings/ooInetNoProxy")[0]))-1)), (((rtl_TextEncoding ) 11)))); | |||
361 | if(nonProxies_name.is() && !nonProxies_name->getStringValue().isEmpty()) { | |||
362 | rtl::OUString httpNonProxyHosts = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.nonProxyHosts=")(&("http.nonProxyHosts=")[0]), ((sal_Int32)((sizeof ("http.nonProxyHosts=" ) / sizeof (("http.nonProxyHosts=")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
363 | rtl::OUString ftpNonProxyHosts= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ftp.nonProxyHosts=")(&("ftp.nonProxyHosts=")[0]), ((sal_Int32)((sizeof ("ftp.nonProxyHosts=" ) / sizeof (("ftp.nonProxyHosts=")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
364 | rtl::OUString value= nonProxies_name->getStringValue(); | |||
365 | // replace the separator ";" by "|" | |||
366 | value= value.replace((sal_Unicode)';', (sal_Unicode)'|'); | |||
367 | ||||
368 | httpNonProxyHosts += value; | |||
369 | ftpNonProxyHosts += value; | |||
370 | ||||
371 | pjvm->pushProp(httpNonProxyHosts); | |||
372 | pjvm->pushProp(ftpNonProxyHosts); | |||
373 | } | |||
374 | ||||
375 | // read socks settings | |||
376 | /* Reference<XRegistryKey> socksProxy_name = xRegistryRootKey->openKey(OUSTR("Settings/ooInetSOCKSProxyName")); | |||
377 | if (socksProxy_name.is() && httpProxy_name->getStringValue().getLength()) { | |||
378 | OUString socksHost = OUSTR("socksProxyHost="); | |||
379 | socksHost += socksProxy_name->getStringValue(); | |||
380 | ||||
381 | // read http proxy port | |||
382 | Reference<XRegistryKey> socksProxy_port = xRegistryRootKey->openKey(OUSTR("Settings/ooInetSOCKSProxyPort")); | |||
383 | if (socksProxy_port.is() && socksProxy_port->getLongValue()) { | |||
384 | OUString socksPort = OUSTR("socksProxyPort="); | |||
385 | socksPort += OUString::valueOf(socksProxy_port->getLongValue()); | |||
386 | ||||
387 | pjvm->pushProp(socksHost); | |||
388 | pjvm->pushProp(socksPort); | |||
389 | } | |||
390 | } | |||
391 | */ } | |||
392 | xConfRegistry_simple->close(); | |||
393 | } | |||
394 | ||||
395 | void getDefaultLocaleFromConfig( | |||
396 | stoc_javavm::JVM * pjvm, | |||
397 | const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr, | |||
398 | const css::uno::Reference<css::uno::XComponentContext> &xCtx ) throw(css::uno::Exception) | |||
399 | { | |||
400 | css::uno::Reference<css::uno::XInterface> xConfRegistry = | |||
401 | xSMgr->createInstanceWithContext( | |||
402 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.configuration.ConfigurationRegistry")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationRegistry" ) / sizeof (("com.sun.star.configuration.ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
403 | "com.sun.star.configuration.ConfigurationRegistry")(&("com.sun.star.configuration.ConfigurationRegistry")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationRegistry" ) / sizeof (("com.sun.star.configuration.ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), xCtx ); | |||
404 | if(!xConfRegistry.is()) | |||
405 | throw css::uno::RuntimeException( | |||
406 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")(&("javavm.cxx: couldn't get ConfigurationRegistry")[0]), ((sal_Int32)((sizeof ("javavm.cxx: couldn't get ConfigurationRegistry" ) / sizeof (("javavm.cxx: couldn't get ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
407 | ||||
408 | css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple( | |||
409 | xConfRegistry, css::uno::UNO_QUERY); | |||
410 | if(!xConfRegistry_simple.is()) | |||
411 | throw css::uno::RuntimeException( | |||
412 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")(&("javavm.cxx: couldn't get ConfigurationRegistry")[0]), ((sal_Int32)((sizeof ("javavm.cxx: couldn't get ConfigurationRegistry" ) / sizeof (("javavm.cxx: couldn't get ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
413 | ||||
414 | xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")(&("org.openoffice.Setup")[0]), ((sal_Int32)((sizeof ("org.openoffice.Setup" ) / sizeof (("org.openoffice.Setup")[0]))-1)), (((rtl_TextEncoding ) 11))), sal_True((sal_Bool)1), sal_False((sal_Bool)0)); | |||
415 | css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey(); | |||
416 | ||||
417 | // read locale | |||
418 | css::uno::Reference<css::registry::XRegistryKey> locale = xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale")(&("L10N/ooLocale")[0]), ((sal_Int32)((sizeof ("L10N/ooLocale" ) / sizeof (("L10N/ooLocale")[0]))-1)), (((rtl_TextEncoding) 11 )))); | |||
419 | if(locale.is() && !locale->getStringValue().isEmpty()) { | |||
420 | rtl::OUString language; | |||
421 | rtl::OUString country; | |||
422 | ||||
423 | sal_Int32 index = locale->getStringValue().indexOf((sal_Unicode) '-'); | |||
424 | ||||
425 | if(index >= 0) { | |||
426 | language = locale->getStringValue().copy(0, index); | |||
427 | country = locale->getStringValue().copy(index + 1); | |||
428 | ||||
429 | if(!language.isEmpty()) { | |||
430 | rtl::OUString prop(RTL_CONSTASCII_USTRINGPARAM("user.language=")(&("user.language=")[0]), ((sal_Int32)((sizeof ("user.language=" ) / sizeof (("user.language=")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
431 | prop += language; | |||
432 | ||||
433 | pjvm->pushProp(prop); | |||
434 | } | |||
435 | ||||
436 | if(!country.isEmpty()) { | |||
437 | rtl::OUString prop(RTL_CONSTASCII_USTRINGPARAM("user.country=")(&("user.country=")[0]), ((sal_Int32)((sizeof ("user.country=" ) / sizeof (("user.country=")[0]))-1)), (((rtl_TextEncoding) 11 ))); | |||
438 | prop += country; | |||
439 | ||||
440 | pjvm->pushProp(prop); | |||
441 | } | |||
442 | } | |||
443 | } | |||
444 | ||||
445 | xConfRegistry_simple->close(); | |||
446 | } | |||
447 | ||||
448 | ||||
449 | ||||
450 | void getJavaPropsFromSafetySettings( | |||
451 | stoc_javavm::JVM * pjvm, | |||
452 | const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr, | |||
453 | const css::uno::Reference<css::uno::XComponentContext> &xCtx) throw(css::uno::Exception) | |||
454 | { | |||
455 | css::uno::Reference<css::uno::XInterface> xConfRegistry = | |||
456 | xSMgr->createInstanceWithContext( | |||
457 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.configuration.ConfigurationRegistry")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationRegistry" ) / sizeof (("com.sun.star.configuration.ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
458 | "com.sun.star.configuration.ConfigurationRegistry")(&("com.sun.star.configuration.ConfigurationRegistry")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationRegistry" ) / sizeof (("com.sun.star.configuration.ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
459 | xCtx); | |||
460 | if(!xConfRegistry.is()) | |||
461 | throw css::uno::RuntimeException( | |||
462 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")(&("javavm.cxx: couldn't get ConfigurationRegistry")[0]), ((sal_Int32)((sizeof ("javavm.cxx: couldn't get ConfigurationRegistry" ) / sizeof (("javavm.cxx: couldn't get ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
463 | ||||
464 | css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple( | |||
465 | xConfRegistry, css::uno::UNO_QUERY); | |||
466 | if(!xConfRegistry_simple.is()) | |||
467 | throw css::uno::RuntimeException( | |||
468 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")(&("javavm.cxx: couldn't get ConfigurationRegistry")[0]), ((sal_Int32)((sizeof ("javavm.cxx: couldn't get ConfigurationRegistry" ) / sizeof (("javavm.cxx: couldn't get ConfigurationRegistry" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
469 | ||||
470 | xConfRegistry_simple->open( | |||
471 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Java")(&("org.openoffice.Office.Java")[0]), ((sal_Int32)((sizeof ("org.openoffice.Office.Java") / sizeof (("org.openoffice.Office.Java" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
472 | sal_True((sal_Bool)1), sal_False((sal_Bool)0)); | |||
473 | css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = | |||
474 | xConfRegistry_simple->getRootKey(); | |||
475 | ||||
476 | if (xRegistryRootKey.is()) | |||
477 | { | |||
478 | css::uno::Reference<css::registry::XRegistryKey> key_NetAccess= xRegistryRootKey->openKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VirtualMachine/NetAccess")(&("VirtualMachine/NetAccess")[0]), ((sal_Int32)((sizeof ( "VirtualMachine/NetAccess") / sizeof (("VirtualMachine/NetAccess" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
479 | if (key_NetAccess.is()) | |||
480 | { | |||
481 | sal_Int32 val= key_NetAccess->getLongValue(); | |||
482 | rtl::OUString sVal; | |||
483 | switch( val) | |||
484 | { | |||
485 | case 0: sVal= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("host")(&("host")[0]), ((sal_Int32)((sizeof ("host") / sizeof (( "host")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
486 | break; | |||
487 | case 1: sVal= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unrestricted")(&("unrestricted")[0]), ((sal_Int32)((sizeof ("unrestricted" ) / sizeof (("unrestricted")[0]))-1)), (((rtl_TextEncoding) 11 ))); | |||
488 | break; | |||
489 | case 3: sVal= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("none")(&("none")[0]), ((sal_Int32)((sizeof ("none") / sizeof (( "none")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
490 | break; | |||
491 | } | |||
492 | rtl::OUString sProperty( RTL_CONSTASCII_USTRINGPARAM("appletviewer.security.mode=")(&("appletviewer.security.mode=")[0]), ((sal_Int32)((sizeof ("appletviewer.security.mode=") / sizeof (("appletviewer.security.mode=" )[0]))-1)), (((rtl_TextEncoding) 11))); | |||
493 | sProperty= sProperty + sVal; | |||
494 | pjvm->pushProp(sProperty); | |||
495 | } | |||
496 | css::uno::Reference<css::registry::XRegistryKey> key_CheckSecurity= xRegistryRootKey->openKey( | |||
497 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VirtualMachine/Security")(&("VirtualMachine/Security")[0]), ((sal_Int32)((sizeof ( "VirtualMachine/Security") / sizeof (("VirtualMachine/Security" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
498 | if( key_CheckSecurity.is()) | |||
499 | { | |||
500 | sal_Bool val= (sal_Bool) key_CheckSecurity->getLongValue(); | |||
501 | rtl::OUString sProperty(RTL_CONSTASCII_USTRINGPARAM("stardiv.security.disableSecurity=")(&("stardiv.security.disableSecurity=")[0]), ((sal_Int32) ((sizeof ("stardiv.security.disableSecurity=") / sizeof (("stardiv.security.disableSecurity=" )[0]))-1)), (((rtl_TextEncoding) 11))); | |||
502 | if( val) | |||
503 | sProperty= sProperty + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("false")(&("false")[0]), ((sal_Int32)((sizeof ("false") / sizeof ( ("false")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
504 | else | |||
505 | sProperty= sProperty + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("true")(&("true")[0]), ((sal_Int32)((sizeof ("true") / sizeof (( "true")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
506 | pjvm->pushProp( sProperty); | |||
507 | } | |||
508 | } | |||
509 | xConfRegistry_simple->close(); | |||
510 | } | |||
511 | ||||
512 | static void setTimeZone(stoc_javavm::JVM * pjvm) throw() { | |||
513 | /* A Bug in the Java function | |||
514 | ** struct Hjava_util_Properties * java_lang_System_initProperties( | |||
515 | ** struct Hjava_lang_System *this, | |||
516 | ** struct Hjava_util_Properties *props); | |||
517 | ** This function doesn't detect MEZ, MET or "W. Europe Standard Time" | |||
518 | */ | |||
519 | struct tm *tmData; | |||
520 | time_t clock = time(NULL__null); | |||
521 | tzset(); | |||
522 | tmData = localtime(&clock); | |||
523 | #ifdef MACOSX | |||
524 | char * p = tmData->tm_zone; | |||
525 | #else | |||
526 | char * p = tzname[0]; | |||
527 | (void)tmData; | |||
528 | #endif | |||
529 | ||||
530 | if (!strcmp(TIMEZONE"MEZ", p)) | |||
531 | pjvm->pushProp(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user.timezone=ECT")(&("user.timezone=ECT")[0]), ((sal_Int32)((sizeof ("user.timezone=ECT" ) / sizeof (("user.timezone=ECT")[0]))-1)), (((rtl_TextEncoding ) 11)))); | |||
532 | } | |||
533 | ||||
534 | void initVMConfiguration( | |||
535 | stoc_javavm::JVM * pjvm, | |||
536 | const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr, | |||
537 | const css::uno::Reference<css::uno::XComponentContext > &xCtx) throw(css::uno::Exception) | |||
538 | { | |||
539 | stoc_javavm::JVM jvm; | |||
540 | try { | |||
541 | getINetPropsFromConfig(&jvm, xSMgr, xCtx); | |||
542 | } | |||
543 | catch(const css::uno::Exception & exception) { | |||
544 | #if OSL_DEBUG_LEVEL1 > 1 | |||
545 | rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))); | |||
546 | OSL_TRACE("javavm.cxx: can not get INetProps cause of >%s<", message.getStr())do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "546" ": "), "javavm.cxx: can not get INetProps cause of >%s<" , message.getStr()); } } while (false); | |||
547 | #else | |||
548 | (void) exception; // unused | |||
549 | #endif | |||
550 | } | |||
551 | ||||
552 | try { | |||
553 | getDefaultLocaleFromConfig(&jvm, xSMgr,xCtx); | |||
554 | } | |||
555 | catch(const css::uno::Exception & exception) { | |||
556 | #if OSL_DEBUG_LEVEL1 > 1 | |||
557 | rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))); | |||
558 | OSL_TRACE("javavm.cxx: can not get locale cause of >%s<", message.getStr())do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "558" ": "), "javavm.cxx: can not get locale cause of >%s<" , message.getStr()); } } while (false); | |||
559 | #else | |||
560 | (void) exception; // unused | |||
561 | #endif | |||
562 | } | |||
563 | ||||
564 | try | |||
565 | { | |||
566 | getJavaPropsFromSafetySettings(&jvm, xSMgr, xCtx); | |||
567 | } | |||
568 | catch(const css::uno::Exception & exception) { | |||
569 | #if OSL_DEBUG_LEVEL1 > 1 | |||
570 | rtl::OString message = rtl::OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))); | |||
571 | OSL_TRACE("javavm.cxx: couldn't get safety settings because of >%s<", message.getStr())do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "571" ": "), "javavm.cxx: couldn't get safety settings because of >%s<" , message.getStr()); } } while (false); | |||
572 | #else | |||
573 | (void) exception; // unused | |||
574 | #endif | |||
575 | } | |||
576 | ||||
577 | *pjvm= jvm; | |||
578 | setTimeZone(pjvm); | |||
579 | ||||
580 | } | |||
581 | ||||
582 | class DetachCurrentThread { | |||
583 | public: | |||
584 | explicit DetachCurrentThread(JavaVM * jvm): m_jvm(jvm) {} | |||
585 | ||||
586 | ~DetachCurrentThread() { | |||
587 | if (m_jvm->DetachCurrentThread() != 0) { | |||
588 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "588" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); | |||
589 | } | |||
590 | } | |||
591 | ||||
592 | private: | |||
593 | DetachCurrentThread(DetachCurrentThread &); // not defined | |||
594 | void operator =(DetachCurrentThread &); // not defined | |||
595 | ||||
596 | JavaVM * m_jvm; | |||
597 | }; | |||
598 | ||||
599 | } | |||
600 | ||||
601 | extern "C" SAL_DLLPUBLIC_EXPORT__attribute__ ((visibility("default"))) void * SAL_CALL component_getFactory(sal_Char const * pImplName, | |||
602 | void * pServiceManager, | |||
603 | void * pRegistryKey) | |||
604 | { | |||
605 | return cppu::component_getFactoryHelper(pImplName, pServiceManager, | |||
606 | pRegistryKey, | |||
607 | aServiceImplementation); | |||
608 | } | |||
609 | ||||
610 | // There is no component_canUnload, as the library cannot be unloaded. | |||
611 | ||||
612 | JavaVirtualMachine::JavaVirtualMachine( | |||
613 | css::uno::Reference< css::uno::XComponentContext > const & rContext): | |||
614 | JavaVirtualMachine_Impl(*static_cast< osl::Mutex * >(this)), | |||
615 | m_xContext(rContext), | |||
616 | m_bDisposed(false), | |||
617 | m_pJavaVm(0), | |||
618 | m_bDontCreateJvm(false), | |||
619 | m_aAttachGuards(destroyAttachGuards) // TODO check for validity | |||
620 | {} | |||
621 | ||||
622 | void SAL_CALL | |||
623 | JavaVirtualMachine::initialize(css::uno::Sequence< css::uno::Any > const & | |||
624 | rArguments) | |||
625 | throw (css::uno::Exception) | |||
626 | { | |||
627 | osl::MutexGuard aGuard(*this); | |||
628 | if (m_bDisposed) | |||
629 | throw css::lang::DisposedException( | |||
630 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
631 | if (m_xUnoVirtualMachine.is()) | |||
632 | throw css::uno::RuntimeException( | |||
633 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("bad call to initialize")[0]), ((sal_Int32)((sizeof ("bad call to initialize" ) / sizeof (("bad call to initialize")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
634 | "bad call to initialize")(&("bad call to initialize")[0]), ((sal_Int32)((sizeof ("bad call to initialize" ) / sizeof (("bad call to initialize")[0]))-1)), (((rtl_TextEncoding ) 11))), | |||
635 | static_cast< cppu::OWeakObject * >(this)); | |||
636 | css::beans::NamedValue val; | |||
637 | if (rArguments.getLength() == 1 && (rArguments[0] >>= val) && val.Name == "UnoVirtualMachine" ) | |||
638 | { | |||
639 | OSL_ENSURE(do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::UnoVirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "641" ": "), "%s", "Pointer cannot be represented as sal_Int64" ); } } while (false) | |||
640 | sizeof (sal_Int64) >= sizeof (jvmaccess::UnoVirtualMachine *),do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::UnoVirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "641" ": "), "%s", "Pointer cannot be represented as sal_Int64" ); } } while (false) | |||
641 | "Pointer cannot be represented as sal_Int64")do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::UnoVirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "641" ": "), "%s", "Pointer cannot be represented as sal_Int64" ); } } while (false); | |||
642 | sal_Int64 nPointer = reinterpret_cast< sal_Int64 >( | |||
643 | static_cast< jvmaccess::UnoVirtualMachine * >(0)); | |||
644 | val.Value >>= nPointer; | |||
645 | m_xUnoVirtualMachine = | |||
646 | reinterpret_cast< jvmaccess::UnoVirtualMachine * >(nPointer); | |||
647 | } else { | |||
648 | OSL_ENSURE(do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::VirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "650" ": "), "%s", "Pointer cannot be represented as sal_Int64" ); } } while (false) | |||
649 | sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *),do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::VirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "650" ": "), "%s", "Pointer cannot be represented as sal_Int64" ); } } while (false) | |||
650 | "Pointer cannot be represented as sal_Int64")do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::VirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "650" ": "), "%s", "Pointer cannot be represented as sal_Int64" ); } } while (false); | |||
651 | sal_Int64 nPointer = reinterpret_cast< sal_Int64 >( | |||
652 | static_cast< jvmaccess::VirtualMachine * >(0)); | |||
653 | if (rArguments.getLength() == 1) | |||
654 | rArguments[0] >>= nPointer; | |||
655 | rtl::Reference< jvmaccess::VirtualMachine > vm( | |||
656 | reinterpret_cast< jvmaccess::VirtualMachine * >(nPointer)); | |||
657 | if (vm.is()) { | |||
658 | try { | |||
659 | m_xUnoVirtualMachine = new jvmaccess::UnoVirtualMachine(vm, 0); | |||
660 | } catch (jvmaccess::UnoVirtualMachine::CreationException &) { | |||
661 | throw css::uno::RuntimeException( | |||
662 | rtl::OUString( | |||
663 | RTL_CONSTASCII_USTRINGPARAM((&("jvmaccess::UnoVirtualMachine::CreationException")[0]) , ((sal_Int32)((sizeof ("jvmaccess::UnoVirtualMachine::CreationException" ) / sizeof (("jvmaccess::UnoVirtualMachine::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
664 | "jvmaccess::UnoVirtualMachine::CreationException")(&("jvmaccess::UnoVirtualMachine::CreationException")[0]) , ((sal_Int32)((sizeof ("jvmaccess::UnoVirtualMachine::CreationException" ) / sizeof (("jvmaccess::UnoVirtualMachine::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
665 | static_cast< cppu::OWeakObject * >(this)); | |||
666 | } | |||
667 | } | |||
668 | } | |||
669 | if (!m_xUnoVirtualMachine.is()) { | |||
670 | throw css::lang::IllegalArgumentException( | |||
671 | rtl::OUString( | |||
672 | RTL_CONSTASCII_USTRINGPARAM((&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
673 | "sequence of exactly one any containing either (a) a"(&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
674 | " com.sun.star.beans.NamedValue with Name"(&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
675 | " \"UnoVirtualMachine\" and Value a hyper representing a"(&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
676 | " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)"(&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
677 | " a hyper representing a non-null pointer to a"(&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
678 | " jvmaccess::VirtualMachine required")(&("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]), ((sal_Int32)((sizeof ("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" ) / sizeof (("sequence of exactly one any containing either (a) a" " com.sun.star.beans.NamedValue with Name" " \"UnoVirtualMachine\" and Value a hyper representing a" " non-null pointer to a jvmaccess:UnoVirtualMachine, or (b)" " a hyper representing a non-null pointer to a" " jvmaccess::VirtualMachine required" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
679 | static_cast< cppu::OWeakObject * >(this), 0); | |||
680 | } | |||
681 | m_xVirtualMachine = m_xUnoVirtualMachine->getVirtualMachine(); | |||
682 | } | |||
683 | ||||
684 | rtl::OUString SAL_CALL JavaVirtualMachine::getImplementationName() | |||
685 | throw (css::uno::RuntimeException) | |||
686 | { | |||
687 | return serviceGetImplementationName(); | |||
688 | } | |||
689 | ||||
690 | sal_Bool SAL_CALL | |||
691 | JavaVirtualMachine::supportsService(rtl::OUString const & rServiceName) | |||
692 | throw (css::uno::RuntimeException) | |||
693 | { | |||
694 | css::uno::Sequence< rtl::OUString > aNames(getSupportedServiceNames()); | |||
695 | for (sal_Int32 i = 0; i < aNames.getLength(); ++i) | |||
696 | if (aNames[i] == rServiceName) | |||
697 | return true; | |||
698 | return false; | |||
699 | } | |||
700 | ||||
701 | css::uno::Sequence< rtl::OUString > SAL_CALL | |||
702 | JavaVirtualMachine::getSupportedServiceNames() | |||
703 | throw (css::uno::RuntimeException) | |||
704 | { | |||
705 | return serviceGetSupportedServiceNames(); | |||
706 | } | |||
707 | ||||
708 | css::uno::Any SAL_CALL | |||
709 | JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId) | |||
710 | throw (css::uno::RuntimeException) | |||
711 | { | |||
712 | osl::MutexGuard aGuard(*this); | |||
713 | if (m_bDisposed) | |||
| ||||
714 | throw css::lang::DisposedException( | |||
715 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
716 | css::uno::Sequence< sal_Int8 > aId(16); | |||
717 | rtl_getGlobalProcessId(reinterpret_cast< sal_uInt8 * >(aId.getArray())); | |||
718 | enum ReturnType { | |||
719 | RETURN_JAVAVM, RETURN_VIRTUALMACHINE, RETURN_UNOVIRTUALMACHINE }; | |||
720 | ReturnType returnType = | |||
721 | rProcessId.getLength() == 17 && rProcessId[16] == 0 | |||
722 | ? RETURN_VIRTUALMACHINE | |||
723 | : rProcessId.getLength() == 17 && rProcessId[16] == 1 | |||
724 | ? RETURN_UNOVIRTUALMACHINE | |||
725 | : RETURN_JAVAVM; | |||
726 | css::uno::Sequence< sal_Int8 > aProcessId(rProcessId); | |||
727 | if (returnType != RETURN_JAVAVM) | |||
728 | aProcessId.realloc(16); | |||
729 | if (aId != aProcessId) | |||
730 | return css::uno::Any(); | |||
731 | ||||
732 | while (!m_xVirtualMachine.is()) // retry until successful | |||
733 | { | |||
734 | // This is the second attempt to create Java. m_bDontCreateJvm is | |||
735 | // set which means instantiating the JVM might crash. | |||
736 | if (m_bDontCreateJvm) | |||
737 | //throw css::uno::RuntimeException(); | |||
738 | return css::uno::Any(); | |||
739 | ||||
740 | stoc_javavm::JVM aJvm; | |||
741 | initVMConfiguration(&aJvm, m_xContext->getServiceManager(), | |||
742 | m_xContext); | |||
743 | //Create the JavaVMOption array | |||
744 | const std::vector<rtl::OUString> & props = aJvm.getProperties(); | |||
745 | boost::scoped_array<JavaVMOption> sarOptions( | |||
746 | new JavaVMOption[props.size()]); | |||
747 | JavaVMOption * arOptions = sarOptions.get(); | |||
748 | //Create an array that contains the strings which are passed | |||
749 | //into the options | |||
750 | boost::scoped_array<rtl::OString> sarPropStrings( | |||
751 | new rtl::OString[props.size()]); | |||
752 | rtl::OString * arPropStrings = sarPropStrings.get(); | |||
753 | ||||
754 | rtl::OString sJavaOption("-"); | |||
755 | typedef std::vector<rtl::OUString>::const_iterator cit; | |||
756 | int index = 0; | |||
757 | for (cit i = props.begin(); i != props.end(); ++i) | |||
758 | { | |||
759 | rtl::OString sOption = rtl::OUStringToOString( | |||
760 | *i, osl_getThreadTextEncoding()); | |||
761 | ||||
762 | if (!sOption.matchIgnoreAsciiCase(sJavaOption, 0)) | |||
763 | arPropStrings[index]= rtl::OString("-D") + sOption; | |||
764 | else | |||
765 | arPropStrings[index] = sOption; | |||
766 | ||||
767 | arOptions[index].optionString = (sal_Char*)arPropStrings[index].getStr(); | |||
768 | arOptions[index].extraInfo = 0; | |||
769 | index ++; | |||
770 | } | |||
771 | ||||
772 | JNIEnv * pMainThreadEnv = 0; | |||
773 | javaFrameworkError errcode = JFW_E_NONE; | |||
774 | ||||
775 | if (getenv("STOC_FORCE_NO_JRE")) | |||
776 | errcode = JFW_E_NO_SELECT; | |||
777 | else | |||
778 | errcode = jfw_startVM(arOptions, index, & m_pJavaVm, | |||
779 | & pMainThreadEnv); | |||
780 | ||||
781 | bool bStarted = false; | |||
782 | switch (errcode) | |||
783 | { | |||
784 | case JFW_E_NONE: bStarted = true; break; | |||
785 | case JFW_E_NO_SELECT: | |||
786 | { | |||
787 | // No Java configured. We silenty run the java configuration | |||
788 | // Java. | |||
789 | javaFrameworkError errFind = jfw_findAndSelectJRE( NULL__null ); | |||
790 | if (getenv("STOC_FORCE_NO_JRE")) | |||
791 | errFind = JFW_E_NO_JAVA_FOUND; | |||
792 | if (errFind == JFW_E_NONE) | |||
793 | { | |||
794 | continue; | |||
795 | } | |||
796 | else if (errFind == JFW_E_NO_JAVA_FOUND) | |||
797 | { | |||
798 | ||||
799 | //Warning MessageBox: | |||
800 | //%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. | |||
801 | //Please install a JRE and restart %PRODUCTNAME. | |||
802 | css::java::JavaNotFoundException exc( | |||
803 | rtl::OUString( | |||
804 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
805 | "JavaVirtualMachine::getJavaVM failed because"(&("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
806 | " No suitable JRE found!")(&("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " No suitable JRE found!")[0]))-1)), (((rtl_TextEncoding) 11 ))), | |||
807 | static_cast< cppu::OWeakObject * >(this)); | |||
808 | askForRetry(css::uno::makeAny(exc)); | |||
809 | return css::uno::Any(); | |||
810 | } | |||
811 | else | |||
812 | { | |||
813 | //An unexpected error occurred | |||
814 | throw css::uno::RuntimeException( | |||
815 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!" )[0]), ((sal_Int32)((sizeof ("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!") / sizeof (("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
816 | "[JavaVirtualMachine]:An unexpected error occurred"(&("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!" )[0]), ((sal_Int32)((sizeof ("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!") / sizeof (("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
817 | " while searching for a Java!")(&("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!" )[0]), ((sal_Int32)((sizeof ("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!") / sizeof (("[JavaVirtualMachine]:An unexpected error occurred" " while searching for a Java!")[0]))-1)), (((rtl_TextEncoding ) 11))), 0); | |||
818 | } | |||
819 | } | |||
820 | case JFW_E_INVALID_SETTINGS: | |||
821 | { | |||
822 | //Warning MessageBox: | |||
823 | // The %PRODUCTNAME configuration has been changed. Under Tools | |||
824 | // - Options - %PRODUCTNAME - Java, select the Java runtime environment | |||
825 | // you want to have used by %PRODUCTNAME. | |||
826 | css::java::InvalidJavaSettingsException exc( | |||
827 | rtl::OUString( | |||
828 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
829 | "JavaVirtualMachine::getJavaVM failed because"(&("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
830 | " Java settings have changed!")(&("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java settings have changed!")[0]))-1)), (((rtl_TextEncoding ) 11))), | |||
831 | static_cast< cppu::OWeakObject * >(this)); | |||
832 | askForRetry(css::uno::makeAny(exc)); | |||
833 | return css::uno::Any(); | |||
834 | } | |||
835 | case JFW_E_JAVA_DISABLED: | |||
836 | { | |||
837 | //QueryBox: | |||
838 | //%PRODUCTNAME requires a Java runtime environment (JRE) to perform | |||
839 | //this task. However, use of a JRE has been disabled. Do you want to | |||
840 | //enable the use of a JRE now? | |||
841 | css::java::JavaDisabledException exc( | |||
842 | rtl::OUString( | |||
843 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
844 | "JavaVirtualMachine::getJavaVM failed because"(&("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
845 | " Java is disabled!")(&("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java is disabled!")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
846 | static_cast< cppu::OWeakObject * >(this)); | |||
847 | if( ! askForRetry(css::uno::makeAny(exc))) | |||
848 | return css::uno::Any(); | |||
849 | continue; | |||
850 | } | |||
851 | case JFW_E_VM_CREATION_FAILED: | |||
852 | { | |||
853 | //If the creation failed because the JRE has been uninstalled then | |||
854 | //we search another one. As long as there is a javaldx, we should | |||
855 | //never come into this situation. javaldx checks alway if the JRE | |||
856 | //still exist. | |||
857 | JavaInfo * pJavaInfo = NULL__null; | |||
858 | if (JFW_E_NONE == jfw_getSelectedJRE(&pJavaInfo)) | |||
859 | { | |||
860 | sal_Bool bExist = sal_False((sal_Bool)0); | |||
861 | if (JFW_E_NONE == jfw_existJRE(pJavaInfo, &bExist)) | |||
862 | { | |||
863 | if (bExist == sal_False((sal_Bool)0) | |||
864 | && ! (pJavaInfo->nRequirements & JFW_REQUIRE_NEEDRESTART0x1l)) | |||
865 | { | |||
866 | javaFrameworkError errFind = jfw_findAndSelectJRE( NULL__null ); | |||
867 | if (errFind == JFW_E_NONE) | |||
868 | { | |||
869 | continue; | |||
870 | } | |||
871 | } | |||
872 | } | |||
873 | } | |||
874 | ||||
875 | jfw_freeJavaInfo(pJavaInfo); | |||
876 | // | |||
877 | //Error: %PRODUCTNAME requires a Java | |||
878 | //runtime environment (JRE) to perform this task. The selected JRE | |||
879 | //is defective. Please select another version or install a new JRE | |||
880 | //and select it under Tools - Options - %PRODUCTNAME - Java. | |||
881 | css::java::JavaVMCreationFailureException exc( | |||
882 | rtl::OUString( | |||
883 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::getJavaVM failed because" " Java is defective!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java is defective!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java is defective!")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
884 | "JavaVirtualMachine::getJavaVM failed because"(&("JavaVirtualMachine::getJavaVM failed because" " Java is defective!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java is defective!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java is defective!")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
885 | " Java is defective!")(&("JavaVirtualMachine::getJavaVM failed because" " Java is defective!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" " Java is defective!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" " Java is defective!")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
886 | static_cast< cppu::OWeakObject * >(this), 0); | |||
887 | askForRetry(css::uno::makeAny(exc)); | |||
888 | return css::uno::Any(); | |||
889 | } | |||
890 | case JFW_E_RUNNING_JVM: | |||
891 | { | |||
892 | //This service should make sure that we do not start java twice. | |||
893 | OSL_ASSERT(0)do { if (true && (!(0))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "893" ": "), "OSL_ASSERT: %s", "0"); } } while (false); | |||
894 | break; | |||
895 | } | |||
896 | case JFW_E_NEED_RESTART: | |||
897 | { | |||
898 | //Error: | |||
899 | //For the selected Java runtime environment to work properly, | |||
900 | //%PRODUCTNAME must be restarted. Please restart %PRODUCTNAME now. | |||
901 | css::java::RestartRequiredException exc( | |||
902 | rtl::OUString( | |||
903 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
904 | "JavaVirtualMachine::getJavaVM failed because"(&("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
905 | "Office must be restarted before Java can be used!")(&("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!") / sizeof (("JavaVirtualMachine::getJavaVM failed because" "Office must be restarted before Java can be used!" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
906 | static_cast< cppu::OWeakObject * >(this)); | |||
907 | askForRetry(css::uno::makeAny(exc)); | |||
908 | return css::uno::Any(); | |||
909 | } | |||
910 | default: | |||
911 | //RuntimeException: error is somewhere in the java framework. | |||
912 | //An unexpected error occurred | |||
913 | throw css::uno::RuntimeException( | |||
914 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!" )[0]), ((sal_Int32)((sizeof ("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!") / sizeof (("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
915 | "[JavaVirtualMachine]:An unexpected error occurred"(&("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!" )[0]), ((sal_Int32)((sizeof ("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!") / sizeof (("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
916 | " while starting Java!")(&("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!" )[0]), ((sal_Int32)((sizeof ("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!") / sizeof (("[JavaVirtualMachine]:An unexpected error occurred" " while starting Java!")[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
917 | } | |||
918 | ||||
919 | if (bStarted) | |||
920 | { | |||
921 | { | |||
922 | DetachCurrentThread detach(m_pJavaVm); | |||
923 | // necessary to make debugging work; this thread will be | |||
924 | // suspended when the destructor of detach returns | |||
925 | m_xVirtualMachine = new jvmaccess::VirtualMachine( | |||
926 | m_pJavaVm, JNI_VERSION_1_20x00010002, true, pMainThreadEnv); | |||
927 | setUpUnoVirtualMachine(pMainThreadEnv); | |||
928 | } | |||
929 | // Listen for changes in the configuration (e.g. proxy settings): | |||
930 | // TODO this is done too late; changes to the configuration done | |||
931 | // after the above call to initVMConfiguration are lost | |||
932 | registerConfigChangesListener(); | |||
933 | ||||
934 | break; | |||
935 | } | |||
936 | } | |||
937 | if (!m_xUnoVirtualMachine.is()) { | |||
938 | try { | |||
939 | jvmaccess::VirtualMachine::AttachGuard guard(m_xVirtualMachine); | |||
940 | setUpUnoVirtualMachine(guard.getEnvironment()); | |||
941 | } catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) { | |||
942 | throw css::uno::RuntimeException( | |||
943 | rtl::OUString( | |||
944 | RTL_CONSTASCII_USTRINGPARAM((&("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred" )[0]), ((sal_Int32)((sizeof ("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred") / sizeof (("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
945 | "jvmaccess::VirtualMachine::AttachGuard::"(&("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred" )[0]), ((sal_Int32)((sizeof ("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred") / sizeof (("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
946 | "CreationException occurred")(&("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred" )[0]), ((sal_Int32)((sizeof ("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred") / sizeof (("jvmaccess::VirtualMachine::AttachGuard::" "CreationException occurred")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
947 | static_cast< cppu::OWeakObject * >(this)); | |||
948 | } | |||
949 | } | |||
950 | switch (returnType) { | |||
951 | default: // RETURN_JAVAVM | |||
952 | if (m_pJavaVm == 0) { | |||
953 | throw css::uno::RuntimeException( | |||
954 | rtl::OUString( | |||
955 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available") / sizeof (("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
956 | "JavaVirtualMachine service was initialized in a way"(&("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available") / sizeof (("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
957 | " that the requested JavaVM pointer is not available")(&("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available") / sizeof (("JavaVirtualMachine service was initialized in a way" " that the requested JavaVM pointer is not available" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
958 | static_cast< cppu::OWeakObject * >(this)); | |||
959 | } | |||
960 | return css::uno::makeAny(reinterpret_cast< sal_IntPtr >(m_pJavaVm)); | |||
961 | case RETURN_VIRTUALMACHINE: | |||
962 | OSL_ASSERT(sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *))do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::VirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "962" ": "), "OSL_ASSERT: %s", "sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *)" ); } } while (false); | |||
963 | return css::uno::makeAny( | |||
964 | reinterpret_cast< sal_Int64 >( | |||
965 | m_xUnoVirtualMachine->getVirtualMachine().get())); | |||
966 | case RETURN_UNOVIRTUALMACHINE: | |||
967 | OSL_ASSERT(sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *))do { if (true && (!(sizeof (sal_Int64) >= sizeof ( jvmaccess::VirtualMachine *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "967" ": "), "OSL_ASSERT: %s", "sizeof (sal_Int64) >= sizeof (jvmaccess::VirtualMachine *)" ); } } while (false); | |||
968 | return css::uno::makeAny( | |||
969 | reinterpret_cast< sal_Int64 >(m_xUnoVirtualMachine.get())); | |||
970 | } | |||
971 | } | |||
972 | ||||
973 | sal_Bool SAL_CALL JavaVirtualMachine::isVMStarted() | |||
974 | throw (css::uno::RuntimeException) | |||
975 | { | |||
976 | osl::MutexGuard aGuard(*this); | |||
977 | if (m_bDisposed) | |||
978 | throw css::lang::DisposedException( | |||
979 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
980 | return m_xUnoVirtualMachine.is(); | |||
981 | } | |||
982 | ||||
983 | sal_Bool SAL_CALL JavaVirtualMachine::isVMEnabled() | |||
984 | throw (css::uno::RuntimeException) | |||
985 | { | |||
986 | { | |||
987 | osl::MutexGuard aGuard(*this); | |||
988 | if (m_bDisposed) | |||
989 | throw css::lang::DisposedException( | |||
990 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
991 | } | |||
992 | // stoc_javavm::JVM aJvm; | |||
993 | // initVMConfiguration(&aJvm, m_xContext->getServiceManager(), m_xContext); | |||
994 | // return aJvm.isEnabled(); | |||
995 | //ToDo | |||
996 | sal_Bool bEnabled = sal_False((sal_Bool)0); | |||
997 | if (jfw_getEnabled( & bEnabled) != JFW_E_NONE) | |||
998 | throw css::uno::RuntimeException(); | |||
999 | return bEnabled; | |||
1000 | } | |||
1001 | ||||
1002 | sal_Bool SAL_CALL JavaVirtualMachine::isThreadAttached() | |||
1003 | throw (css::uno::RuntimeException) | |||
1004 | { | |||
1005 | osl::MutexGuard aGuard(*this); | |||
1006 | if (m_bDisposed) | |||
1007 | throw css::lang::DisposedException( | |||
1008 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
1009 | // TODO isThreadAttached only returns true if the thread was attached via | |||
1010 | // registerThread: | |||
1011 | GuardStack * pStack | |||
1012 | = static_cast< GuardStack * >(m_aAttachGuards.getData()); | |||
1013 | return pStack != 0 && !pStack->empty(); | |||
1014 | } | |||
1015 | ||||
1016 | void SAL_CALL JavaVirtualMachine::registerThread() | |||
1017 | throw (css::uno::RuntimeException) | |||
1018 | { | |||
1019 | osl::MutexGuard aGuard(*this); | |||
1020 | if (m_bDisposed) | |||
1021 | throw css::lang::DisposedException( | |||
1022 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
1023 | if (!m_xUnoVirtualMachine.is()) | |||
1024 | throw css::uno::RuntimeException( | |||
1025 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::registerThread:" " null VirtualMachine" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::registerThread:" " null VirtualMachine") / sizeof (("JavaVirtualMachine::registerThread:" " null VirtualMachine")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1026 | "JavaVirtualMachine::registerThread:"(&("JavaVirtualMachine::registerThread:" " null VirtualMachine" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::registerThread:" " null VirtualMachine") / sizeof (("JavaVirtualMachine::registerThread:" " null VirtualMachine")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1027 | " null VirtualMachine")(&("JavaVirtualMachine::registerThread:" " null VirtualMachine" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::registerThread:" " null VirtualMachine") / sizeof (("JavaVirtualMachine::registerThread:" " null VirtualMachine")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1028 | static_cast< cppu::OWeakObject * >(this)); | |||
1029 | GuardStack * pStack | |||
1030 | = static_cast< GuardStack * >(m_aAttachGuards.getData()); | |||
1031 | if (pStack == 0) | |||
1032 | { | |||
1033 | pStack = new GuardStack; | |||
1034 | m_aAttachGuards.setData(pStack); | |||
1035 | } | |||
1036 | try | |||
1037 | { | |||
1038 | pStack->push( | |||
1039 | new jvmaccess::VirtualMachine::AttachGuard( | |||
1040 | m_xUnoVirtualMachine->getVirtualMachine())); | |||
1041 | } | |||
1042 | catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) | |||
1043 | { | |||
1044 | throw css::uno::RuntimeException( | |||
1045 | rtl::OUString( | |||
1046 | RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException") / sizeof ( ("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1047 | "JavaVirtualMachine::registerThread: jvmaccess::"(&("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException") / sizeof ( ("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1048 | "VirtualMachine::AttachGuard::CreationException")(&("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException") / sizeof ( ("JavaVirtualMachine::registerThread: jvmaccess::" "VirtualMachine::AttachGuard::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1049 | static_cast< cppu::OWeakObject * >(this)); | |||
1050 | } | |||
1051 | } | |||
1052 | ||||
1053 | void SAL_CALL JavaVirtualMachine::revokeThread() | |||
1054 | throw (css::uno::RuntimeException) | |||
1055 | { | |||
1056 | osl::MutexGuard aGuard(*this); | |||
1057 | if (m_bDisposed) | |||
1058 | throw css::lang::DisposedException( | |||
1059 | rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); | |||
1060 | if (!m_xUnoVirtualMachine.is()) | |||
1061 | throw css::uno::RuntimeException( | |||
1062 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::revokeThread:" " null VirtualMachine" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::revokeThread:" " null VirtualMachine") / sizeof (("JavaVirtualMachine::revokeThread:" " null VirtualMachine")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1063 | "JavaVirtualMachine::revokeThread:"(&("JavaVirtualMachine::revokeThread:" " null VirtualMachine" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::revokeThread:" " null VirtualMachine") / sizeof (("JavaVirtualMachine::revokeThread:" " null VirtualMachine")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1064 | " null VirtualMachine")(&("JavaVirtualMachine::revokeThread:" " null VirtualMachine" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::revokeThread:" " null VirtualMachine") / sizeof (("JavaVirtualMachine::revokeThread:" " null VirtualMachine")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1065 | static_cast< cppu::OWeakObject * >(this)); | |||
1066 | GuardStack * pStack | |||
1067 | = static_cast< GuardStack * >(m_aAttachGuards.getData()); | |||
1068 | if (pStack == 0 || pStack->empty()) | |||
1069 | throw css::uno::RuntimeException( | |||
1070 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("JavaVirtualMachine::revokeThread:" " no matching registerThread" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::revokeThread:" " no matching registerThread") / sizeof (("JavaVirtualMachine::revokeThread:" " no matching registerThread")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
1071 | "JavaVirtualMachine::revokeThread:"(&("JavaVirtualMachine::revokeThread:" " no matching registerThread" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::revokeThread:" " no matching registerThread") / sizeof (("JavaVirtualMachine::revokeThread:" " no matching registerThread")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
1072 | " no matching registerThread")(&("JavaVirtualMachine::revokeThread:" " no matching registerThread" )[0]), ((sal_Int32)((sizeof ("JavaVirtualMachine::revokeThread:" " no matching registerThread") / sizeof (("JavaVirtualMachine::revokeThread:" " no matching registerThread")[0]))-1)), (((rtl_TextEncoding ) 11))), | |||
1073 | static_cast< cppu::OWeakObject * >(this)); | |||
1074 | delete pStack->top(); | |||
1075 | pStack->pop(); | |||
1076 | } | |||
1077 | ||||
1078 | void SAL_CALL | |||
1079 | JavaVirtualMachine::disposing(css::lang::EventObject const & rSource) | |||
1080 | throw (css::uno::RuntimeException) | |||
1081 | { | |||
1082 | osl::MutexGuard aGuard(*this); | |||
1083 | if (rSource.Source == m_xInetConfiguration) | |||
1084 | m_xInetConfiguration.clear(); | |||
1085 | if (rSource.Source == m_xJavaConfiguration) | |||
1086 | m_xJavaConfiguration.clear(); | |||
1087 | } | |||
1088 | ||||
1089 | void SAL_CALL JavaVirtualMachine::elementInserted( | |||
1090 | css::container::ContainerEvent const &) | |||
1091 | throw (css::uno::RuntimeException) | |||
1092 | {} | |||
1093 | ||||
1094 | void SAL_CALL JavaVirtualMachine::elementRemoved( | |||
1095 | css::container::ContainerEvent const &) | |||
1096 | throw (css::uno::RuntimeException) | |||
1097 | {} | |||
1098 | ||||
1099 | // If a user changes the setting, for example for proxy settings, then this | |||
1100 | // function will be called from the configuration manager. Even if the .xml | |||
1101 | // file does not contain an entry yet and that entry has to be inserted, this | |||
1102 | // function will be called. We call java.lang.System.setProperty for the new | |||
1103 | // values. | |||
1104 | void SAL_CALL JavaVirtualMachine::elementReplaced( | |||
1105 | css::container::ContainerEvent const & rEvent) | |||
1106 | throw (css::uno::RuntimeException) | |||
1107 | { | |||
1108 | // TODO Using the new value stored in rEvent is wrong here. If two threads | |||
1109 | // receive different elementReplaced calls in quick succession, it is | |||
1110 | // unspecified which changes the JVM's system properties last. A correct | |||
1111 | // solution must atomically (i.e., protected by a mutex) read the latest | |||
1112 | // value from the configuration and set it as a system property at the JVM. | |||
1113 | ||||
1114 | rtl::OUString aAccessor; | |||
1115 | rEvent.Accessor >>= aAccessor; | |||
1116 | rtl::OUString aPropertyName; | |||
1117 | rtl::OUString aPropertyName2; | |||
1118 | rtl::OUString aPropertyValue; | |||
1119 | bool bSecurityChanged = false; | |||
1120 | if ( aAccessor == "ooInetProxyType" ) | |||
1121 | { | |||
1122 | // Proxy none, manually | |||
1123 | sal_Int32 value = 0; | |||
1124 | rEvent.Element >>= value; | |||
1125 | setINetSettingsInVM(value != 0); | |||
1126 | return; | |||
1127 | } | |||
1128 | else if ( aAccessor == "ooInetHTTPProxyName" ) | |||
1129 | { | |||
1130 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("http.proxyHost")[0]), ((sal_Int32)((sizeof ("http.proxyHost" ) / sizeof (("http.proxyHost")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1131 | "http.proxyHost")(&("http.proxyHost")[0]), ((sal_Int32)((sizeof ("http.proxyHost" ) / sizeof (("http.proxyHost")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1132 | rEvent.Element >>= aPropertyValue; | |||
1133 | } | |||
1134 | else if ( aAccessor == "ooInetHTTPProxyPort" ) | |||
1135 | { | |||
1136 | aPropertyName | |||
1137 | = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort")(&("http.proxyPort")[0]), ((sal_Int32)((sizeof ("http.proxyPort" ) / sizeof (("http.proxyPort")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1138 | sal_Int32 n = 0; | |||
1139 | rEvent.Element >>= n; | |||
1140 | aPropertyValue = rtl::OUString::valueOf(n); | |||
1141 | } | |||
1142 | else if ( aAccessor == "ooInetHTTPSProxyName" ) | |||
1143 | { | |||
1144 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("https.proxyHost")[0]), ((sal_Int32)((sizeof ("https.proxyHost" ) / sizeof (("https.proxyHost")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
1145 | "https.proxyHost")(&("https.proxyHost")[0]), ((sal_Int32)((sizeof ("https.proxyHost" ) / sizeof (("https.proxyHost")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
1146 | rEvent.Element >>= aPropertyValue; | |||
1147 | } | |||
1148 | else if ( aAccessor == "ooInetHTTPSProxyPort" ) | |||
1149 | { | |||
1150 | aPropertyName | |||
1151 | = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https.proxyPort")(&("https.proxyPort")[0]), ((sal_Int32)((sizeof ("https.proxyPort" ) / sizeof (("https.proxyPort")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
1152 | sal_Int32 n = 0; | |||
1153 | rEvent.Element >>= n; | |||
1154 | aPropertyValue = rtl::OUString::valueOf(n); | |||
1155 | } | |||
1156 | else if ( aAccessor == "ooInetFTPProxyName" ) | |||
1157 | { | |||
1158 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("ftp.proxyHost")[0]), ((sal_Int32)((sizeof ("ftp.proxyHost" ) / sizeof (("ftp.proxyHost")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
1159 | "ftp.proxyHost")(&("ftp.proxyHost")[0]), ((sal_Int32)((sizeof ("ftp.proxyHost" ) / sizeof (("ftp.proxyHost")[0]))-1)), (((rtl_TextEncoding) 11 ))); | |||
1160 | rEvent.Element >>= aPropertyValue; | |||
1161 | } | |||
1162 | else if ( aAccessor == "ooInetFTPProxyPort" ) | |||
1163 | { | |||
1164 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("ftp.proxyPort")[0]), ((sal_Int32)((sizeof ("ftp.proxyPort" ) / sizeof (("ftp.proxyPort")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
1165 | "ftp.proxyPort")(&("ftp.proxyPort")[0]), ((sal_Int32)((sizeof ("ftp.proxyPort" ) / sizeof (("ftp.proxyPort")[0]))-1)), (((rtl_TextEncoding) 11 ))); | |||
1166 | sal_Int32 n = 0; | |||
1167 | rEvent.Element >>= n; | |||
1168 | aPropertyValue = rtl::OUString::valueOf(n); | |||
1169 | } | |||
1170 | else if ( aAccessor == "ooInetNoProxy" ) | |||
1171 | { | |||
1172 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("http.nonProxyHosts")[0]), ((sal_Int32)((sizeof ("http.nonProxyHosts" ) / sizeof (("http.nonProxyHosts")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
1173 | "http.nonProxyHosts")(&("http.nonProxyHosts")[0]), ((sal_Int32)((sizeof ("http.nonProxyHosts" ) / sizeof (("http.nonProxyHosts")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
1174 | aPropertyName2 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("ftp.nonProxyHosts")[0]), ((sal_Int32)((sizeof ("ftp.nonProxyHosts" ) / sizeof (("ftp.nonProxyHosts")[0]))-1)), (((rtl_TextEncoding ) 11)) | |||
1175 | "ftp.nonProxyHosts")(&("ftp.nonProxyHosts")[0]), ((sal_Int32)((sizeof ("ftp.nonProxyHosts" ) / sizeof (("ftp.nonProxyHosts")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
1176 | rEvent.Element >>= aPropertyValue; | |||
1177 | aPropertyValue = aPropertyValue.replace(';', '|'); | |||
1178 | } | |||
1179 | else if ( aAccessor == "NetAccess" ) | |||
1180 | { | |||
1181 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("appletviewer.security.mode")[0]), ((sal_Int32)((sizeof ("appletviewer.security.mode") / sizeof (("appletviewer.security.mode" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1182 | "appletviewer.security.mode")(&("appletviewer.security.mode")[0]), ((sal_Int32)((sizeof ("appletviewer.security.mode") / sizeof (("appletviewer.security.mode" )[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1183 | sal_Int32 n = 0; | |||
1184 | if (rEvent.Element >>= n) | |||
1185 | switch (n) | |||
1186 | { | |||
1187 | case 0: | |||
1188 | aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("host")[0]), ((sal_Int32)((sizeof ("host") / sizeof (( "host")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1189 | "host")(&("host")[0]), ((sal_Int32)((sizeof ("host") / sizeof (( "host")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1190 | break; | |||
1191 | case 1: | |||
1192 | aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("unrestricted")[0]), ((sal_Int32)((sizeof ("unrestricted" ) / sizeof (("unrestricted")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
1193 | "unrestricted")(&("unrestricted")[0]), ((sal_Int32)((sizeof ("unrestricted" ) / sizeof (("unrestricted")[0]))-1)), (((rtl_TextEncoding) 11 ))); | |||
1194 | break; | |||
1195 | case 3: | |||
1196 | aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("none")[0]), ((sal_Int32)((sizeof ("none") / sizeof (( "none")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1197 | "none")(&("none")[0]), ((sal_Int32)((sizeof ("none") / sizeof (( "none")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1198 | break; | |||
1199 | } | |||
1200 | else | |||
1201 | return; | |||
1202 | bSecurityChanged = true; | |||
1203 | } | |||
1204 | else if ( aAccessor == "Security" ) | |||
1205 | { | |||
1206 | aPropertyName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("stardiv.security.disableSecurity")[0]), ((sal_Int32)( (sizeof ("stardiv.security.disableSecurity") / sizeof (("stardiv.security.disableSecurity" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1207 | "stardiv.security.disableSecurity")(&("stardiv.security.disableSecurity")[0]), ((sal_Int32)( (sizeof ("stardiv.security.disableSecurity") / sizeof (("stardiv.security.disableSecurity" )[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1208 | sal_Bool b = sal_Bool(); | |||
1209 | if (rEvent.Element >>= b) | |||
1210 | if (b) | |||
1211 | aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("false")[0]), ((sal_Int32)((sizeof ("false") / sizeof ( ("false")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1212 | "false")(&("false")[0]), ((sal_Int32)((sizeof ("false") / sizeof ( ("false")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1213 | else | |||
1214 | aPropertyValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("true")[0]), ((sal_Int32)((sizeof ("true") / sizeof (( "true")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1215 | "true")(&("true")[0]), ((sal_Int32)((sizeof ("true") / sizeof (( "true")[0]))-1)), (((rtl_TextEncoding) 11))); | |||
1216 | else | |||
1217 | return; | |||
1218 | bSecurityChanged = true; | |||
1219 | } | |||
1220 | else | |||
1221 | return; | |||
1222 | ||||
1223 | rtl::Reference< jvmaccess::VirtualMachine > xVirtualMachine; | |||
1224 | { | |||
1225 | osl::MutexGuard aGuard(*this); | |||
1226 | if (m_xUnoVirtualMachine.is()) { | |||
1227 | xVirtualMachine = m_xUnoVirtualMachine->getVirtualMachine(); | |||
1228 | } | |||
1229 | } | |||
1230 | if (xVirtualMachine.is()) | |||
1231 | { | |||
1232 | try | |||
1233 | { | |||
1234 | jvmaccess::VirtualMachine::AttachGuard aAttachGuard( | |||
1235 | xVirtualMachine); | |||
1236 | JNIEnv * pJNIEnv = aAttachGuard.getEnvironment(); | |||
1237 | ||||
1238 | // call java.lang.System.setProperty | |||
1239 | // String setProperty( String key, String value) | |||
1240 | jclass jcSystem= pJNIEnv->FindClass("java/lang/System"); | |||
1241 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/lang/System")(&("JNI:FindClass java/lang/System")[0]), ((sal_Int32)((sizeof ("JNI:FindClass java/lang/System") / sizeof (("JNI:FindClass java/lang/System" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1242 | jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); | |||
1243 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.setProperty")(&("JNI:GetStaticMethodID java.lang.System.setProperty")[ 0]), ((sal_Int32)((sizeof ("JNI:GetStaticMethodID java.lang.System.setProperty" ) / sizeof (("JNI:GetStaticMethodID java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1244 | ||||
1245 | jstring jsPropName= pJNIEnv->NewString( aPropertyName.getStr(), aPropertyName.getLength()); | |||
1246 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1247 | ||||
1248 | // remove the property if it does not have a value ( user left the dialog field empty) | |||
1249 | // or if the port is set to 0 | |||
1250 | aPropertyValue= aPropertyValue.trim(); | |||
1251 | if( aPropertyValue.isEmpty() || | |||
1252 | ( ( aPropertyName == "ftp.proxyPort" || aPropertyName == "http.proxyPort" /*|| aPropertyName == "socksProxyPort"*/ ) && aPropertyValue == "0" ) | |||
1253 | ) | |||
1254 | { | |||
1255 | // call java.lang.System.getProperties | |||
1256 | jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;"); | |||
1257 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.getProperties")(&("JNI:GetStaticMethodID java.lang.System.getProperties" )[0]), ((sal_Int32)((sizeof ("JNI:GetStaticMethodID java.lang.System.getProperties" ) / sizeof (("JNI:GetStaticMethodID java.lang.System.getProperties" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1258 | jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps); | |||
1259 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.getProperties")(&("JNI:CallStaticObjectMethod java.lang.System.getProperties" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.getProperties" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.getProperties" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1260 | // call java.util.Properties.remove | |||
1261 | jclass jcProperties= pJNIEnv->FindClass("java/util/Properties"); | |||
1262 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/util/Properties")(&("JNI:FindClass java/util/Properties")[0]), ((sal_Int32 )((sizeof ("JNI:FindClass java/util/Properties") / sizeof (("JNI:FindClass java/util/Properties" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1263 | jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;"); | |||
1264 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID java.util.Properties.remove")(&("JNI:GetMethodID java.util.Properties.remove")[0]), (( sal_Int32)((sizeof ("JNI:GetMethodID java.util.Properties.remove" ) / sizeof (("JNI:GetMethodID java.util.Properties.remove")[0 ]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1265 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName); | |||
1266 | ||||
1267 | // special calse for ftp.nonProxyHosts and http.nonProxyHosts. The office only | |||
1268 | // has a value for two java properties | |||
1269 | if (!aPropertyName2.isEmpty()) | |||
1270 | { | |||
1271 | jstring jsPropName2= pJNIEnv->NewString( aPropertyName2.getStr(), aPropertyName2.getLength()); | |||
1272 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1273 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName2); | |||
1274 | } | |||
1275 | } | |||
1276 | else | |||
1277 | { | |||
1278 | // Change the Value of the property | |||
1279 | jstring jsPropValue= pJNIEnv->NewString( aPropertyValue.getStr(), aPropertyValue.getLength()); | |||
1280 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1281 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue); | |||
1282 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1283 | ||||
1284 | // special calse for ftp.nonProxyHosts and http.nonProxyHosts. The office only | |||
1285 | // has a value for two java properties | |||
1286 | if (!aPropertyName2.isEmpty()) | |||
1287 | { | |||
1288 | jstring jsPropName2= pJNIEnv->NewString( aPropertyName2.getStr(), aPropertyName2.getLength()); | |||
1289 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1290 | jsPropValue= pJNIEnv->NewString( aPropertyValue.getStr(), aPropertyValue.getLength()); | |||
1291 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1292 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName2, jsPropValue); | |||
1293 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1294 | } | |||
1295 | } | |||
1296 | ||||
1297 | // If the settings for Security and NetAccess changed then we have to notify the SandboxSecurity | |||
1298 | // SecurityManager | |||
1299 | // call System.getSecurityManager() | |||
1300 | if (bSecurityChanged) | |||
1301 | { | |||
1302 | jmethodID jmGetSecur= pJNIEnv->GetStaticMethodID( jcSystem,"getSecurityManager","()Ljava/lang/SecurityManager;"); | |||
1303 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.getSecurityManager")(&("JNI:GetStaticMethodID java.lang.System.getSecurityManager" )[0]), ((sal_Int32)((sizeof ("JNI:GetStaticMethodID java.lang.System.getSecurityManager" ) / sizeof (("JNI:GetStaticMethodID java.lang.System.getSecurityManager" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1304 | jobject joSecur= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetSecur); | |||
1305 | if (joSecur != 0) | |||
1306 | { | |||
1307 | // Make sure the SecurityManager is our SandboxSecurity | |||
1308 | // FindClass("com.sun.star.lib.sandbox.SandboxSecurityManager" only worked at the first time | |||
1309 | // this code was executed. Maybe it is a security feature. However, all attempts to debug the | |||
1310 | // SandboxSecurity class (maybe the VM invokes checkPackageAccess) failed. | |||
1311 | // jclass jcSandboxSec= pJNIEnv->FindClass("com.sun.star.lib.sandbox.SandboxSecurity"); | |||
1312 | // if(pJNIEnv->ExceptionOccurred()) throw RuntimeException(OUSTR("JNI:FindClass com.sun.star.lib.sandbox.SandboxSecurity"), Reference<XInterface>()); | |||
1313 | // jboolean bIsSand= pJNIEnv->IsInstanceOf( joSecur, jcSandboxSec); | |||
1314 | // The SecurityManagers class Name must be com.sun.star.lib.sandbox.SandboxSecurity | |||
1315 | jclass jcSec= pJNIEnv->GetObjectClass( joSecur); | |||
1316 | jclass jcClass= pJNIEnv->FindClass("java/lang/Class"); | |||
1317 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java.lang.Class")(&("JNI:FindClass java.lang.Class")[0]), ((sal_Int32)((sizeof ("JNI:FindClass java.lang.Class") / sizeof (("JNI:FindClass java.lang.Class" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1318 | jmethodID jmName= pJNIEnv->GetMethodID( jcClass,"getName","()Ljava/lang/String;"); | |||
1319 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID java.lang.Class.getName")(&("JNI:GetMethodID java.lang.Class.getName")[0]), ((sal_Int32 )((sizeof ("JNI:GetMethodID java.lang.Class.getName") / sizeof (("JNI:GetMethodID java.lang.Class.getName")[0]))-1)), (((rtl_TextEncoding ) 11))), 0); | |||
1320 | jstring jsClass= (jstring) pJNIEnv->CallObjectMethod( jcSec, jmName); | |||
1321 | const jchar* jcharName= pJNIEnv->GetStringChars( jsClass, NULL__null); | |||
1322 | rtl::OUString sName( jcharName); | |||
1323 | jboolean bIsSandbox; | |||
1324 | if ( sName == "com.sun.star.lib.sandbox.SandboxSecurity" ) | |||
1325 | bIsSandbox= JNI_TRUE1; | |||
1326 | else | |||
1327 | bIsSandbox= JNI_FALSE0; | |||
1328 | pJNIEnv->ReleaseStringChars( jsClass, jcharName); | |||
1329 | ||||
1330 | if (bIsSandbox == JNI_TRUE1) | |||
1331 | { | |||
1332 | // call SandboxSecurity.reset | |||
1333 | jmethodID jmReset= pJNIEnv->GetMethodID( jcSec,"reset","()V"); | |||
1334 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset")(&("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset" )[0]), ((sal_Int32)((sizeof ("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset" ) / sizeof (("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1335 | pJNIEnv->CallVoidMethod( joSecur, jmReset); | |||
1336 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset")(&("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset" )[0]), ((sal_Int32)((sizeof ("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset" ) / sizeof (("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1337 | } | |||
1338 | } | |||
1339 | } | |||
1340 | } | |||
1341 | catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) | |||
1342 | { | |||
1343 | throw css::uno::RuntimeException( | |||
1344 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("jvmaccess::VirtualMachine::AttachGuard::" "CreationException" )[0]), ((sal_Int32)((sizeof ("jvmaccess::VirtualMachine::AttachGuard::" "CreationException") / sizeof (("jvmaccess::VirtualMachine::AttachGuard::" "CreationException")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1345 | "jvmaccess::VirtualMachine::AttachGuard::"(&("jvmaccess::VirtualMachine::AttachGuard::" "CreationException" )[0]), ((sal_Int32)((sizeof ("jvmaccess::VirtualMachine::AttachGuard::" "CreationException") / sizeof (("jvmaccess::VirtualMachine::AttachGuard::" "CreationException")[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1346 | "CreationException")(&("jvmaccess::VirtualMachine::AttachGuard::" "CreationException" )[0]), ((sal_Int32)((sizeof ("jvmaccess::VirtualMachine::AttachGuard::" "CreationException") / sizeof (("jvmaccess::VirtualMachine::AttachGuard::" "CreationException")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1347 | 0); | |||
1348 | } | |||
1349 | } | |||
1350 | } | |||
1351 | ||||
1352 | JavaVirtualMachine::~JavaVirtualMachine() | |||
1353 | { | |||
1354 | if (m_xInetConfiguration.is()) | |||
1355 | // We should never get here, but just in case... | |||
1356 | try | |||
1357 | { | |||
1358 | m_xInetConfiguration->removeContainerListener(this); | |||
1359 | } | |||
1360 | catch (css::uno::Exception &) | |||
1361 | { | |||
1362 | OSL_FAIL("com.sun.star.uno.Exception caught")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "1362" ": "), "%s", "com.sun.star.uno.Exception caught") ; } } while (false); | |||
1363 | } | |||
1364 | if (m_xJavaConfiguration.is()) | |||
1365 | // We should never get here, but just in case... | |||
1366 | try | |||
1367 | { | |||
1368 | m_xJavaConfiguration->removeContainerListener(this); | |||
1369 | } | |||
1370 | catch (css::uno::Exception &) | |||
1371 | { | |||
1372 | OSL_FAIL("com.sun.star.uno.Exception caught")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "1372" ": "), "%s", "com.sun.star.uno.Exception caught") ; } } while (false); | |||
1373 | } | |||
1374 | } | |||
1375 | ||||
1376 | void SAL_CALL JavaVirtualMachine::disposing() | |||
1377 | { | |||
1378 | css::uno::Reference< css::container::XContainer > xContainer1; | |||
1379 | css::uno::Reference< css::container::XContainer > xContainer2; | |||
1380 | { | |||
1381 | osl::MutexGuard aGuard(*this); | |||
1382 | m_bDisposed = true; | |||
1383 | xContainer1 = m_xInetConfiguration; | |||
1384 | m_xInetConfiguration.clear(); | |||
1385 | xContainer2 = m_xJavaConfiguration; | |||
1386 | m_xJavaConfiguration.clear(); | |||
1387 | } | |||
1388 | if (xContainer1.is()) | |||
1389 | xContainer1->removeContainerListener(this); | |||
1390 | if (xContainer2.is()) | |||
1391 | xContainer2->removeContainerListener(this); | |||
1392 | } | |||
1393 | ||||
1394 | /*We listen to changes in the configuration. For example, the user changes the proxy | |||
1395 | settings in the options dialog (menu tools). Then we are notified of this change and | |||
1396 | if the java vm is already running we change the properties (System.lang.System.setProperties) | |||
1397 | through JNI. | |||
1398 | To receive notifications this class implements XContainerListener. | |||
1399 | */ | |||
1400 | void JavaVirtualMachine::registerConfigChangesListener() | |||
1401 | { | |||
1402 | try | |||
1403 | { | |||
1404 | css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( | |||
1405 | m_xContext->getServiceManager()->createInstanceWithContext( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.configuration.ConfigurationProvider")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationProvider" ) / sizeof (("com.sun.star.configuration.ConfigurationProvider" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1406 | "com.sun.star.configuration.ConfigurationProvider")(&("com.sun.star.configuration.ConfigurationProvider")[0] ), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationProvider" ) / sizeof (("com.sun.star.configuration.ConfigurationProvider" )[0]))-1)), (((rtl_TextEncoding) 11))), m_xContext), css::uno::UNO_QUERY); | |||
1407 | ||||
1408 | if (xConfigProvider.is()) | |||
1409 | { | |||
1410 | // We register this instance as listener to changes in org.openoffice.Inet/Settings | |||
1411 | // arguments for ConfigurationAccess | |||
1412 | css::uno::Sequence< css::uno::Any > aArguments(2); | |||
1413 | aArguments[0] <<= css::beans::PropertyValue( | |||
1414 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")(&("nodepath")[0]), ((sal_Int32)((sizeof ("nodepath") / sizeof (("nodepath")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1415 | 0, | |||
1416 | css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Inet/Settings")(&("org.openoffice.Inet/Settings")[0]), ((sal_Int32)((sizeof ("org.openoffice.Inet/Settings") / sizeof (("org.openoffice.Inet/Settings" )[0]))-1)), (((rtl_TextEncoding) 11)))), | |||
1417 | css::beans::PropertyState_DIRECT_VALUE); | |||
1418 | // depth: -1 means unlimited | |||
1419 | aArguments[1] <<= css::beans::PropertyValue( | |||
1420 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")(&("depth")[0]), ((sal_Int32)((sizeof ("depth") / sizeof ( ("depth")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1421 | 0, | |||
1422 | css::uno::makeAny( (sal_Int32)-1), | |||
1423 | css::beans::PropertyState_DIRECT_VALUE); | |||
1424 | ||||
1425 | m_xInetConfiguration | |||
1426 | = css::uno::Reference< css::container::XContainer >( | |||
1427 | xConfigProvider->createInstanceWithArguments( | |||
1428 | rtl::OUString( | |||
1429 | RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.configuration.ConfigurationAccess")[0]), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationAccess" ) / sizeof (("com.sun.star.configuration.ConfigurationAccess" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1430 | "com.sun.star.configuration.ConfigurationAccess")(&("com.sun.star.configuration.ConfigurationAccess")[0]), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationAccess" ) / sizeof (("com.sun.star.configuration.ConfigurationAccess" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1431 | aArguments), | |||
1432 | css::uno::UNO_QUERY); | |||
1433 | ||||
1434 | if (m_xInetConfiguration.is()) | |||
1435 | m_xInetConfiguration->addContainerListener(this); | |||
1436 | ||||
1437 | // now register as listener to changes in org.openoffice.Java/VirtualMachine | |||
1438 | css::uno::Sequence< css::uno::Any > aArguments2(2); | |||
1439 | aArguments2[0] <<= css::beans::PropertyValue( | |||
1440 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")(&("nodepath")[0]), ((sal_Int32)((sizeof ("nodepath") / sizeof (("nodepath")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1441 | 0, | |||
1442 | css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Java/VirtualMachine")(&("org.openoffice.Office.Java/VirtualMachine")[0]), ((sal_Int32 )((sizeof ("org.openoffice.Office.Java/VirtualMachine") / sizeof (("org.openoffice.Office.Java/VirtualMachine")[0]))-1)), ((( rtl_TextEncoding) 11)))), | |||
1443 | css::beans::PropertyState_DIRECT_VALUE); | |||
1444 | // depth: -1 means unlimited | |||
1445 | aArguments2[1] <<= css::beans::PropertyValue( | |||
1446 | rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")(&("depth")[0]), ((sal_Int32)((sizeof ("depth") / sizeof ( ("depth")[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1447 | 0, | |||
1448 | css::uno::makeAny( (sal_Int32)-1), | |||
1449 | css::beans::PropertyState_DIRECT_VALUE); | |||
1450 | ||||
1451 | m_xJavaConfiguration | |||
1452 | = css::uno::Reference< css::container::XContainer >( | |||
1453 | xConfigProvider->createInstanceWithArguments( | |||
1454 | rtl::OUString( | |||
1455 | RTL_CONSTASCII_USTRINGPARAM((&("com.sun.star.configuration.ConfigurationAccess")[0]), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationAccess" ) / sizeof (("com.sun.star.configuration.ConfigurationAccess" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1456 | "com.sun.star.configuration.ConfigurationAccess")(&("com.sun.star.configuration.ConfigurationAccess")[0]), ((sal_Int32)((sizeof ("com.sun.star.configuration.ConfigurationAccess" ) / sizeof (("com.sun.star.configuration.ConfigurationAccess" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1457 | aArguments2), | |||
1458 | css::uno::UNO_QUERY); | |||
1459 | ||||
1460 | if (m_xJavaConfiguration.is()) | |||
1461 | m_xJavaConfiguration->addContainerListener(this); | |||
1462 | } | |||
1463 | }catch(const css::uno::Exception & e) | |||
1464 | { | |||
1465 | #if OSL_DEBUG_LEVEL1 > 1 | |||
1466 | rtl::OString message = rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11))); | |||
1467 | OSL_TRACE("javavm.cxx: could not set up listener for Configuration because of >%s<", message.getStr())do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "1467" ": "), "javavm.cxx: could not set up listener for Configuration because of >%s<" , message.getStr()); } } while (false); | |||
1468 | #else | |||
1469 | (void) e; // unused | |||
1470 | #endif | |||
1471 | } | |||
1472 | } | |||
1473 | ||||
1474 | // param true: all Inet setting are set as Java Properties on a live VM. | |||
1475 | // false: the Java net properties are set to empty value. | |||
1476 | void JavaVirtualMachine::setINetSettingsInVM(bool set_reset) | |||
1477 | { | |||
1478 | osl::MutexGuard aGuard(*this); | |||
1479 | try | |||
1480 | { | |||
1481 | if (m_xUnoVirtualMachine.is()) | |||
1482 | { | |||
1483 | jvmaccess::VirtualMachine::AttachGuard aAttachGuard( | |||
1484 | m_xUnoVirtualMachine->getVirtualMachine()); | |||
1485 | JNIEnv * pJNIEnv = aAttachGuard.getEnvironment(); | |||
1486 | ||||
1487 | // The Java Properties | |||
1488 | rtl::OUString sFtpProxyHost(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyHost")(&("ftp.proxyHost")[0]), ((sal_Int32)((sizeof ("ftp.proxyHost" ) / sizeof (("ftp.proxyHost")[0]))-1)), (((rtl_TextEncoding) 11 )) ); | |||
1489 | rtl::OUString sFtpProxyPort(RTL_CONSTASCII_USTRINGPARAM("ftp.proxyPort")(&("ftp.proxyPort")[0]), ((sal_Int32)((sizeof ("ftp.proxyPort" ) / sizeof (("ftp.proxyPort")[0]))-1)), (((rtl_TextEncoding) 11 )) ); | |||
1490 | rtl::OUString sFtpNonProxyHosts (RTL_CONSTASCII_USTRINGPARAM("ftp.nonProxyHosts")(&("ftp.nonProxyHosts")[0]), ((sal_Int32)((sizeof ("ftp.nonProxyHosts" ) / sizeof (("ftp.nonProxyHosts")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
1491 | rtl::OUString sHttpProxyHost(RTL_CONSTASCII_USTRINGPARAM("http.proxyHost")(&("http.proxyHost")[0]), ((sal_Int32)((sizeof ("http.proxyHost" ) / sizeof (("http.proxyHost")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
1492 | rtl::OUString sHttpProxyPort(RTL_CONSTASCII_USTRINGPARAM("http.proxyPort")(&("http.proxyPort")[0]), ((sal_Int32)((sizeof ("http.proxyPort" ) / sizeof (("http.proxyPort")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
1493 | rtl::OUString sHttpNonProxyHosts(RTL_CONSTASCII_USTRINGPARAM("http.nonProxyHosts")(&("http.nonProxyHosts")[0]), ((sal_Int32)((sizeof ("http.nonProxyHosts" ) / sizeof (("http.nonProxyHosts")[0]))-1)), (((rtl_TextEncoding ) 11))); | |||
1494 | ||||
1495 | // creat Java Properties as JNI strings | |||
1496 | jstring jsFtpProxyHost= pJNIEnv->NewString( sFtpProxyHost.getStr(), sFtpProxyHost.getLength()); | |||
1497 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1498 | jstring jsFtpProxyPort= pJNIEnv->NewString( sFtpProxyPort.getStr(), sFtpProxyPort.getLength()); | |||
1499 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1500 | jstring jsFtpNonProxyHosts= pJNIEnv->NewString( sFtpNonProxyHosts.getStr(), sFtpNonProxyHosts.getLength()); | |||
1501 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1502 | jstring jsHttpProxyHost= pJNIEnv->NewString( sHttpProxyHost.getStr(), sHttpProxyHost.getLength()); | |||
1503 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1504 | jstring jsHttpProxyPort= pJNIEnv->NewString( sHttpProxyPort.getStr(), sHttpProxyPort.getLength()); | |||
1505 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1506 | jstring jsHttpNonProxyHosts= pJNIEnv->NewString( sHttpNonProxyHosts.getStr(), sHttpNonProxyHosts.getLength()); | |||
1507 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1508 | ||||
1509 | // prepare java.lang.System.setProperty | |||
1510 | jclass jcSystem= pJNIEnv->FindClass("java/lang/System"); | |||
1511 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/lang/System")(&("JNI:FindClass java/lang/System")[0]), ((sal_Int32)((sizeof ("JNI:FindClass java/lang/System") / sizeof (("JNI:FindClass java/lang/System" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1512 | jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); | |||
1513 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.setProperty")(&("JNI:GetStaticMethodID java.lang.System.setProperty")[ 0]), ((sal_Int32)((sizeof ("JNI:GetStaticMethodID java.lang.System.setProperty" ) / sizeof (("JNI:GetStaticMethodID java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1514 | ||||
1515 | // call java.lang.System.getProperties | |||
1516 | jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;"); | |||
1517 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetStaticMethodID java.lang.System.getProperties")(&("JNI:GetStaticMethodID java.lang.System.getProperties" )[0]), ((sal_Int32)((sizeof ("JNI:GetStaticMethodID java.lang.System.getProperties" ) / sizeof (("JNI:GetStaticMethodID java.lang.System.getProperties" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1518 | jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps); | |||
1519 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.getProperties")(&("JNI:CallStaticObjectMethod java.lang.System.getProperties" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.getProperties" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.getProperties" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1520 | // prepare java.util.Properties.remove | |||
1521 | jclass jcProperties= pJNIEnv->FindClass("java/util/Properties"); | |||
1522 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:FindClass java/util/Properties")(&("JNI:FindClass java/util/Properties")[0]), ((sal_Int32 )((sizeof ("JNI:FindClass java/util/Properties") / sizeof (("JNI:FindClass java/util/Properties" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1523 | ||||
1524 | if (set_reset) | |||
1525 | { | |||
1526 | // Set all network properties with the VM | |||
1527 | JVM jvm; | |||
1528 | getINetPropsFromConfig( &jvm, m_xContext->getServiceManager(), m_xContext); | |||
1529 | const ::std::vector< rtl::OUString> & Props = jvm.getProperties(); | |||
1530 | typedef ::std::vector< rtl::OUString >::const_iterator C_IT; | |||
1531 | ||||
1532 | for( C_IT i= Props.begin(); i != Props.end(); ++i) | |||
1533 | { | |||
1534 | rtl::OUString prop= *i; | |||
1535 | sal_Int32 index= prop.indexOf( (sal_Unicode)'='); | |||
1536 | rtl::OUString propName= prop.copy( 0, index); | |||
1537 | rtl::OUString propValue= prop.copy( index + 1); | |||
1538 | ||||
1539 | if( propName.equals( sFtpProxyHost)) | |||
1540 | { | |||
1541 | jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength()); | |||
1542 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1543 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpProxyHost, jsVal); | |||
1544 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1545 | } | |||
1546 | else if( propName.equals( sFtpProxyPort)) | |||
1547 | { | |||
1548 | jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength()); | |||
1549 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1550 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpProxyPort, jsVal); | |||
1551 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1552 | } | |||
1553 | else if( propName.equals( sFtpNonProxyHosts)) | |||
1554 | { | |||
1555 | jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength()); | |||
1556 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1557 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsFtpNonProxyHosts, jsVal); | |||
1558 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1559 | } | |||
1560 | else if( propName.equals( sHttpProxyHost)) | |||
1561 | { | |||
1562 | jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength()); | |||
1563 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1564 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpProxyHost, jsVal); | |||
1565 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1566 | } | |||
1567 | else if( propName.equals( sHttpProxyPort)) | |||
1568 | { | |||
1569 | jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength()); | |||
1570 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1571 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpProxyPort, jsVal); | |||
1572 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1573 | } | |||
1574 | else if( propName.equals( sHttpNonProxyHosts)) | |||
1575 | { | |||
1576 | jstring jsVal= pJNIEnv->NewString( propValue.getStr(), propValue.getLength()); | |||
1577 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:NewString")(&("JNI:NewString")[0]), ((sal_Int32)((sizeof ("JNI:NewString" ) / sizeof (("JNI:NewString")[0]))-1)), (((rtl_TextEncoding) 11 ))), 0); | |||
1578 | pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsHttpNonProxyHosts, jsVal); | |||
1579 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:CallStaticObjectMethod java.lang.System.setProperty")(&("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]), ((sal_Int32)((sizeof ("JNI:CallStaticObjectMethod java.lang.System.setProperty" ) / sizeof (("JNI:CallStaticObjectMethod java.lang.System.setProperty" )[0]))-1)), (((rtl_TextEncoding) 11))), 0); | |||
1580 | } | |||
1581 | } | |||
1582 | } | |||
1583 | else | |||
1584 | { | |||
1585 | // call java.util.Properties.remove | |||
1586 | jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;"); | |||
1587 | if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JNI:GetMethodID java.util.Property.remove")(&("JNI:GetMethodID java.util.Property.remove")[0]), ((sal_Int32 )((sizeof ("JNI:GetMethodID java.util.Property.remove") / sizeof (("JNI:GetMethodID java.util.Property.remove")[0]))-1)), ((( rtl_TextEncoding) 11))), 0); | |||
1588 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpProxyHost); | |||
1589 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpProxyPort); | |||
1590 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsFtpNonProxyHosts); | |||
1591 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpProxyHost); | |||
1592 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpProxyPort); | |||
1593 | pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsHttpNonProxyHosts); | |||
1594 | } | |||
1595 | } | |||
1596 | } | |||
1597 | catch (css::uno::RuntimeException &) | |||
1598 | { | |||
1599 | OSL_FAIL("RuntimeException")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "1599" ": "), "%s", "RuntimeException"); } } while (false ); | |||
1600 | } | |||
1601 | catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) | |||
1602 | { | |||
1603 | OSL_FAIL("jvmaccess::VirtualMachine::AttachGuard::CreationException")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/javavm/javavm.cxx" ":" "1603" ": "), "%s", "jvmaccess::VirtualMachine::AttachGuard::CreationException" ); } } while (false); | |||
1604 | } | |||
1605 | } | |||
1606 | ||||
1607 | void JavaVirtualMachine::setUpUnoVirtualMachine(JNIEnv * environment) { | |||
1608 | css::uno::Reference< css::util::XMacroExpander > exp; | |||
1609 | if (!(m_xContext->getValueByName( | |||
1610 | rtl::OUString( | |||
1611 | RTL_CONSTASCII_USTRINGPARAM((&("/singletons/com.sun.star.util.theMacroExpander")[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.util.theMacroExpander" ) / sizeof (("/singletons/com.sun.star.util.theMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1612 | "/singletons/com.sun.star.util.theMacroExpander")(&("/singletons/com.sun.star.util.theMacroExpander")[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.util.theMacroExpander" ) / sizeof (("/singletons/com.sun.star.util.theMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11)))) | |||
1613 | >>= exp) | |||
1614 | || !exp.is()) | |||
1615 | { | |||
1616 | throw css::uno::RuntimeException( | |||
1617 | rtl::OUString( | |||
1618 | RTL_CONSTASCII_USTRINGPARAM((&("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander")[0]), ((sal_Int32)((sizeof ("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander") / sizeof (("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1619 | "component context fails to supply singleton"(&("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander")[0]), ((sal_Int32)((sizeof ("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander") / sizeof (("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1620 | " com.sun.star.util.theMacroExpander of type"(&("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander")[0]), ((sal_Int32)((sizeof ("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander") / sizeof (("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1621 | " com.sun.star.util.XMacroExpander")(&("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander")[0]), ((sal_Int32)((sizeof ("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander") / sizeof (("component context fails to supply singleton" " com.sun.star.util.theMacroExpander of type" " com.sun.star.util.XMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1622 | m_xContext); | |||
1623 | } | |||
1624 | rtl::OUString baseUrl; | |||
1625 | try { | |||
1626 | baseUrl = exp->expandMacros( | |||
1627 | rtl::OUString( | |||
1628 | RTL_CONSTASCII_USTRINGPARAM("$URE_INTERNAL_JAVA_DIR/")(&("$URE_INTERNAL_JAVA_DIR/")[0]), ((sal_Int32)((sizeof ( "$URE_INTERNAL_JAVA_DIR/") / sizeof (("$URE_INTERNAL_JAVA_DIR/" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
1629 | } catch (css::lang::IllegalArgumentException &) { | |||
1630 | throw css::uno::RuntimeException( | |||
1631 | rtl::OUString( | |||
1632 | RTL_CONSTASCII_USTRINGPARAM((&("com::sun::star::lang::IllegalArgumentException")[0]), ((sal_Int32)((sizeof ("com::sun::star::lang::IllegalArgumentException" ) / sizeof (("com::sun::star::lang::IllegalArgumentException" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1633 | "com::sun::star::lang::IllegalArgumentException")(&("com::sun::star::lang::IllegalArgumentException")[0]), ((sal_Int32)((sizeof ("com::sun::star::lang::IllegalArgumentException" ) / sizeof (("com::sun::star::lang::IllegalArgumentException" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1634 | static_cast< cppu::OWeakObject * >(this)); | |||
1635 | } | |||
1636 | rtl::OUString classPath; | |||
1637 | try { | |||
1638 | classPath = exp->expandMacros( | |||
1639 | rtl::OUString( | |||
1640 | RTL_CONSTASCII_USTRINGPARAM("$URE_INTERNAL_JAVA_CLASSPATH")(&("$URE_INTERNAL_JAVA_CLASSPATH")[0]), ((sal_Int32)((sizeof ("$URE_INTERNAL_JAVA_CLASSPATH") / sizeof (("$URE_INTERNAL_JAVA_CLASSPATH" )[0]))-1)), (((rtl_TextEncoding) 11)))); | |||
1641 | } catch (css::lang::IllegalArgumentException &) {} | |||
1642 | jclass class_URLClassLoader = environment->FindClass( | |||
1643 | "java/net/URLClassLoader"); | |||
1644 | if (class_URLClassLoader == 0) { | |||
1645 | handleJniException(environment); | |||
1646 | } | |||
1647 | jmethodID ctor_URLClassLoader = environment->GetMethodID( | |||
1648 | class_URLClassLoader, "<init>", "([Ljava/net/URL;)V"); | |||
1649 | if (ctor_URLClassLoader == 0) { | |||
1650 | handleJniException(environment); | |||
1651 | } | |||
1652 | jclass class_URL = environment->FindClass("java/net/URL"); | |||
1653 | if (class_URL == 0) { | |||
1654 | handleJniException(environment); | |||
1655 | } | |||
1656 | jmethodID ctor_URL_1 = environment->GetMethodID( | |||
1657 | class_URL, "<init>", "(Ljava/lang/String;)V"); | |||
1658 | if (ctor_URL_1 == 0) { | |||
1659 | handleJniException(environment); | |||
1660 | } | |||
1661 | jvalue args[3]; | |||
1662 | args[0].l = environment->NewString( | |||
1663 | static_cast< jchar const * >(baseUrl.getStr()), | |||
1664 | static_cast< jsize >(baseUrl.getLength())); | |||
1665 | if (args[0].l == 0) { | |||
1666 | handleJniException(environment); | |||
1667 | } | |||
1668 | jobject base = environment->NewObjectA(class_URL, ctor_URL_1, args); | |||
1669 | if (base == 0) { | |||
1670 | handleJniException(environment); | |||
1671 | } | |||
1672 | jmethodID ctor_URL_2 = environment->GetMethodID( | |||
1673 | class_URL, "<init>", "(Ljava/net/URL;Ljava/lang/String;)V"); | |||
1674 | if (ctor_URL_2 == 0) { | |||
1675 | handleJniException(environment); | |||
1676 | } | |||
1677 | jobjectArray classpath = jvmaccess::ClassPath::translateToUrls( | |||
1678 | m_xContext, environment, classPath); | |||
1679 | if (classpath == 0) { | |||
1680 | handleJniException(environment); | |||
1681 | } | |||
1682 | args[0].l = base; | |||
1683 | args[1].l = environment->NewStringUTF("unoloader.jar"); | |||
1684 | if (args[1].l == 0) { | |||
1685 | handleJniException(environment); | |||
1686 | } | |||
1687 | args[0].l = environment->NewObjectA(class_URL, ctor_URL_2, args); | |||
1688 | if (args[0].l == 0) { | |||
1689 | handleJniException(environment); | |||
1690 | } | |||
1691 | args[0].l = environment->NewObjectArray(1, class_URL, args[0].l); | |||
1692 | if (args[0].l == 0) { | |||
1693 | handleJniException(environment); | |||
1694 | } | |||
1695 | jobject cl1 = environment->NewObjectA( | |||
1696 | class_URLClassLoader, ctor_URLClassLoader, args); | |||
1697 | if (cl1 == 0) { | |||
1698 | handleJniException(environment); | |||
1699 | } | |||
1700 | jmethodID method_loadClass = environment->GetMethodID( | |||
1701 | class_URLClassLoader, "loadClass", | |||
1702 | "(Ljava/lang/String;)Ljava/lang/Class;"); | |||
1703 | if (method_loadClass == 0) { | |||
1704 | handleJniException(environment); | |||
1705 | } | |||
1706 | args[0].l = environment->NewStringUTF( | |||
1707 | "com.sun.star.lib.unoloader.UnoClassLoader"); | |||
1708 | if (args[0].l == 0) { | |||
1709 | handleJniException(environment); | |||
1710 | } | |||
1711 | jclass class_UnoClassLoader = static_cast< jclass >( | |||
1712 | environment->CallObjectMethodA(cl1, method_loadClass, args)); | |||
1713 | if (class_UnoClassLoader == 0) { | |||
1714 | handleJniException(environment); | |||
1715 | } | |||
1716 | jmethodID ctor_UnoClassLoader = environment->GetMethodID( | |||
1717 | class_UnoClassLoader, "<init>", | |||
1718 | "(Ljava/net/URL;[Ljava/net/URL;Ljava/lang/ClassLoader;)V"); | |||
1719 | if (ctor_UnoClassLoader == 0) { | |||
1720 | handleJniException(environment); | |||
1721 | } | |||
1722 | args[0].l = base; | |||
1723 | args[1].l = classpath; | |||
1724 | args[2].l = cl1; | |||
1725 | jobject cl2 = environment->NewObjectA( | |||
1726 | class_UnoClassLoader, ctor_UnoClassLoader, args); | |||
1727 | if (cl2 == 0) { | |||
1728 | handleJniException(environment); | |||
1729 | } | |||
1730 | try { | |||
1731 | m_xUnoVirtualMachine = new jvmaccess::UnoVirtualMachine( | |||
1732 | m_xVirtualMachine, cl2); | |||
1733 | } catch (jvmaccess::UnoVirtualMachine::CreationException &) { | |||
1734 | throw css::uno::RuntimeException( | |||
1735 | rtl::OUString( | |||
1736 | RTL_CONSTASCII_USTRINGPARAM((&("jvmaccess::UnoVirtualMachine::CreationException")[0]) , ((sal_Int32)((sizeof ("jvmaccess::UnoVirtualMachine::CreationException" ) / sizeof (("jvmaccess::UnoVirtualMachine::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
1737 | "jvmaccess::UnoVirtualMachine::CreationException")(&("jvmaccess::UnoVirtualMachine::CreationException")[0]) , ((sal_Int32)((sizeof ("jvmaccess::UnoVirtualMachine::CreationException" ) / sizeof (("jvmaccess::UnoVirtualMachine::CreationException" )[0]))-1)), (((rtl_TextEncoding) 11))), | |||
1738 | static_cast< cppu::OWeakObject * >(this)); | |||
1739 | } | |||
1740 | } | |||
1741 | ||||
1742 | void JavaVirtualMachine::handleJniException(JNIEnv * environment) { | |||
1743 | environment->ExceptionClear(); | |||
1744 | throw css::uno::RuntimeException( | |||
1745 | rtl::OUString( | |||
1746 | RTL_CONSTASCII_USTRINGPARAM("JNI exception occurred")(&("JNI exception occurred")[0]), ((sal_Int32)((sizeof ("JNI exception occurred" ) / sizeof (("JNI exception occurred")[0]))-1)), (((rtl_TextEncoding ) 11))), | |||
1747 | static_cast< cppu::OWeakObject * >(this)); | |||
1748 | } | |||
1749 | ||||
1750 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |