File: | bridges/source/jni_uno/jni_info.cxx |
Location: | line 56, column 11 |
Description: | Access to field 'bComplete' results in a dereference of a null pointer |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /************************************************************************* |
3 | * |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 | * |
6 | * Copyright 2000, 2010 Oracle and/or its affiliates. |
7 | * |
8 | * OpenOffice.org - a multi-platform office productivity suite |
9 | * |
10 | * This file is part of OpenOffice.org. |
11 | * |
12 | * OpenOffice.org is free software: you can redistribute it and/or modify |
13 | * it under the terms of the GNU Lesser General Public License version 3 |
14 | * only, as published by the Free Software Foundation. |
15 | * |
16 | * OpenOffice.org is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU Lesser General Public License version 3 for more details |
20 | * (a copy is included in the LICENSE file that accompanied this code). |
21 | * |
22 | * You should have received a copy of the GNU Lesser General Public License |
23 | * version 3 along with OpenOffice.org. If not, see |
24 | * <http://www.openoffice.org/license.html> |
25 | * for a copy of the LGPLv3 License. |
26 | * |
27 | ************************************************************************/ |
28 | |
29 | #include "jni_bridge.h" |
30 | |
31 | #include "com/sun/star/uno/RuntimeException.hpp" |
32 | |
33 | #include "jvmaccess/unovirtualmachine.hxx" |
34 | #include "rtl/string.hxx" |
35 | #include "rtl/strbuf.hxx" |
36 | #include "rtl/ustrbuf.hxx" |
37 | |
38 | #include "uno/lbnames.h" |
39 | |
40 | |
41 | namespace css = ::com::sun::star; |
42 | using namespace ::std; |
43 | using namespace ::osl; |
44 | using namespace ::rtl; |
45 | |
46 | namespace jni_uno |
47 | { |
48 | |
49 | //______________________________________________________________________________ |
50 | JNI_type_info::JNI_type_info( |
51 | JNI_context const & jni, typelib_TypeDescription * td ) |
52 | : m_td( td ), |
53 | m_class( 0 ) |
54 | { |
55 | m_td.makeComplete(); |
56 | if (! m_td.get()->bComplete) |
Access to field 'bComplete' results in a dereference of a null pointer | |
57 | { |
58 | OUStringBuffer buf( 128 ); |
59 | buf.appendAscii( |
60 | RTL_CONSTASCII_STRINGPARAM("cannot make type complete: ")(&("cannot make type complete: ")[0]), ((sal_Int32)(sizeof ("cannot make type complete: ") / sizeof (("cannot make type complete: " )[0]))-1) ); |
61 | buf.append( OUString::unacquired( &m_td.get()->pTypeName ) ); |
62 | buf.append( jni.get_stack_trace() ); |
63 | throw BridgeRuntimeError( buf.makeStringAndClear() ); |
64 | } |
65 | } |
66 | |
67 | |
68 | //______________________________________________________________________________ |
69 | void JNI_interface_type_info::destroy( JNIEnv * jni_env ) |
70 | { |
71 | JNI_type_info::destruct( jni_env ); |
72 | jni_env->DeleteGlobalRef( m_proxy_ctor ); |
73 | jni_env->DeleteGlobalRef( m_type ); |
74 | delete [] m_methods; |
75 | delete this; |
76 | } |
77 | |
78 | //______________________________________________________________________________ |
79 | JNI_interface_type_info::JNI_interface_type_info( |
80 | JNI_context const & jni, typelib_TypeDescription * td_ ) |
81 | : JNI_type_info( jni, td_ ) |
82 | { |
83 | OSL_ASSERT( typelib_TypeClass_INTERFACE == m_td.get()->eTypeClass )do { if (true && (!(typelib_TypeClass_INTERFACE == m_td .get()->eTypeClass))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "83" ": "), "OSL_ASSERT: %s", "typelib_TypeClass_INTERFACE == m_td.get()->eTypeClass" ); } } while (false); |
84 | |
85 | OUString const & uno_name = OUString::unacquired( &m_td.get()->pTypeName ); |
86 | JNI_info const * jni_info = jni.get_info(); |
87 | |
88 | JLocalAutoRef jo_class( |
89 | jni, |
90 | find_class( |
91 | jni, |
92 | ( OUStringToOString( uno_name, RTL_TEXTENCODING_JAVA_UTF8(((rtl_TextEncoding) 90)) ). |
93 | getStr() ) ) ); |
94 | JLocalAutoRef jo_type( jni, create_type( jni, (jclass) jo_class.get() ) ); |
95 | |
96 | // get proxy ctor |
97 | jvalue arg; |
98 | arg.l = jo_class.get(); |
99 | JLocalAutoRef jo_proxy_ctor( |
100 | jni, jni->CallStaticObjectMethodA( |
101 | jni_info->m_class_JNI_proxy, |
102 | jni_info->m_method_JNI_proxy_get_proxy_ctor, &arg ) ); |
103 | |
104 | if (is_XInterface( m_td.get()->pWeakRef )) |
105 | { |
106 | m_methods = 0; // no methods |
107 | } |
108 | else |
109 | { |
110 | // retrieve method ids for all direct members |
111 | try |
112 | { |
113 | typelib_InterfaceTypeDescription * td = |
114 | reinterpret_cast< typelib_InterfaceTypeDescription * >( |
115 | m_td.get() ); |
116 | m_methods = new jmethodID[ td->nMapFunctionIndexToMemberIndex ]; |
117 | sal_Int32 nMethodIndex = 0; |
118 | typelib_TypeDescriptionReference ** ppMembers = td->ppMembers; |
119 | sal_Int32 nMembers = td->nMembers; |
120 | |
121 | for ( sal_Int32 nPos = 0; nPos < nMembers; ++nPos ) |
122 | { |
123 | TypeDescr member_td( ppMembers[ nPos ] ); |
124 | |
125 | OStringBuffer sig_buf( 64 ); |
126 | |
127 | if (typelib_TypeClass_INTERFACE_METHOD == |
128 | member_td.get()->eTypeClass) // method |
129 | { |
130 | typelib_InterfaceMethodTypeDescription * method_td = |
131 | reinterpret_cast< |
132 | typelib_InterfaceMethodTypeDescription * >( |
133 | member_td.get() ); |
134 | |
135 | sig_buf.append( '(' ); |
136 | for ( sal_Int32 i = 0; i < method_td->nParams; ++i ) |
137 | { |
138 | typelib_MethodParameter const & param = |
139 | method_td->pParams[ i ]; |
140 | if (param.bOut) |
141 | sig_buf.append( '[' ); |
142 | JNI_info::append_sig( &sig_buf, param.pTypeRef ); |
143 | } |
144 | sig_buf.append( ')' ); |
145 | JNI_info::append_sig( &sig_buf, method_td->pReturnTypeRef ); |
146 | |
147 | OString method_signature( sig_buf.makeStringAndClear() ); |
148 | OString method_name( |
149 | OUStringToOString( OUString::unacquired( |
150 | &method_td->aBase.pMemberName ), |
151 | RTL_TEXTENCODING_JAVA_UTF8(((rtl_TextEncoding) 90)) ) ); |
152 | |
153 | m_methods[ nMethodIndex ] = jni->GetMethodID( |
154 | (jclass) jo_class.get(), method_name.getStr(), |
155 | method_signature.getStr() ); |
156 | jni.ensure_no_exception(); |
157 | OSL_ASSERT( 0 != m_methods[ nMethodIndex ] )do { if (true && (!(0 != m_methods[ nMethodIndex ]))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "157" ": "), "OSL_ASSERT: %s", "0 != m_methods[ nMethodIndex ]" ); } } while (false); |
158 | ++nMethodIndex; |
159 | } |
160 | else // attribute |
161 | { |
162 | OSL_ASSERT(do { if (true && (!(typelib_TypeClass_INTERFACE_ATTRIBUTE == member_td.get()->eTypeClass))) { sal_detail_logFormat( (SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "164" ": "), "OSL_ASSERT: %s", "typelib_TypeClass_INTERFACE_ATTRIBUTE == member_td.get()->eTypeClass" ); } } while (false) |
163 | typelib_TypeClass_INTERFACE_ATTRIBUTE ==do { if (true && (!(typelib_TypeClass_INTERFACE_ATTRIBUTE == member_td.get()->eTypeClass))) { sal_detail_logFormat( (SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "164" ": "), "OSL_ASSERT: %s", "typelib_TypeClass_INTERFACE_ATTRIBUTE == member_td.get()->eTypeClass" ); } } while (false) |
164 | member_td.get()->eTypeClass )do { if (true && (!(typelib_TypeClass_INTERFACE_ATTRIBUTE == member_td.get()->eTypeClass))) { sal_detail_logFormat( (SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "164" ": "), "OSL_ASSERT: %s", "typelib_TypeClass_INTERFACE_ATTRIBUTE == member_td.get()->eTypeClass" ); } } while (false); |
165 | typelib_InterfaceAttributeTypeDescription * attribute_td = |
166 | reinterpret_cast< |
167 | typelib_InterfaceAttributeTypeDescription * >( |
168 | member_td.get() ); |
169 | |
170 | // type sig |
171 | JNI_info::append_sig( |
172 | &sig_buf, attribute_td->pAttributeTypeRef ); |
173 | OString type_sig( sig_buf.makeStringAndClear() ); |
174 | sig_buf.ensureCapacity( 64 ); |
175 | // member name |
176 | OUString const & member_name = |
177 | OUString::unacquired( |
178 | &attribute_td->aBase.pMemberName ); |
179 | |
180 | // getter |
181 | sig_buf.append( RTL_CONSTASCII_STRINGPARAM("()")(&("()")[0]), ((sal_Int32)(sizeof ("()") / sizeof (("()") [0]))-1) ); |
182 | sig_buf.append( type_sig ); |
183 | OString method_signature( sig_buf.makeStringAndClear() ); |
184 | OUStringBuffer name_buf( 3 + member_name.getLength() ); |
185 | name_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("get")(&("get")[0]), ((sal_Int32)(sizeof ("get") / sizeof (("get" )[0]))-1) ); |
186 | name_buf.append( member_name ); |
187 | OString method_name( |
188 | OUStringToOString( |
189 | name_buf.makeStringAndClear(), |
190 | RTL_TEXTENCODING_JAVA_UTF8(((rtl_TextEncoding) 90)) ) ); |
191 | m_methods[ nMethodIndex ] = jni->GetMethodID( |
192 | (jclass) jo_class.get(), method_name.getStr(), |
193 | method_signature.getStr() ); |
194 | jni.ensure_no_exception(); |
195 | OSL_ASSERT( 0 != m_methods[ nMethodIndex ] )do { if (true && (!(0 != m_methods[ nMethodIndex ]))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "195" ": "), "OSL_ASSERT: %s", "0 != m_methods[ nMethodIndex ]" ); } } while (false); |
196 | ++nMethodIndex; |
197 | if (! attribute_td->bReadOnly) |
198 | { |
199 | // setter |
200 | sig_buf.ensureCapacity( 64 ); |
201 | sig_buf.append( '(' ); |
202 | sig_buf.append( type_sig ); |
203 | sig_buf.append( RTL_CONSTASCII_STRINGPARAM(")V")(&(")V")[0]), ((sal_Int32)(sizeof (")V") / sizeof ((")V") [0]))-1) ); |
204 | method_signature = sig_buf.makeStringAndClear(); |
205 | name_buf.ensureCapacity( 3 + member_name.getLength() ); |
206 | name_buf.appendAscii( |
207 | RTL_CONSTASCII_STRINGPARAM("set")(&("set")[0]), ((sal_Int32)(sizeof ("set") / sizeof (("set" )[0]))-1) ); |
208 | name_buf.append( member_name ); |
209 | method_name = OUStringToOString( |
210 | name_buf.makeStringAndClear(), |
211 | RTL_TEXTENCODING_JAVA_UTF8(((rtl_TextEncoding) 90)) ); |
212 | m_methods[ nMethodIndex ] = jni->GetMethodID( |
213 | (jclass) jo_class.get(), method_name.getStr(), |
214 | method_signature.getStr() ); |
215 | jni.ensure_no_exception(); |
216 | OSL_ASSERT( 0 != m_methods[ nMethodIndex ] )do { if (true && (!(0 != m_methods[ nMethodIndex ]))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "216" ": "), "OSL_ASSERT: %s", "0 != m_methods[ nMethodIndex ]" ); } } while (false); |
217 | ++nMethodIndex; |
218 | } |
219 | } |
220 | } |
221 | } |
222 | catch (...) |
223 | { |
224 | delete [] m_methods; |
225 | throw; |
226 | } |
227 | } |
228 | m_class = (jclass) jni->NewGlobalRef( jo_class.get() ); |
229 | m_type = jni->NewGlobalRef( jo_type.get() ); |
230 | m_proxy_ctor = jni->NewGlobalRef( jo_proxy_ctor.get() ); |
231 | } |
232 | |
233 | |
234 | //______________________________________________________________________________ |
235 | void JNI_compound_type_info::destroy( JNIEnv * jni_env ) |
236 | { |
237 | JNI_type_info::destruct( jni_env ); |
238 | delete [] m_fields; |
239 | delete this; |
240 | } |
241 | |
242 | //______________________________________________________________________________ |
243 | JNI_compound_type_info::JNI_compound_type_info( |
244 | JNI_context const & jni, typelib_TypeDescription * td_ ) |
245 | : JNI_type_info( jni, td_ ), |
246 | m_exc_ctor( 0 ), |
247 | m_fields( 0 ) |
248 | { |
249 | OSL_ASSERT( typelib_TypeClass_STRUCT == m_td.get()->eTypeClass ||do { if (true && (!(typelib_TypeClass_STRUCT == m_td. get()->eTypeClass || typelib_TypeClass_EXCEPTION == m_td.get ()->eTypeClass))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "250" ": "), "OSL_ASSERT: %s", "typelib_TypeClass_STRUCT == m_td.get()->eTypeClass || typelib_TypeClass_EXCEPTION == m_td.get()->eTypeClass" ); } } while (false) |
250 | typelib_TypeClass_EXCEPTION == m_td.get()->eTypeClass )do { if (true && (!(typelib_TypeClass_STRUCT == m_td. get()->eTypeClass || typelib_TypeClass_EXCEPTION == m_td.get ()->eTypeClass))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "250" ": "), "OSL_ASSERT: %s", "typelib_TypeClass_STRUCT == m_td.get()->eTypeClass || typelib_TypeClass_EXCEPTION == m_td.get()->eTypeClass" ); } } while (false); |
251 | typelib_CompoundTypeDescription * td = |
252 | reinterpret_cast< typelib_CompoundTypeDescription * >( m_td.get() ); |
253 | |
254 | OUString const & uno_name = |
255 | OUString::unacquired( &((typelib_TypeDescription *)td)->pTypeName ); |
256 | |
257 | // Erase type arguments of instantiated polymorphic struct types: |
258 | OUString nucleus; |
259 | sal_Int32 i = uno_name.indexOf( '<' ); |
260 | if ( i < 0 ) { |
261 | nucleus = uno_name; |
262 | } else { |
263 | nucleus = uno_name.copy( 0, i ); |
264 | } |
265 | JLocalAutoRef jo_class( |
266 | jni, |
267 | find_class( |
268 | jni, |
269 | OUStringToOString( |
270 | nucleus, RTL_TEXTENCODING_JAVA_UTF8(((rtl_TextEncoding) 90)) ).getStr() ) ); |
271 | |
272 | JNI_info const * jni_info = jni.get_info(); |
273 | |
274 | if (typelib_TypeClass_EXCEPTION == m_td.get()->eTypeClass) |
275 | { |
276 | // retrieve exc ctor( msg ) |
277 | m_exc_ctor = jni->GetMethodID( |
278 | (jclass) jo_class.get(), "<init>", "(Ljava/lang/String;)V" ); |
279 | jni.ensure_no_exception(); |
280 | OSL_ASSERT( 0 != m_exc_ctor )do { if (true && (!(0 != m_exc_ctor))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "280" ": "), "OSL_ASSERT: %s", "0 != m_exc_ctor"); } } while (false); |
281 | } |
282 | |
283 | // retrieve info for base type |
284 | typelib_TypeDescription * base_td = |
285 | type_equals( |
286 | td->aBase.pWeakRef, |
287 | jni_info->m_RuntimeException_type.getTypeLibType()) |
288 | ? 0 |
289 | : reinterpret_cast< typelib_TypeDescription * >( |
290 | td->pBaseTypeDescription ); |
291 | m_base = (0 == base_td ? 0 : jni_info->get_type_info( jni, base_td )); |
292 | |
293 | try |
294 | { |
295 | if (type_equals( |
296 | ((typelib_TypeDescription *)td)->pWeakRef, |
297 | jni_info->m_Exception_type.getTypeLibType() ) || |
298 | type_equals( |
299 | ((typelib_TypeDescription *)td)->pWeakRef, |
300 | jni_info->m_RuntimeException_type.getTypeLibType() )) |
301 | { |
302 | m_fields = new jfieldID[ 2 ]; |
303 | m_fields[ 0 ] = 0; // special Throwable.getMessage() |
304 | // field Context |
305 | m_fields[ 1 ] = jni->GetFieldID( |
306 | (jclass) jo_class.get(), "Context", "Ljava/lang/Object;" ); |
307 | jni.ensure_no_exception(); |
308 | OSL_ASSERT( 0 != m_fields[ 1 ] )do { if (true && (!(0 != m_fields[ 1 ]))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "308" ": "), "OSL_ASSERT: %s", "0 != m_fields[ 1 ]"); } } while (false); |
309 | } |
310 | else |
311 | { |
312 | // retrieve field ids for all direct members |
313 | sal_Int32 nMembers = td->nMembers; |
314 | m_fields = new jfieldID[ nMembers ]; |
315 | |
316 | for ( sal_Int32 nPos = 0; nPos < nMembers; ++nPos ) |
317 | { |
318 | OString sig; |
319 | if (td->aBase.eTypeClass == typelib_TypeClass_STRUCT |
320 | && reinterpret_cast< typelib_StructTypeDescription * >( |
321 | td)->pParameterizedTypes != 0 |
322 | && reinterpret_cast< typelib_StructTypeDescription * >( |
323 | td)->pParameterizedTypes[nPos]) |
324 | { |
325 | sig = OString( |
326 | RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;")(&("Ljava/lang/Object;")[0]), ((sal_Int32)(sizeof ("Ljava/lang/Object;" ) / sizeof (("Ljava/lang/Object;")[0]))-1)); |
327 | } else { |
328 | OStringBuffer sig_buf( 32 ); |
329 | JNI_info::append_sig( &sig_buf, td->ppTypeRefs[ nPos ] ); |
330 | sig = sig_buf.makeStringAndClear(); |
331 | } |
332 | |
333 | OString member_name( |
334 | OUStringToOString( |
335 | OUString::unacquired( &td->ppMemberNames[ nPos ] ), |
336 | RTL_TEXTENCODING_JAVA_UTF8(((rtl_TextEncoding) 90)) ) ); |
337 | |
338 | m_fields[ nPos ] = jni->GetFieldID( |
339 | (jclass) jo_class.get(), member_name.getStr(), |
340 | sig.getStr() ); |
341 | jni.ensure_no_exception(); |
342 | OSL_ASSERT( 0 != m_fields[ nPos ] )do { if (true && (!(0 != m_fields[ nPos ]))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "342" ": "), "OSL_ASSERT: %s", "0 != m_fields[ nPos ]"); } } while (false); |
343 | } |
344 | } |
345 | } |
346 | catch (...) |
347 | { |
348 | delete [] m_fields; |
349 | throw; |
350 | } |
351 | |
352 | m_class = (jclass) jni->NewGlobalRef( jo_class.get() ); |
353 | } |
354 | |
355 | |
356 | //______________________________________________________________________________ |
357 | JNI_type_info const * JNI_info::create_type_info( |
358 | JNI_context const & jni, typelib_TypeDescription * td ) const |
359 | { |
360 | OUString const & uno_name = OUString::unacquired( &td->pTypeName ); |
361 | |
362 | JNI_type_info * new_info; |
363 | switch (td->eTypeClass) |
364 | { |
365 | case typelib_TypeClass_STRUCT: |
366 | case typelib_TypeClass_EXCEPTION: |
367 | { |
368 | new_info = new JNI_compound_type_info( jni, td ); |
369 | break; |
370 | } |
371 | case typelib_TypeClass_INTERFACE: |
372 | { |
373 | new_info = new JNI_interface_type_info( jni, td ); |
374 | break; |
375 | } |
376 | default: |
377 | { |
378 | OUStringBuffer buf( 128 ); |
379 | buf.appendAscii( |
380 | RTL_CONSTASCII_STRINGPARAM("type info not supported for ")(&("type info not supported for ")[0]), ((sal_Int32)(sizeof ("type info not supported for ") / sizeof (("type info not supported for " )[0]))-1) ); |
381 | buf.append( uno_name ); |
382 | buf.append( jni.get_stack_trace() ); |
383 | throw BridgeRuntimeError( buf.makeStringAndClear() ); |
384 | } |
385 | } |
386 | |
387 | // look up |
388 | JNI_type_info * info; |
389 | ClearableMutexGuard guard( m_mutex ); |
390 | JNI_type_info_holder & holder = m_type_map[ uno_name ]; |
391 | if (0 == holder.m_info) // new insertion |
392 | { |
393 | holder.m_info = new_info; |
394 | guard.clear(); |
395 | info = new_info; |
396 | } |
397 | else // inserted in the meantime |
398 | { |
399 | info = holder.m_info; |
400 | guard.clear(); |
401 | new_info->destroy( jni.get_jni_env() ); |
402 | } |
403 | return info; |
404 | } |
405 | |
406 | //______________________________________________________________________________ |
407 | JNI_type_info const * JNI_info::get_type_info( |
408 | JNI_context const & jni, typelib_TypeDescription * td ) const |
409 | { |
410 | if (is_XInterface( td->pWeakRef )) |
411 | { |
412 | return m_XInterface_type_info; |
413 | } |
414 | |
415 | OUString const & uno_name = OUString::unacquired( &td->pTypeName ); |
416 | JNI_type_info const * info; |
417 | ClearableMutexGuard guard( m_mutex ); |
418 | |
419 | t_str2type::const_iterator iFind( m_type_map.find( uno_name ) ); |
420 | if (iFind == m_type_map.end()) |
421 | { |
422 | guard.clear(); |
423 | info = create_type_info( jni, td ); |
424 | } |
425 | else |
426 | { |
427 | info = iFind->second.m_info; |
428 | } |
429 | |
430 | return info; |
431 | } |
432 | |
433 | //______________________________________________________________________________ |
434 | JNI_type_info const * JNI_info::get_type_info( |
435 | JNI_context const & jni, typelib_TypeDescriptionReference * type ) const |
436 | { |
437 | if (is_XInterface( type )) |
438 | { |
439 | return m_XInterface_type_info; |
440 | } |
441 | |
442 | OUString const & uno_name = OUString::unacquired( &type->pTypeName ); |
443 | JNI_type_info const * info; |
444 | ClearableMutexGuard guard( m_mutex ); |
445 | t_str2type::const_iterator iFind( m_type_map.find( uno_name ) ); |
446 | if (iFind == m_type_map.end()) |
447 | { |
448 | guard.clear(); |
449 | TypeDescr td( type ); |
450 | info = create_type_info( jni, td.get() ); |
451 | } |
452 | else |
453 | { |
454 | info = iFind->second.m_info; |
455 | } |
456 | |
457 | return info; |
458 | } |
459 | |
460 | //______________________________________________________________________________ |
461 | JNI_type_info const * JNI_info::get_type_info( |
462 | JNI_context const & jni, OUString const & uno_name ) const |
463 | { |
464 | if ( uno_name == "com.sun.star.uno.XInterface" ) |
465 | { |
466 | return m_XInterface_type_info; |
467 | } |
468 | |
469 | JNI_type_info const * info; |
470 | ClearableMutexGuard guard( m_mutex ); |
471 | t_str2type::const_iterator iFind( m_type_map.find( uno_name ) ); |
472 | if (iFind == m_type_map.end()) |
473 | { |
474 | guard.clear(); |
475 | css::uno::TypeDescription td( uno_name ); |
476 | if (! td.is()) |
477 | { |
478 | OUStringBuffer buf( 128 ); |
479 | buf.appendAscii( |
480 | RTL_CONSTASCII_STRINGPARAM("UNO type not found: ")(&("UNO type not found: ")[0]), ((sal_Int32)(sizeof ("UNO type not found: " ) / sizeof (("UNO type not found: ")[0]))-1) ); |
481 | buf.append( uno_name ); |
482 | buf.append( jni.get_stack_trace() ); |
483 | throw BridgeRuntimeError( buf.makeStringAndClear() ); |
484 | } |
485 | info = create_type_info( jni, td.get() ); |
486 | } |
487 | else |
488 | { |
489 | info = iFind->second.m_info; |
490 | } |
491 | |
492 | return info; |
493 | } |
494 | |
495 | //______________________________________________________________________________ |
496 | JNI_info::JNI_info( |
497 | JNIEnv * jni_env, jobject class_loader, jclass classClass, |
498 | jmethodID methodForName ) |
499 | : m_class_Class( classClass ), |
500 | m_method_Class_forName( methodForName ), |
501 | m_class_JNI_proxy( 0 ), |
502 | m_XInterface_queryInterface_td( |
503 | (reinterpret_cast< typelib_InterfaceTypeDescription * >( |
504 | css::uno::TypeDescription( |
505 | ::getCppuType( |
506 | (css::uno::Reference< css::uno::XInterface > const *)0 ) ) |
507 | .get())->ppMembers[ 0 ] ) ), |
508 | m_Exception_type( ::getCppuType( (css::uno::Exception const *)0 ) ), |
509 | m_RuntimeException_type( |
510 | ::getCppuType( (css::uno::RuntimeException const *)0 ) ), |
511 | m_void_type( ::getCppuVoidType() ), |
512 | m_XInterface_type_info( 0 ) |
513 | { |
514 | JNI_context jni( this, jni_env, class_loader ); // !no proper jni_info! |
515 | |
516 | // class lookup |
517 | JLocalAutoRef jo_Object( |
518 | jni, find_class( jni, "java.lang.Object" ) ); |
519 | JLocalAutoRef jo_Class( |
520 | jni, find_class( jni, "java.lang.Class" ) ); |
521 | JLocalAutoRef jo_Throwable( |
522 | jni, find_class( jni, "java.lang.Throwable" ) ); |
523 | JLocalAutoRef jo_Character( |
524 | jni, find_class( jni, "java.lang.Character" ) ); |
525 | JLocalAutoRef jo_Boolean( |
526 | jni, find_class( jni, "java.lang.Boolean" ) ); |
527 | JLocalAutoRef jo_Byte( |
528 | jni, find_class( jni, "java.lang.Byte" ) ); |
529 | JLocalAutoRef jo_Short( |
530 | jni, find_class( jni, "java.lang.Short" ) ); |
531 | JLocalAutoRef jo_Integer( |
532 | jni, find_class( jni, "java.lang.Integer" ) ); |
533 | JLocalAutoRef jo_Long( |
534 | jni, find_class( jni, "java.lang.Long" ) ); |
535 | JLocalAutoRef jo_Float( |
536 | jni, find_class( jni, "java.lang.Float" ) ); |
537 | JLocalAutoRef jo_Double( |
538 | jni, find_class( jni, "java.lang.Double" ) ); |
539 | JLocalAutoRef jo_String( |
540 | jni, find_class( jni, "java.lang.String" ) ); |
541 | JLocalAutoRef jo_RuntimeException( |
542 | jni, find_class( jni, "com.sun.star.uno.RuntimeException" ) ); |
543 | JLocalAutoRef jo_UnoRuntime( |
544 | jni, find_class( jni, "com.sun.star.uno.UnoRuntime" ) ); |
545 | JLocalAutoRef jo_Any( |
546 | jni, find_class( jni, "com.sun.star.uno.Any" ) ); |
547 | JLocalAutoRef jo_Enum( |
548 | jni, find_class( jni, "com.sun.star.uno.Enum" ) ); |
549 | JLocalAutoRef jo_Type( |
550 | jni, find_class( jni, "com.sun.star.uno.Type" ) ); |
551 | JLocalAutoRef jo_TypeClass( |
552 | jni, find_class( jni, "com.sun.star.uno.TypeClass" ) ); |
553 | JLocalAutoRef jo_IEnvironment( |
554 | jni, find_class( jni, "com.sun.star.uno.IEnvironment" ) ); |
555 | JLocalAutoRef jo_JNI_proxy( |
556 | jni, find_class( jni, "com.sun.star.bridges.jni_uno.JNI_proxy" ) ); |
557 | |
558 | // method Object.toString() |
559 | m_method_Object_toString = jni->GetMethodID( |
560 | (jclass) jo_Object.get(), "toString", "()Ljava/lang/String;" ); |
561 | jni.ensure_no_exception(); |
562 | OSL_ASSERT( 0 != m_method_Object_toString )do { if (true && (!(0 != m_method_Object_toString))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "562" ": "), "OSL_ASSERT: %s", "0 != m_method_Object_toString" ); } } while (false); |
563 | // method Class.getName() |
564 | m_method_Class_getName = jni->GetMethodID( |
565 | (jclass) jo_Class.get(), "getName", "()Ljava/lang/String;" ); |
566 | jni.ensure_no_exception(); |
567 | OSL_ASSERT( 0 != m_method_Class_getName )do { if (true && (!(0 != m_method_Class_getName))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "567" ": "), "OSL_ASSERT: %s", "0 != m_method_Class_getName" ); } } while (false); |
568 | |
569 | // method Throwable.getMessage() |
570 | m_method_Throwable_getMessage = jni->GetMethodID( |
571 | (jclass) jo_Throwable.get(), "getMessage", "()Ljava/lang/String;" ); |
572 | jni.ensure_no_exception(); |
573 | OSL_ASSERT( 0 != m_method_Throwable_getMessage )do { if (true && (!(0 != m_method_Throwable_getMessage ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "573" ": "), "OSL_ASSERT: %s", "0 != m_method_Throwable_getMessage" ); } } while (false); |
574 | |
575 | // method Character.charValue() |
576 | m_method_Character_charValue = jni->GetMethodID( |
577 | (jclass) jo_Character.get(), "charValue", "()C" ); |
578 | jni.ensure_no_exception(); |
579 | OSL_ASSERT( 0 != m_method_Character_charValue )do { if (true && (!(0 != m_method_Character_charValue ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "579" ": "), "OSL_ASSERT: %s", "0 != m_method_Character_charValue" ); } } while (false); |
580 | // method Boolean.booleanValue() |
581 | m_method_Boolean_booleanValue = jni->GetMethodID( |
582 | (jclass) jo_Boolean.get(), "booleanValue", "()Z" ); |
583 | jni.ensure_no_exception(); |
584 | OSL_ASSERT( 0 != m_method_Boolean_booleanValue )do { if (true && (!(0 != m_method_Boolean_booleanValue ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "584" ": "), "OSL_ASSERT: %s", "0 != m_method_Boolean_booleanValue" ); } } while (false); |
585 | // method Byte.byteValue() |
586 | m_method_Byte_byteValue = jni->GetMethodID( |
587 | (jclass) jo_Byte.get(), "byteValue", "()B" ); |
588 | jni.ensure_no_exception(); |
589 | OSL_ASSERT( 0 != m_method_Byte_byteValue )do { if (true && (!(0 != m_method_Byte_byteValue))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "589" ": "), "OSL_ASSERT: %s", "0 != m_method_Byte_byteValue" ); } } while (false); |
590 | // method Short.shortValue() |
591 | m_method_Short_shortValue = jni->GetMethodID( |
592 | (jclass) jo_Short.get(), "shortValue", "()S" ); |
593 | jni.ensure_no_exception(); |
594 | OSL_ASSERT( 0 != m_method_Short_shortValue )do { if (true && (!(0 != m_method_Short_shortValue))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "594" ": "), "OSL_ASSERT: %s", "0 != m_method_Short_shortValue" ); } } while (false); |
595 | // method Integer.intValue() |
596 | m_method_Integer_intValue = jni->GetMethodID( |
597 | (jclass) jo_Integer.get(), "intValue", "()I" ); |
598 | jni.ensure_no_exception(); |
599 | OSL_ASSERT( 0 != m_method_Integer_intValue )do { if (true && (!(0 != m_method_Integer_intValue))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "599" ": "), "OSL_ASSERT: %s", "0 != m_method_Integer_intValue" ); } } while (false); |
600 | // method Long.longValue() |
601 | m_method_Long_longValue = jni->GetMethodID( |
602 | (jclass) jo_Long.get(), "longValue", "()J" ); |
603 | jni.ensure_no_exception(); |
604 | OSL_ASSERT( 0 != m_method_Long_longValue )do { if (true && (!(0 != m_method_Long_longValue))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "604" ": "), "OSL_ASSERT: %s", "0 != m_method_Long_longValue" ); } } while (false); |
605 | // method Float.floatValue() |
606 | m_method_Float_floatValue = jni->GetMethodID( |
607 | (jclass) jo_Float.get(), "floatValue", "()F" ); |
608 | jni.ensure_no_exception(); |
609 | OSL_ASSERT( 0 != m_method_Float_floatValue )do { if (true && (!(0 != m_method_Float_floatValue))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "609" ": "), "OSL_ASSERT: %s", "0 != m_method_Float_floatValue" ); } } while (false); |
610 | // method Double.doubleValue() |
611 | m_method_Double_doubleValue = jni->GetMethodID( |
612 | (jclass) jo_Double.get(), "doubleValue", "()D" ); |
613 | jni.ensure_no_exception(); |
614 | OSL_ASSERT( 0 != m_method_Double_doubleValue )do { if (true && (!(0 != m_method_Double_doubleValue) )) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "614" ": "), "OSL_ASSERT: %s", "0 != m_method_Double_doubleValue" ); } } while (false); |
615 | |
616 | // ctor Character( char ) |
617 | m_ctor_Character_with_char = jni->GetMethodID( |
618 | (jclass) jo_Character.get(), "<init>", "(C)V" ); |
619 | jni.ensure_no_exception(); |
620 | OSL_ASSERT( 0 != m_ctor_Character_with_char )do { if (true && (!(0 != m_ctor_Character_with_char)) ) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "620" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Character_with_char" ); } } while (false); |
621 | // ctor Boolean( boolean ) |
622 | m_ctor_Boolean_with_boolean = jni->GetMethodID( |
623 | (jclass) jo_Boolean.get(), "<init>", "(Z)V" ); |
624 | jni.ensure_no_exception(); |
625 | OSL_ASSERT( 0 != m_ctor_Boolean_with_boolean )do { if (true && (!(0 != m_ctor_Boolean_with_boolean) )) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "625" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Boolean_with_boolean" ); } } while (false); |
626 | // ctor Byte( byte ) |
627 | m_ctor_Byte_with_byte = jni->GetMethodID( |
628 | (jclass) jo_Byte.get(), "<init>", "(B)V" ); |
629 | jni.ensure_no_exception(); |
630 | OSL_ASSERT( 0 != m_ctor_Byte_with_byte )do { if (true && (!(0 != m_ctor_Byte_with_byte))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "630" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Byte_with_byte" ); } } while (false); |
631 | // ctor Short( short ) |
632 | m_ctor_Short_with_short = jni->GetMethodID( |
633 | (jclass) jo_Short.get(), "<init>", "(S)V" ); |
634 | jni.ensure_no_exception(); |
635 | OSL_ASSERT( 0 != m_ctor_Short_with_short )do { if (true && (!(0 != m_ctor_Short_with_short))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "635" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Short_with_short" ); } } while (false); |
636 | // ctor Integer( int ) |
637 | m_ctor_Integer_with_int = jni->GetMethodID( |
638 | (jclass) jo_Integer.get(), "<init>", "(I)V" ); |
639 | jni.ensure_no_exception(); |
640 | OSL_ASSERT( 0 != m_ctor_Integer_with_int )do { if (true && (!(0 != m_ctor_Integer_with_int))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "640" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Integer_with_int" ); } } while (false); |
641 | // ctor Long( long ) |
642 | m_ctor_Long_with_long = jni->GetMethodID( |
643 | (jclass) jo_Long.get(), "<init>", "(J)V" ); |
644 | jni.ensure_no_exception(); |
645 | OSL_ASSERT( 0 != m_ctor_Long_with_long )do { if (true && (!(0 != m_ctor_Long_with_long))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "645" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Long_with_long" ); } } while (false); |
646 | // ctor Float( float ) |
647 | m_ctor_Float_with_float = jni->GetMethodID( |
648 | (jclass) jo_Float.get(), "<init>", "(F)V" ); |
649 | jni.ensure_no_exception(); |
650 | OSL_ASSERT( 0 != m_ctor_Float_with_float )do { if (true && (!(0 != m_ctor_Float_with_float))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "650" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Float_with_float" ); } } while (false); |
651 | // ctor Double( double ) |
652 | m_ctor_Double_with_double = jni->GetMethodID( |
653 | (jclass) jo_Double.get(), "<init>", "(D)V" ); |
654 | jni.ensure_no_exception(); |
655 | OSL_ASSERT( 0 != m_ctor_Double_with_double )do { if (true && (!(0 != m_ctor_Double_with_double))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "655" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Double_with_double" ); } } while (false); |
656 | |
657 | // static method UnoRuntime.generateOid() |
658 | m_method_UnoRuntime_generateOid = jni->GetStaticMethodID( |
659 | (jclass) jo_UnoRuntime.get(), |
660 | "generateOid", "(Ljava/lang/Object;)Ljava/lang/String;" ); |
661 | jni.ensure_no_exception(); |
662 | OSL_ASSERT( 0 != m_method_UnoRuntime_generateOid )do { if (true && (!(0 != m_method_UnoRuntime_generateOid ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "662" ": "), "OSL_ASSERT: %s", "0 != m_method_UnoRuntime_generateOid" ); } } while (false); |
663 | // static method UnoRuntime.queryInterface() |
664 | m_method_UnoRuntime_queryInterface = jni->GetStaticMethodID( |
665 | (jclass) jo_UnoRuntime.get(), |
666 | "queryInterface", |
667 | "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)Ljava/lang/Object;" ); |
668 | jni.ensure_no_exception(); |
669 | OSL_ASSERT( 0 != m_method_UnoRuntime_queryInterface )do { if (true && (!(0 != m_method_UnoRuntime_queryInterface ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "669" ": "), "OSL_ASSERT: %s", "0 != m_method_UnoRuntime_queryInterface" ); } } while (false); |
670 | |
671 | // field Enum.m_value |
672 | m_field_Enum_m_value = jni->GetFieldID( |
673 | (jclass) jo_Enum.get(), "m_value", "I" ); |
674 | jni.ensure_no_exception(); |
675 | OSL_ASSERT( 0 != m_field_Enum_m_value )do { if (true && (!(0 != m_field_Enum_m_value))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "675" ": "), "OSL_ASSERT: %s", "0 != m_field_Enum_m_value" ); } } while (false); |
676 | |
677 | // static method TypeClass.fromInt() |
678 | m_method_TypeClass_fromInt = jni->GetStaticMethodID( |
679 | (jclass) jo_TypeClass.get(), |
680 | "fromInt", "(I)Lcom/sun/star/uno/TypeClass;" ); |
681 | jni.ensure_no_exception(); |
682 | OSL_ASSERT( 0 != m_method_TypeClass_fromInt )do { if (true && (!(0 != m_method_TypeClass_fromInt)) ) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "682" ": "), "OSL_ASSERT: %s", "0 != m_method_TypeClass_fromInt" ); } } while (false); |
683 | |
684 | // ctor Type( Class ) |
685 | m_ctor_Type_with_Class = jni->GetMethodID( |
686 | (jclass) jo_Type.get(), "<init>", "(Ljava/lang/Class;)V" ); |
687 | jni.ensure_no_exception(); |
688 | OSL_ASSERT( 0 != m_ctor_Type_with_Class )do { if (true && (!(0 != m_ctor_Type_with_Class))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "688" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Type_with_Class" ); } } while (false); |
689 | // ctor Type( String, TypeClass ) |
690 | m_ctor_Type_with_Name_TypeClass = jni->GetMethodID( |
691 | (jclass) jo_Type.get(), |
692 | "<init>", "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V" ); |
693 | jni.ensure_no_exception(); |
694 | OSL_ASSERT( 0 != m_ctor_Type_with_Name_TypeClass )do { if (true && (!(0 != m_ctor_Type_with_Name_TypeClass ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "694" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Type_with_Name_TypeClass" ); } } while (false); |
695 | // field Type._typeName |
696 | m_field_Type__typeName = jni->GetFieldID( |
697 | (jclass) jo_Type.get(), "_typeName", "Ljava/lang/String;" ); |
698 | jni.ensure_no_exception(); |
699 | OSL_ASSERT( 0 != m_field_Type__typeName )do { if (true && (!(0 != m_field_Type__typeName))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "699" ": "), "OSL_ASSERT: %s", "0 != m_field_Type__typeName" ); } } while (false); |
700 | |
701 | // ctor Any( Type, Object ) |
702 | m_ctor_Any_with_Type_Object = jni->GetMethodID( |
703 | (jclass) jo_Any.get(), |
704 | "<init>", "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V" ); |
705 | jni.ensure_no_exception(); |
706 | OSL_ASSERT( 0 != m_ctor_Any_with_Type_Object )do { if (true && (!(0 != m_ctor_Any_with_Type_Object) )) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "706" ": "), "OSL_ASSERT: %s", "0 != m_ctor_Any_with_Type_Object" ); } } while (false); |
707 | |
708 | // field Any._type |
709 | m_field_Any__type = jni->GetFieldID( |
710 | (jclass) jo_Any.get(), "_type", "Lcom/sun/star/uno/Type;" ); |
711 | jni.ensure_no_exception(); |
712 | OSL_ASSERT( 0 != m_field_Any__type )do { if (true && (!(0 != m_field_Any__type))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "712" ": "), "OSL_ASSERT: %s", "0 != m_field_Any__type") ; } } while (false); |
713 | // field Any._object |
714 | m_field_Any__object = jni->GetFieldID( |
715 | (jclass) jo_Any.get(), "_object", "Ljava/lang/Object;" ); |
716 | jni.ensure_no_exception(); |
717 | OSL_ASSERT( 0 != m_field_Any__object )do { if (true && (!(0 != m_field_Any__object))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "717" ": "), "OSL_ASSERT: %s", "0 != m_field_Any__object" ); } } while (false); |
718 | |
719 | // method IEnvironment.getRegisteredInterface() |
720 | m_method_IEnvironment_getRegisteredInterface = jni->GetMethodID( |
721 | (jclass) jo_IEnvironment.get(), |
722 | "getRegisteredInterface", |
723 | "(Ljava/lang/String;Lcom/sun/star/uno/Type;)Ljava/lang/Object;" ); |
724 | jni.ensure_no_exception(); |
725 | OSL_ASSERT( 0 != m_method_IEnvironment_getRegisteredInterface )do { if (true && (!(0 != m_method_IEnvironment_getRegisteredInterface ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "725" ": "), "OSL_ASSERT: %s", "0 != m_method_IEnvironment_getRegisteredInterface" ); } } while (false); |
726 | // method IEnvironment.registerInterface() |
727 | m_method_IEnvironment_registerInterface = jni->GetMethodID( |
728 | (jclass) jo_IEnvironment.get(), "registerInterface", |
729 | "(Ljava/lang/Object;[Ljava/lang/String;Lcom/sun/star/uno/Type;)" |
730 | "Ljava/lang/Object;" ); |
731 | jni.ensure_no_exception(); |
732 | OSL_ASSERT( 0 != m_method_IEnvironment_registerInterface )do { if (true && (!(0 != m_method_IEnvironment_registerInterface ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "732" ": "), "OSL_ASSERT: %s", "0 != m_method_IEnvironment_registerInterface" ); } } while (false); |
733 | |
734 | // static method JNI_proxy.get_proxy_ctor() |
735 | m_method_JNI_proxy_get_proxy_ctor = jni->GetStaticMethodID( |
736 | (jclass) jo_JNI_proxy.get(), "get_proxy_ctor", |
737 | "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;" ); |
738 | jni.ensure_no_exception(); |
739 | OSL_ASSERT( 0 != m_method_JNI_proxy_get_proxy_ctor )do { if (true && (!(0 != m_method_JNI_proxy_get_proxy_ctor ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "739" ": "), "OSL_ASSERT: %s", "0 != m_method_JNI_proxy_get_proxy_ctor" ); } } while (false); |
740 | // static method JNI_proxy.create() |
741 | m_method_JNI_proxy_create = jni->GetStaticMethodID( |
742 | (jclass) jo_JNI_proxy.get(), "create", |
743 | "(JLcom/sun/star/uno/IEnvironment;JJLcom/sun/star/uno/Type;Ljava/lang" |
744 | "/String;Ljava/lang/reflect/Constructor;)Ljava/lang/Object;" ); |
745 | jni.ensure_no_exception(); |
746 | OSL_ASSERT( 0 != m_method_JNI_proxy_create )do { if (true && (!(0 != m_method_JNI_proxy_create))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "746" ": "), "OSL_ASSERT: %s", "0 != m_method_JNI_proxy_create" ); } } while (false); |
747 | // field JNI_proxy.m_receiver_handle |
748 | m_field_JNI_proxy_m_receiver_handle = jni->GetFieldID( |
749 | (jclass) jo_JNI_proxy.get(), "m_receiver_handle", "J" ); |
750 | jni.ensure_no_exception(); |
751 | OSL_ASSERT( 0 != m_field_JNI_proxy_m_receiver_handle )do { if (true && (!(0 != m_field_JNI_proxy_m_receiver_handle ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "751" ": "), "OSL_ASSERT: %s", "0 != m_field_JNI_proxy_m_receiver_handle" ); } } while (false); |
752 | // field JNI_proxy.m_td_handle |
753 | m_field_JNI_proxy_m_td_handle = jni->GetFieldID( |
754 | (jclass) jo_JNI_proxy.get(), "m_td_handle", "J" ); |
755 | jni.ensure_no_exception(); |
756 | OSL_ASSERT( 0 != m_field_JNI_proxy_m_td_handle )do { if (true && (!(0 != m_field_JNI_proxy_m_td_handle ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "756" ": "), "OSL_ASSERT: %s", "0 != m_field_JNI_proxy_m_td_handle" ); } } while (false); |
757 | // field JNI_proxy.m_type |
758 | m_field_JNI_proxy_m_type = jni->GetFieldID( |
759 | (jclass) jo_JNI_proxy.get(), "m_type", "Lcom/sun/star/uno/Type;" ); |
760 | jni.ensure_no_exception(); |
761 | OSL_ASSERT( 0 != m_field_JNI_proxy_m_type )do { if (true && (!(0 != m_field_JNI_proxy_m_type))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "761" ": "), "OSL_ASSERT: %s", "0 != m_field_JNI_proxy_m_type" ); } } while (false); |
762 | // field JNI_proxy.m_oid |
763 | m_field_JNI_proxy_m_oid = jni->GetFieldID( |
764 | (jclass) jo_JNI_proxy.get(), "m_oid", "Ljava/lang/String;" ); |
765 | jni.ensure_no_exception(); |
766 | OSL_ASSERT( 0 != m_field_JNI_proxy_m_oid )do { if (true && (!(0 != m_field_JNI_proxy_m_oid))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "766" ": "), "OSL_ASSERT: %s", "0 != m_field_JNI_proxy_m_oid" ); } } while (false); |
767 | |
768 | // get java env |
769 | OUString java_env_type_name( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_JAVA)(&("java")[0]), ((sal_Int32)((sizeof ("java") / sizeof (( "java")[0]))-1)), (((rtl_TextEncoding) 11)) ); |
770 | JLocalAutoRef jo_java( |
771 | jni, ustring_to_jstring( jni, java_env_type_name.pData ) ); |
772 | jvalue args[ 2 ]; |
773 | args[ 0 ].l = jo_java.get(); |
774 | args[ 1 ].l = 0; |
775 | jmethodID method_getEnvironment = jni->GetStaticMethodID( |
776 | (jclass) jo_UnoRuntime.get(), "getEnvironment", |
777 | "(Ljava/lang/String;Ljava/lang/Object;)" |
778 | "Lcom/sun/star/uno/IEnvironment;" ); |
779 | jni.ensure_no_exception(); |
780 | OSL_ASSERT( 0 != method_getEnvironment )do { if (true && (!(0 != method_getEnvironment))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "780" ": "), "OSL_ASSERT: %s", "0 != method_getEnvironment" ); } } while (false); |
781 | JLocalAutoRef jo_java_env( |
782 | jni, jni->CallStaticObjectMethodA( |
783 | (jclass) jo_UnoRuntime.get(), method_getEnvironment, args ) ); |
784 | |
785 | // get com.sun.star.uno.Any.VOID |
786 | jfieldID field_Any_VOID = jni->GetStaticFieldID( |
787 | (jclass) jo_Any.get(), "VOID", "Lcom/sun/star/uno/Any;" ); |
788 | jni.ensure_no_exception(); |
789 | OSL_ASSERT( 0 != field_Any_VOID )do { if (true && (!(0 != field_Any_VOID))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "789" ": "), "OSL_ASSERT: %s", "0 != field_Any_VOID"); } } while (false); |
790 | JLocalAutoRef jo_Any_VOID( |
791 | jni, jni->GetStaticObjectField( |
792 | (jclass) jo_Any.get(), field_Any_VOID ) ); |
793 | // get com.sun.star.uno.Type.UNSIGNED_SHORT |
794 | jfieldID field_Type_UNSIGNED_SHORT = jni->GetStaticFieldID( |
795 | (jclass) jo_Type.get(), "UNSIGNED_SHORT", "Lcom/sun/star/uno/Type;" ); |
796 | jni.ensure_no_exception(); |
797 | OSL_ASSERT( 0 != field_Type_UNSIGNED_SHORT )do { if (true && (!(0 != field_Type_UNSIGNED_SHORT))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "797" ": "), "OSL_ASSERT: %s", "0 != field_Type_UNSIGNED_SHORT" ); } } while (false); |
798 | JLocalAutoRef jo_Type_UNSIGNED_SHORT( |
799 | jni, jni->GetStaticObjectField( |
800 | (jclass) jo_Type.get(), field_Type_UNSIGNED_SHORT ) ); |
801 | // get com.sun.star.uno.Type.UNSIGNED_LONG |
802 | jfieldID field_Type_UNSIGNED_LONG = jni->GetStaticFieldID( |
803 | (jclass) jo_Type.get(), "UNSIGNED_LONG", "Lcom/sun/star/uno/Type;" ); |
804 | jni.ensure_no_exception(); |
805 | OSL_ASSERT( 0 != field_Type_UNSIGNED_LONG )do { if (true && (!(0 != field_Type_UNSIGNED_LONG))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "805" ": "), "OSL_ASSERT: %s", "0 != field_Type_UNSIGNED_LONG" ); } } while (false); |
806 | JLocalAutoRef jo_Type_UNSIGNED_LONG( |
807 | jni, jni->GetStaticObjectField( |
808 | (jclass) jo_Type.get(), field_Type_UNSIGNED_LONG ) ); |
809 | // get com.sun.star.uno.Type.UNSIGNED_HYPER |
810 | jfieldID field_Type_UNSIGNED_HYPER = jni->GetStaticFieldID( |
811 | (jclass) jo_Type.get(), "UNSIGNED_HYPER", "Lcom/sun/star/uno/Type;" ); |
812 | jni.ensure_no_exception(); |
813 | OSL_ASSERT( 0 != field_Type_UNSIGNED_HYPER )do { if (true && (!(0 != field_Type_UNSIGNED_HYPER))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "813" ": "), "OSL_ASSERT: %s", "0 != field_Type_UNSIGNED_HYPER" ); } } while (false); |
814 | JLocalAutoRef jo_Type_UNSIGNED_HYPER( |
815 | jni, jni->GetStaticObjectField( |
816 | (jclass) jo_Type.get(), field_Type_UNSIGNED_HYPER ) ); |
817 | |
818 | // make global refs |
819 | m_class_UnoRuntime = |
820 | (jclass) jni->NewGlobalRef( jo_UnoRuntime.get() ); |
821 | m_class_RuntimeException = |
822 | (jclass) jni->NewGlobalRef( jo_RuntimeException.get() ); |
823 | m_class_Any = |
824 | (jclass) jni->NewGlobalRef( jo_Any.get() ); |
825 | m_class_Type = |
826 | (jclass) jni->NewGlobalRef( jo_Type.get() ); |
827 | m_class_TypeClass = |
828 | (jclass) jni->NewGlobalRef( jo_TypeClass.get() ); |
829 | m_class_JNI_proxy = |
830 | (jclass) jni->NewGlobalRef( jo_JNI_proxy.get() ); |
831 | |
832 | m_class_Character = |
833 | (jclass) jni->NewGlobalRef( jo_Character.get() ); |
834 | m_class_Boolean = |
835 | (jclass) jni->NewGlobalRef( jo_Boolean.get() ); |
836 | m_class_Byte = |
837 | (jclass) jni->NewGlobalRef( jo_Byte.get() ); |
838 | m_class_Short = |
839 | (jclass) jni->NewGlobalRef( jo_Short.get() ); |
840 | m_class_Integer = |
841 | (jclass) jni->NewGlobalRef( jo_Integer.get() ); |
842 | m_class_Long = |
843 | (jclass) jni->NewGlobalRef( jo_Long.get() ); |
844 | m_class_Float = |
845 | (jclass) jni->NewGlobalRef( jo_Float.get() ); |
846 | m_class_Double = |
847 | (jclass) jni->NewGlobalRef( jo_Double.get() ); |
848 | m_class_String = |
849 | (jclass) jni->NewGlobalRef( jo_String.get() ); |
850 | m_class_Object = |
851 | (jclass) jni->NewGlobalRef( jo_Object.get() ); |
852 | m_class_Class = |
853 | (jclass) jni->NewGlobalRef( m_class_Class ); |
854 | |
855 | m_object_Any_VOID = |
856 | jni->NewGlobalRef( jo_Any_VOID.get() ); |
857 | m_object_Type_UNSIGNED_SHORT = |
858 | jni->NewGlobalRef( jo_Type_UNSIGNED_SHORT.get() ); |
859 | m_object_Type_UNSIGNED_LONG = |
860 | jni->NewGlobalRef( jo_Type_UNSIGNED_LONG.get() ); |
861 | m_object_Type_UNSIGNED_HYPER = |
862 | jni->NewGlobalRef( jo_Type_UNSIGNED_HYPER.get() ); |
863 | m_object_java_env = jni->NewGlobalRef( jo_java_env.get() ); |
864 | |
865 | try |
866 | { |
867 | css::uno::TypeDescription XInterface_td( |
868 | ::getCppuType( |
869 | (css::uno::Reference< css::uno::XInterface > const *)0 ) ); |
870 | m_XInterface_type_info = |
871 | new JNI_interface_type_info( jni, XInterface_td.get() ); |
872 | } |
873 | catch (...) |
874 | { |
875 | destruct( jni_env ); |
876 | throw; |
877 | } |
878 | } |
879 | |
880 | //______________________________________________________________________________ |
881 | void JNI_info::destruct( JNIEnv * jni_env ) |
882 | { |
883 | t_str2type::const_iterator iPos( m_type_map.begin() ); |
884 | t_str2type::const_iterator const iEnd( m_type_map.begin() ); |
885 | for ( ; iPos != iEnd; ++iPos ) |
886 | { |
887 | iPos->second.m_info->destroy( jni_env ); |
888 | } |
889 | if (0 != m_XInterface_type_info) |
890 | { |
891 | const_cast< JNI_interface_type_info * >( |
892 | m_XInterface_type_info )->destroy( jni_env ); |
893 | } |
894 | |
895 | // free global refs |
896 | jni_env->DeleteGlobalRef( m_object_java_env ); |
897 | jni_env->DeleteGlobalRef( m_object_Any_VOID ); |
898 | jni_env->DeleteGlobalRef( m_object_Type_UNSIGNED_SHORT ); |
899 | jni_env->DeleteGlobalRef( m_object_Type_UNSIGNED_LONG ); |
900 | jni_env->DeleteGlobalRef( m_object_Type_UNSIGNED_HYPER ); |
901 | |
902 | jni_env->DeleteGlobalRef( m_class_Class ); |
903 | jni_env->DeleteGlobalRef( m_class_Object ); |
904 | jni_env->DeleteGlobalRef( m_class_String ); |
905 | jni_env->DeleteGlobalRef( m_class_Double ); |
906 | jni_env->DeleteGlobalRef( m_class_Float ); |
907 | jni_env->DeleteGlobalRef( m_class_Long ); |
908 | jni_env->DeleteGlobalRef( m_class_Integer ); |
909 | jni_env->DeleteGlobalRef( m_class_Short ); |
910 | jni_env->DeleteGlobalRef( m_class_Byte ); |
911 | jni_env->DeleteGlobalRef( m_class_Boolean ); |
912 | jni_env->DeleteGlobalRef( m_class_Character ); |
913 | |
914 | jni_env->DeleteGlobalRef( m_class_JNI_proxy ); |
915 | jni_env->DeleteGlobalRef( m_class_RuntimeException ); |
916 | jni_env->DeleteGlobalRef( m_class_UnoRuntime ); |
917 | jni_env->DeleteGlobalRef( m_class_TypeClass ); |
918 | jni_env->DeleteGlobalRef( m_class_Type ); |
919 | jni_env->DeleteGlobalRef( m_class_Any ); |
920 | } |
921 | |
922 | //______________________________________________________________________________ |
923 | JNI_info const * JNI_info::get_jni_info( |
924 | rtl::Reference< jvmaccess::UnoVirtualMachine > const & uno_vm ) |
925 | { |
926 | // !!!no JNI_info available at JNI_context!!! |
927 | ::jvmaccess::VirtualMachine::AttachGuard guard( |
928 | uno_vm->getVirtualMachine() ); |
929 | JNIEnv * jni_env = guard.getEnvironment(); |
930 | JNI_context jni( |
931 | 0, jni_env, static_cast< jobject >(uno_vm->getClassLoader()) ); |
932 | |
933 | jclass jo_class; |
934 | jmethodID jo_forName; |
935 | jni.getClassForName( &jo_class, &jo_forName ); |
936 | jni.ensure_no_exception(); |
937 | JLocalAutoRef jo_JNI_info_holder( |
938 | jni, |
939 | jni.findClass( |
940 | "com.sun.star.bridges.jni_uno.JNI_info_holder", jo_class, |
941 | jo_forName, false ) ); |
942 | // field JNI_info_holder.m_jni_info_handle |
943 | jfieldID field_s_jni_info_handle = |
944 | jni->GetStaticFieldID( |
945 | (jclass) jo_JNI_info_holder.get(), "s_jni_info_handle", "J" ); |
946 | jni.ensure_no_exception(); |
947 | OSL_ASSERT( 0 != field_s_jni_info_handle )do { if (true && (!(0 != field_s_jni_info_handle))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/bridges/source/jni_uno/jni_info.cxx" ":" "947" ": "), "OSL_ASSERT: %s", "0 != field_s_jni_info_handle" ); } } while (false); |
948 | |
949 | JNI_info const * jni_info = |
950 | reinterpret_cast< JNI_info const * >( |
951 | jni->GetStaticLongField( |
952 | (jclass) jo_JNI_info_holder.get(), field_s_jni_info_handle ) ); |
953 | if (0 == jni_info) // un-initialized? |
954 | { |
955 | JNI_info * new_info = new JNI_info( |
956 | jni_env, static_cast< jobject >(uno_vm->getClassLoader()), jo_class, |
957 | jo_forName ); |
958 | |
959 | ClearableMutexGuard g( Mutex::getGlobalMutex() ); |
960 | jni_info = |
961 | reinterpret_cast< JNI_info const * >( |
962 | jni->GetStaticLongField( |
963 | (jclass) jo_JNI_info_holder.get(), |
964 | field_s_jni_info_handle ) ); |
965 | if (0 == jni_info) // still un-initialized? |
966 | { |
967 | jni->SetStaticLongField( |
968 | (jclass) jo_JNI_info_holder.get(), field_s_jni_info_handle, |
969 | reinterpret_cast< jlong >( new_info ) ); |
970 | jni_info = new_info; |
971 | } |
972 | else |
973 | { |
974 | g.clear(); |
975 | new_info->destroy( jni_env ); |
976 | } |
977 | } |
978 | |
979 | return jni_info; |
980 | } |
981 | |
982 | } |
983 | |
984 | extern "C" |
985 | { |
986 | |
987 | //------------------------------------------------------------------------------ |
988 | JNIEXPORT void |
989 | JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1info_1holder_finalize__J( |
990 | JNIEnv * jni_env, SAL_UNUSED_PARAMETER__attribute__ ((unused)) jobject, jlong jni_info_handle ) |
991 | SAL_THROW_EXTERN_C()throw () |
992 | { |
993 | ::jni_uno::JNI_info * jni_info = |
994 | reinterpret_cast< ::jni_uno::JNI_info * >( jni_info_handle ); |
995 | jni_info->destroy( jni_env ); |
996 | } |
997 | |
998 | } |
999 | |
1000 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |