LCOV - code coverage report
Current view: top level - native/vm/gnuclasspath - gnu_classpath_VMStackWalker.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 18 66.7 %
Date: 2015-06-10 18:10:59 Functions: 3 5 60.0 %

          Line data    Source code
       1             : /* src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp
       2             : 
       3             :    Copyright (C) 1996-2013
       4             :    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
       5             : 
       6             :    This file is part of CACAO.
       7             : 
       8             :    This program is free software; you can redistribute it and/or
       9             :    modify it under the terms of the GNU General Public License as
      10             :    published by the Free Software Foundation; either version 2, or (at
      11             :    your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful, but
      14             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16             :    General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program; if not, write to the Free Software
      20             :    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
      21             :    02110-1301, USA.
      22             : 
      23             : */
      24             : 
      25             : 
      26             : #include "config.h"
      27             : 
      28             : #include <stdint.h>
      29             : 
      30             : #include "native/jni.hpp"
      31             : #include "native/native.hpp"
      32             : 
      33             : #if defined(ENABLE_JNI_HEADERS)
      34             : # include "native/vm/include/gnu_classpath_VMStackWalker.h"
      35             : #endif
      36             : 
      37             : #include "vm/class.hpp"
      38             : #include "vm/global.hpp"
      39             : #include "vm/utf8.hpp"
      40             : #include "vm/vm.hpp"
      41             : 
      42             : #include "vm/jit/stacktrace.hpp"
      43             : 
      44             : 
      45             : // Native functions are exported as C functions.
      46             : extern "C" {
      47             : 
      48             : /*
      49             :  * Class:     gnu/classpath/VMStackWalker
      50             :  * Method:    getClassContext
      51             :  * Signature: ()[Ljava/lang/Class;
      52             :  */
      53           3 : JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
      54             : {
      55             :         java_handle_objectarray_t *oa;
      56             : 
      57           3 :         oa = stacktrace_getClassContext();
      58             : 
      59           3 :         return (jobjectArray) oa;
      60             : }
      61             : 
      62             : 
      63             : /*
      64             :  * Class:     gnu/classpath/VMStackWalker
      65             :  * Method:    getCallingClass
      66             :  * Signature: ()Ljava/lang/Class;
      67             :  */
      68           0 : JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
      69             : {
      70             :         classinfo *c;
      71             : 
      72           0 :         c = stacktrace_get_caller_class(2);
      73             : 
      74           0 :         return (jclass) c;
      75             : }
      76             : 
      77             : 
      78             : /*
      79             :  * Class:     gnu/classpath/VMStackWalker
      80             :  * Method:    getCallingClassLoader
      81             :  * Signature: ()Ljava/lang/ClassLoader;
      82             :  */
      83         777 : JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
      84             : {
      85             :         classinfo     *c;
      86             :         classloader_t *cl;
      87             : 
      88         777 :         c  = stacktrace_get_caller_class(2);
      89         777 :         cl = class_get_classloader(c);
      90             : 
      91         777 :         return (jobject) cl;
      92             : }
      93             : 
      94             : 
      95             : /*
      96             :  * Class:     gnu/classpath/VMStackWalker
      97             :  * Method:    firstNonNullClassLoader
      98             :  * Signature: ()Ljava/lang/ClassLoader;
      99             :  */
     100           0 : JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
     101             : {
     102             :         classloader_t *cl;
     103             : 
     104           0 :         cl = stacktrace_first_nonnull_classloader();
     105             : 
     106           0 :         return (jobject) cl;
     107             : }
     108             : 
     109             : } // extern "C"
     110             : 
     111             : 
     112             : /* native methods implemented by this file ************************************/
     113             : 
     114             : static JNINativeMethod methods[] = {
     115             :         { (char*) "getClassContext",         (char*) "()[Ljava/lang/Class;",      (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getClassContext         },
     116             :         { (char*) "getCallingClass",         (char*) "()Ljava/lang/Class;",       (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClass         },
     117             :         { (char*) "getCallingClassLoader",   (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader   },
     118             :         { (char*) "firstNonNullClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
     119             : };
     120             : 
     121             : 
     122             : /* _Jv_gnu_classpath_VMStackWalker_init ****************************************
     123             : 
     124             :    Register native functions.
     125             : 
     126             : *******************************************************************************/
     127             : 
     128         163 : void _Jv_gnu_classpath_VMStackWalker_init(void)
     129             : {
     130         163 :         Utf8String u = Utf8String::from_utf8("gnu/classpath/VMStackWalker");
     131             : 
     132         163 :         NativeMethods& nm = VM::get_current()->get_nativemethods();
     133         163 :         nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
     134         163 : }
     135             : 
     136             : 
     137             : /*
     138             :  * These are local overrides for various environment variables in Emacs.
     139             :  * Please do not remove this and leave it at the end of the file, where
     140             :  * Emacs will automagically detect them.
     141             :  * ---------------------------------------------------------------------
     142             :  * Local variables:
     143             :  * mode: c++
     144             :  * indent-tabs-mode: t
     145             :  * c-basic-offset: 4
     146             :  * tab-width: 4
     147             :  * End:
     148             :  * vim:noexpandtab:sw=4:ts=4:
     149             :  */

Generated by: LCOV version 1.11