LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/javaunohelper/source - preload.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 37 0.0 %
Date: 2013-07-09 Functions: 0 5 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 "sal/config.h"
      21             : 
      22             : #include "jni.h"
      23             : 
      24             : #include "rtl/ustring.hxx"
      25             : #include "osl/module.h"
      26             : 
      27             : #include "juhx-export-types.hxx"
      28             : 
      29             : // In retrospect, the reason to create a juh wrapper around the juhx library was
      30             : // probably because java.lang.System.loadLibrary uses RTLD_LOCAL, so uniqueness
      31             : // of GCC RTTI symbols needed for exception handling would not be guaranteed.
      32             : 
      33             : #if ! defined SAL_DLLPREFIX
      34             : #define SAL_DLLPREFIX ""
      35             : #endif
      36             : 
      37             : 
      38             : extern "C"
      39             : {
      40             : 
      41             : static javaunohelper::detail::Func_writeInfo * s_writeInfo;
      42             : static javaunohelper::detail::Func_getFactory * s_getFactory;
      43             : static javaunohelper::detail::Func_bootstrap * s_bootstrap;
      44             : static bool s_inited = false;
      45             : 
      46           0 : extern "C" { static void SAL_CALL thisModule() {} }
      47             : 
      48             : //--------------------------------------------------------------------------------------------------
      49           0 : static bool inited_juhx( JNIEnv * jni_env )
      50             : {
      51           0 :     if (s_inited)
      52           0 :         return true;
      53           0 :     OUString lib_name = SAL_DLLPREFIX "juhx" SAL_DLLEXTENSION;
      54             :     oslModule hModule =
      55           0 :         osl_loadModuleRelative( &thisModule, lib_name.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
      56           0 :     if (0 == hModule)
      57             :     {
      58           0 :         jclass c = jni_env->FindClass( "java/lang/RuntimeException" );
      59             :         jni_env->ThrowNew(
      60           0 :             c, "error loading " SAL_DLLPREFIX "juhx" SAL_DLLEXTENSION "!" );
      61           0 :         return false;
      62             :     }
      63             :     else
      64             :     {
      65             :         OUString symbol =
      66           0 :               "Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo";
      67             :         s_writeInfo = (javaunohelper::detail::Func_writeInfo *)osl_getFunctionSymbol(
      68           0 :             hModule, symbol.pData );
      69             :         symbol =
      70           0 :             "Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory";
      71             :         s_getFactory = (javaunohelper::detail::Func_getFactory *)osl_getFunctionSymbol(
      72           0 :             hModule, symbol.pData );
      73             :         symbol =
      74           0 :             "Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap";
      75             :         s_bootstrap =
      76           0 :             (javaunohelper::detail::Func_bootstrap *)osl_getFunctionSymbol( hModule, symbol.pData );
      77             : 
      78           0 :         if (0 == s_writeInfo ||
      79           0 :             0 == s_getFactory ||
      80           0 :             0 == s_bootstrap)
      81             :         {
      82           0 :             jclass c = jni_env->FindClass( "java/lang/RuntimeException" );
      83             :             jni_env->ThrowNew(
      84           0 :                 c, "error resolving symbols of " SAL_DLLPREFIX "juhx" SAL_DLLEXTENSION "!" );
      85           0 :             return false;
      86           0 :         }
      87             :     }
      88           0 :     s_inited = true;
      89           0 :     return true;
      90             : }
      91             : 
      92             : //==================================================================================================
      93             : SAL_DLLPUBLIC_EXPORT jboolean JNICALL
      94           0 : Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
      95             :     JNIEnv * pJEnv, jclass jClass, jstring jLibName, jobject jSMgr,
      96             :     jobject jRegKey, jobject loader )
      97             : {
      98           0 :     if (inited_juhx( pJEnv ))
      99             :         return (*s_writeInfo)(
     100           0 :             pJEnv, jClass, jLibName, jSMgr, jRegKey, loader );
     101           0 :     return JNI_FALSE;
     102             : }
     103             : //==================================================================================================
     104             : SAL_DLLPUBLIC_EXPORT jobject JNICALL
     105           0 : Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
     106             :     JNIEnv * pJEnv, jclass jClass, jstring jLibName, jstring jImplName,
     107             :     jobject jSMgr, jobject jRegKey, jobject loader )
     108             : {
     109           0 :     if (inited_juhx( pJEnv ))
     110             :         return (*s_getFactory)(
     111           0 :             pJEnv, jClass, jLibName, jImplName, jSMgr, jRegKey, loader );
     112           0 :     return 0;
     113             : }
     114             : //==================================================================================================
     115             : SAL_DLLPUBLIC_EXPORT jobject JNICALL
     116           0 : Java_com_sun_star_comp_helper_Bootstrap_cppuhelper_1bootstrap(
     117             :     JNIEnv * jni_env, jclass jClass, jstring juno_rc, jobjectArray jpairs,
     118             :     jobject loader )
     119             : {
     120           0 :     if (inited_juhx( jni_env ))
     121           0 :         return (*s_bootstrap)( jni_env, jClass, juno_rc, jpairs, loader );
     122           0 :     return 0;
     123             : }
     124             : }
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10