LCOV - code coverage report
Current view: top level - libreoffice/bridges/source/jni_uno - jni_info.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 427 0.0 %
Date: 2012-12-27 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10