LCOV - code coverage report
Current view: top level - include/jvmaccess - classpath.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 1 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             : #ifndef INCLUDED_JVMACCESS_CLASSPATH_HXX
      21             : #define INCLUDED_JVMACCESS_CLASSPATH_HXX
      22             : 
      23             : #include <jvmaccess/jvmaccessdllapi.h>
      24             : #include <sal/config.h>
      25             : #include <com/sun/star/uno/Reference.hxx>
      26             : 
      27             : #include "jni.h"
      28             : 
      29             : namespace com { namespace sun { namespace star { namespace uno {
      30             :     class XComponentContext;
      31             : } } } }
      32             : 
      33             : namespace jvmaccess {
      34             : 
      35             : /**
      36             :    Helper functions for class path handling.
      37             : */
      38             : class JVMACCESS_DLLPUBLIC ClassPath {
      39             : public:
      40             :     /**
      41             :        translates a class path into a java.net.URL[] instance.
      42             : 
      43             :        @param context
      44             :        a component context; must not be null.
      45             : 
      46             :        @param environment
      47             :        a JNI environment; must not be null.
      48             : 
      49             :        @param classPath
      50             :        a list of zero or more internal (see the
      51             :        com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
      52             :        where any space characters (U+0020) are ignored (and, in particular,
      53             :        separate adjacent URI references).  Any vnd.sun.star.expand URL
      54             :        references in the list are expanded using the
      55             :        com.sun.star.util.theMacroExpander singleton of the given context.
      56             : 
      57             :        @returns
      58             :        a local reference to a java.net.URL[] instance containing the external
      59             :        (see the com.sun.star.uri.ExternalUriReferenceTranslator service)
      60             :        equivalents of all the URI references in the given classPath.  If null, a
      61             :        (still pending) JNI exception occurred.
      62             : 
      63             :        @throws com::sun::star::uno::RuntimeException
      64             :     */
      65             :     static inline ::jobjectArray
      66           0 :     translateToUrls(
      67             :         ::com::sun::star::uno::Reference<
      68             :         ::com::sun::star::uno::XComponentContext > const & context,
      69             :         ::JNIEnv * environment, OUString const & classPath)
      70             :     {
      71             :         return
      72             :             static_cast< ::jobjectArray >(
      73           0 :                 doTranslateToUrls(context, environment, classPath));
      74             :     }
      75             : 
      76             :     /**
      77             :        loads a class via a java.net.URLClassLoader.
      78             : 
      79             :        @param context
      80             :        a component context; must not be null.
      81             : 
      82             :        @param environment
      83             :        a JNI environment; must not be null.
      84             : 
      85             :        @param classPath
      86             :        a list of zero or more internal (see the
      87             :        com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
      88             :        where any space characters (U+0020) are ignored (and, in particular,
      89             :        separate adjacent URI references).  Any vnd.sun.star.expand URL
      90             :        references in the list are expanded using the
      91             :        com.sun.star.util.theMacroExpander singleton of the given context.
      92             : 
      93             :        @param name
      94             :        the Java binary name of the class to load.
      95             : 
      96             :        @returns
      97             :        a local reference to a java.lang.Class instance.  If null, a (still
      98             :        pending) JNI exception occurred.
      99             : 
     100             :        @throws com::sun::star::uno::RuntimeException
     101             :     */
     102             :     static inline ::jclass loadClass(
     103             :         ::com::sun::star::uno::Reference<
     104             :         ::com::sun::star::uno::XComponentContext > const & context,
     105             :         ::JNIEnv * environment, OUString const & classPath,
     106             :         OUString const & name)
     107             :     {
     108             :         return
     109             :             static_cast< ::jclass >(
     110             :                 doLoadClass(context, environment, classPath, name));
     111             :     }
     112             : 
     113             : private:
     114             :     ClassPath(); // not defined
     115             :     ClassPath(ClassPath &); // not defined
     116             :     ~ClassPath(); // not defined
     117             :     void operator =(ClassPath &); // not defined
     118             : 
     119             :     // Functions that replace JNIEnv, jobjectArray, and jclass with void *, so
     120             :     // that their mangled C++ names do not depend on the JDK version used at
     121             :     // compile time:
     122             : 
     123             :     static void * doTranslateToUrls(
     124             :         ::com::sun::star::uno::Reference<
     125             :         ::com::sun::star::uno::XComponentContext > const & context,
     126             :         void * environment, OUString const & classPath);
     127             : 
     128             :     static void * doLoadClass(
     129             :         ::com::sun::star::uno::Reference<
     130             :         ::com::sun::star::uno::XComponentContext > const & context,
     131             :         void * environment, OUString const & classPath,
     132             :         OUString const & name);
     133             : };
     134             : 
     135             : }
     136             : 
     137             : #endif
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10