LCOV - code coverage report
Current view: top level - jvmfwk/plugins/sunmajor/pluginlib - gnujre.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 103 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 162 0.0 %

           Branch data     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                 :            : 
      21                 :            : #include "osl/file.hxx"
      22                 :            : #include "osl/thread.h"
      23                 :            : #include "gnujre.hxx"
      24                 :            : #include "util.hxx"
      25                 :            : 
      26                 :            : using namespace std;
      27                 :            : using namespace osl;
      28                 :            : using ::rtl::OUString;
      29                 :            : using ::rtl::Reference;
      30                 :            : 
      31                 :            : namespace jfw_plugin
      32                 :            : {
      33                 :            : 
      34                 :          0 : Reference<VendorBase> GnuInfo::createInstance()
      35                 :            : {
      36         [ #  # ]:          0 :     return new GnuInfo;
      37                 :            : }
      38                 :            : 
      39                 :          0 : char const* const* GnuInfo::getJavaExePaths(int * size)
      40                 :            : {
      41                 :            :     static char const * ar[] = {
      42                 :            :         "gij",
      43                 :            :         "bin/gij",
      44                 :            :         "gij-4.3",
      45                 :            :         "bin/gij-4.3",
      46                 :            :         "gij-4.2",
      47                 :            :         "bin/gij-4.2",
      48                 :            :         "gij-4.1",
      49                 :            :         "bin/gij-4.1"
      50                 :            :     };
      51                 :          0 :     *size = sizeof (ar) / sizeof (char*);
      52                 :          0 :     return ar;
      53                 :            : }
      54                 :            : 
      55                 :            : #if defined(MIPS) && defined(OSL_LITENDIAN)
      56                 :            : #define GCJ_JFW_PLUGIN_ARCH "mipsel"
      57                 :            : #else
      58                 :            : #define GCJ_JFW_PLUGIN_ARCH JFW_PLUGIN_ARCH
      59                 :            : #endif
      60                 :            : 
      61                 :          0 : char const* const* GnuInfo::getRuntimePaths(int * size)
      62                 :            : {
      63                 :            :     static char const* ar[]= {
      64                 :            :         "/libjvm.so",
      65                 :            :         "/lib/" GCJ_JFW_PLUGIN_ARCH "/client/libjvm.so",
      66                 :            :         "/gcj-4.1.1/libjvm.so",
      67                 :            :         "/gcj-4.3-90/libjvm.so",
      68                 :            :         "/gcj-4.2-81/libjvm.so",
      69                 :            :         "/gcj-4.2/libjvm.so",
      70                 :            :         "/gcj-4.2.1/libjvm.so",
      71                 :            :         "/gcj-4.2.2/libjvm.so",
      72                 :            :         "/gcj-4.2.3/libjvm.so",
      73                 :            :         "/gcj-4.1-71/libjvm.so",
      74                 :            :         "/gcj-4_1/libjvm.so",
      75                 :            :         "/gcj-4.1/libjvm.so",
      76                 :            :         "/libgcj.so.81",
      77                 :            :         "/libgcj.so.80",
      78                 :            :         "/libgcj.so.8",
      79                 :            :         "/libgcj.so.71",
      80                 :            :         "/libgcj.so.70",
      81                 :            :         "/libgcj.so.7",
      82                 :            :         "/libgcj.so.6"
      83                 :            :     };
      84                 :          0 :     *size = sizeof(ar) / sizeof (char*);
      85                 :          0 :     return ar;
      86                 :            : }
      87                 :            : 
      88                 :          0 : bool GnuInfo::initialize(vector<pair<OUString, OUString> > props)
      89                 :            : {
      90                 :            :     //get java.vendor, java.version, java.home,
      91                 :            :     //javax.accessibility.assistive_technologies from system properties
      92                 :            : 
      93                 :          0 :     OUString sJavaLibraryPath;
      94                 :            :     typedef vector<pair<OUString, OUString> >::const_iterator it_prop;
      95                 :            :     OUString sVendorProperty(
      96         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("java.vendor"));
      97                 :            :     OUString sVersionProperty(
      98         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("java.version"));
      99                 :            :     OUString sJavaHomeProperty(
     100         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("java.home"));
     101                 :            :     OUString sJavaLibraryPathProperty(
     102         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("java.library.path"));
     103                 :            :     OUString sGNUHomeProperty(
     104         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("gnu.classpath.home.url"));
     105                 :            :     OUString sAccessProperty(
     106         [ #  # ]:          0 :         RTL_CONSTASCII_USTRINGPARAM("javax.accessibility.assistive_technologies"));
     107                 :            : 
     108                 :          0 :     bool bVersion = false;
     109                 :          0 :     bool bVendor = false;
     110                 :          0 :     bool bHome = false;
     111                 :          0 :     bool bJavaHome = false;
     112                 :          0 :     bool bJavaLibraryPath = false;
     113                 :          0 :     bool bAccess = false;
     114                 :            : 
     115                 :            :     typedef vector<pair<OUString, OUString> >::const_iterator it_prop;
     116 [ #  # ][ #  # ]:          0 :     for (it_prop i = props.begin(); i != props.end(); ++i)
                 [ #  # ]
     117                 :            :     {
     118 [ #  # ][ #  # ]:          0 :         if(! bVendor && sVendorProperty.equals(i->first))
                 [ #  # ]
     119                 :            :         {
     120                 :          0 :             m_sVendor = i->second;
     121                 :          0 :             bVendor = true;
     122                 :            :         }
     123 [ #  # ][ #  # ]:          0 :         else if (!bVersion && sVersionProperty.equals(i->first))
                 [ #  # ]
     124                 :            :         {
     125                 :          0 :             m_sVersion = i->second;
     126                 :          0 :             bVersion = true;
     127                 :            :         }
     128 [ #  # ][ #  # ]:          0 :         else if (!bHome && sGNUHomeProperty.equals(i->first))
                 [ #  # ]
     129                 :            :         {
     130                 :          0 :             m_sHome = i->second;
     131                 :          0 :             bHome = true;
     132                 :            :         }
     133 [ #  # ][ #  # ]:          0 :         else if (!bJavaHome && sJavaHomeProperty.equals(i->first))
                 [ #  # ]
     134                 :            :         {
     135                 :          0 :            OUString fileURL;
     136 [ #  # ][ #  # ]:          0 :            if (osl_getFileURLFromSystemPath(i->second.pData,& fileURL.pData) ==
     137                 :            :                osl_File_E_None)
     138                 :            :            {
     139                 :            :                //make sure that the drive letter have all the same case
     140                 :            :                //otherwise file:///c:/jre and file:///C:/jre produce two
     141                 :            :                //different objects!!!
     142 [ #  # ][ #  # ]:          0 :                if (makeDriveLetterSame( & fileURL))
     143                 :            :                {
     144                 :          0 :                    m_sJavaHome = fileURL;
     145                 :          0 :                    bJavaHome = true;
     146                 :            :                }
     147                 :          0 :            }
     148                 :            :         }
     149 [ #  # ][ #  # ]:          0 :         else if (!bJavaLibraryPath && sJavaLibraryPathProperty.equals(i->first))
                 [ #  # ]
     150                 :            :         {
     151                 :          0 :             sal_Int32 nIndex = 0;
     152         [ #  # ]:          0 :             osl_getFileURLFromSystemPath(i->second.getToken(0, ':', nIndex).pData, &sJavaLibraryPath.pData);
     153                 :          0 :             bJavaLibraryPath = true;
     154                 :            :         }
     155 [ #  # ][ #  # ]:          0 :         else if (!bAccess && sAccessProperty.equals(i->first))
                 [ #  # ]
     156                 :            :         {
     157         [ #  # ]:          0 :             if (!i->second.isEmpty())
     158                 :            :             {
     159                 :          0 :                 m_bAccessibility = true;
     160                 :          0 :                 bAccess = true;
     161                 :            :             }
     162                 :            :         }
     163                 :            :         // the javax.accessibility.xxx property may not be set. Therefore we
     164                 :            :         //must search through all properties.
     165                 :            : 
     166                 :            :     }
     167 [ #  # ][ #  # ]:          0 :     if (!bVersion || !bVendor || !bHome)
                 [ #  # ]
     168                 :          0 :         return false;
     169                 :            : 
     170         [ #  # ]:          0 :     if (m_sJavaHome.isEmpty())
     171         [ #  # ]:          0 :         m_sJavaHome = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///usr/lib"));
     172                 :            : 
     173                 :            :     // init m_sRuntimeLibrary
     174                 :            :     OSL_ASSERT(!m_sHome.isEmpty());
     175                 :            :     //call virtual function to get the possible paths to the runtime library.
     176                 :            : 
     177                 :          0 :     int size = 0;
     178         [ #  # ]:          0 :     char const* const* arRtPaths = getRuntimePaths( & size);
     179         [ #  # ]:          0 :     vector<OUString> libpaths = getVectorFromCharArray(arRtPaths, size);
     180                 :            : 
     181                 :          0 :     bool bRt = false;
     182                 :            :     typedef vector<OUString>::const_iterator i_path;
     183 [ #  # ][ #  # ]:          0 :     for(i_path ip = libpaths.begin(); ip != libpaths.end(); ++ip)
                 [ #  # ]
     184                 :            :     {
     185                 :            :         //Construct an absolute path to the possible runtime
     186                 :          0 :         OUString usRt= m_sHome + *ip;
     187                 :          0 :         DirectoryItem item;
     188 [ #  # ][ #  # ]:          0 :         if(DirectoryItem::get(usRt, item) == File::E_None)
     189                 :            :         {
     190                 :            :             //found runtime lib
     191                 :          0 :             m_sRuntimeLibrary = usRt;
     192                 :          0 :             bRt = true;
     193                 :            :             break;
     194                 :            :         }
     195 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     196                 :            : 
     197         [ #  # ]:          0 :     if (!bRt)
     198                 :            :     {
     199                 :          0 :         m_sHome = m_sJavaHome;
     200 [ #  # ][ #  # ]:          0 :         for(i_path ip = libpaths.begin(); ip != libpaths.end(); ++ip)
                 [ #  # ]
     201                 :            :         {
     202                 :            :             //Construct an absolute path to the possible runtime
     203                 :          0 :             OUString usRt= m_sHome + *ip;
     204                 :          0 :             DirectoryItem item;
     205 [ #  # ][ #  # ]:          0 :             if(DirectoryItem::get(usRt, item) == File::E_None)
     206                 :            :             {
     207                 :            :                 //found runtime lib
     208                 :          0 :                 m_sRuntimeLibrary = usRt;
     209                 :          0 :                 bRt = true;
     210                 :            :                 break;
     211                 :            :             }
     212 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     213                 :            :     }
     214                 :            : 
     215                 :            :     // try to find it by the java.library.path property
     216 [ #  # ][ #  # ]:          0 :     if (!bRt && m_sJavaHome != sJavaLibraryPath)
                 [ #  # ]
     217                 :            :     {
     218                 :          0 :         m_sHome = sJavaLibraryPath;
     219 [ #  # ][ #  # ]:          0 :         for(i_path ip = libpaths.begin(); ip != libpaths.end(); ++ip)
                 [ #  # ]
     220                 :            :         {
     221                 :            :             //Construct an absolute path to the possible runtime
     222                 :          0 :             OUString usRt= m_sHome + *ip;
     223                 :          0 :             DirectoryItem item;
     224 [ #  # ][ #  # ]:          0 :             if(DirectoryItem::get(usRt, item) == File::E_None)
     225                 :            :             {
     226                 :            :                 //found runtime lib
     227                 :          0 :                 m_sRuntimeLibrary = usRt;
     228                 :          0 :                 bRt = true;
     229                 :            :                 break;
     230                 :            :             }
     231 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     232                 :            :     }
     233                 :            : 
     234                 :            : #ifdef X86_64
     235                 :            :     //Make one last final legacy attempt on x86_64 in case the distro placed it in lib64 instead
     236                 :            :     if (!bRt && m_sJavaHome != rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///usr/lib")))
     237                 :            :     {
     238                 :            :         m_sHome = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///usr/lib64"));
     239                 :            :         for(i_path ip = libpaths.begin(); ip != libpaths.end(); ++ip)
     240                 :            :         {
     241                 :            :             //Construct an absolute path to the possible runtime
     242                 :            :             OUString usRt= m_sHome + *ip;
     243                 :            :             DirectoryItem item;
     244                 :            :             if(DirectoryItem::get(usRt, item) == File::E_None)
     245                 :            :             {
     246                 :            :                 //found runtime lib
     247                 :            :                 m_sRuntimeLibrary = usRt;
     248                 :            :                 bRt = true;
     249                 :            :                 break;
     250                 :            :             }
     251                 :            :         }
     252                 :            :     }
     253                 :            : #endif
     254                 :            : 
     255         [ #  # ]:          0 :     if (!bRt)
     256                 :          0 :         return false;
     257                 :            : 
     258                 :            :     // init m_sLD_LIBRARY_PATH
     259                 :            :     OSL_ASSERT(!m_sHome.isEmpty());
     260                 :          0 :     size = 0;
     261         [ #  # ]:          0 :     char const * const * arLDPaths = getLibraryPaths( & size);
     262         [ #  # ]:          0 :     vector<OUString> ld_paths = getVectorFromCharArray(arLDPaths, size);
     263                 :            : 
     264                 :          0 :     char arSep[]= {SAL_PATHSEPARATOR, 0};
     265                 :          0 :     OUString sPathSep= OUString::createFromAscii(arSep);
     266                 :          0 :     bool bLdPath = true;
     267                 :          0 :     int c = 0;
     268 [ #  # ][ #  # ]:          0 :     for(i_path il = ld_paths.begin(); il != ld_paths.end(); ++il, ++c)
                 [ #  # ]
     269                 :            :     {
     270                 :          0 :         OUString usAbsUrl= m_sHome + *il;
     271                 :            :         // convert to system path
     272                 :          0 :         OUString usSysPath;
     273 [ #  # ][ #  # ]:          0 :         if(File::getSystemPathFromFileURL(usAbsUrl, usSysPath) == File::E_None)
     274                 :            :         {
     275                 :            : 
     276         [ #  # ]:          0 :             if(c > 0)
     277                 :          0 :                 m_sLD_LIBRARY_PATH+= sPathSep;
     278                 :          0 :             m_sLD_LIBRARY_PATH+= usSysPath;
     279                 :            :         }
     280                 :            :         else
     281                 :            :         {
     282                 :          0 :             bLdPath = false;
     283                 :            :             break;
     284                 :            :         }
     285 [ #  # ][ #  # ]:          0 :     }
     286         [ #  # ]:          0 :     if (bLdPath == false)
     287                 :          0 :         return false;
     288                 :            : 
     289                 :          0 :     return true;
     290                 :            : }
     291                 :            : 
     292                 :          0 : int GnuInfo::compareVersions(const rtl::OUString&) const
     293                 :            : {
     294                 :          0 :     return 0;
     295                 :            : }
     296                 :            : 
     297                 :            : }
     298                 :            : 
     299                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10