LCOV - code coverage report
Current view: top level - native/vm/gnuclasspath - java_lang_VMObject.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 22 90.9 %
Date: 2017-07-14 10:03:36 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /* src/native/vm/gnuclasspath/java_lang_VMObject.cpp - java/lang/VMObject
       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/llni.hpp"
      32             : #include "native/native.hpp"
      33             : 
      34             : #if defined(ENABLE_JNI_HEADERS)
      35             : # include "native/vm/include/java_lang_VMObject.h"
      36             : #endif
      37             : 
      38             : #include "threads/lock.hpp"
      39             : 
      40             : #include "vm/jit/builtin.hpp"
      41             : #include "vm/exceptions.hpp"
      42             : #include "vm/javaobjects.hpp"
      43             : #include "vm/utf8.hpp"
      44             : #include "vm/vm.hpp"
      45             : 
      46             : // Native functions are exported as C functions.
      47             : extern "C" {
      48             : 
      49             : /*
      50             :  * Class:     java/lang/VMObject
      51             :  * Method:    getClass
      52             :  * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
      53             :  */
      54       46132 : JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv* env, jclass clazz, jobject obj)
      55             : {
      56       46132 :         if (obj == NULL) {
      57           0 :                 exceptions_throw_nullpointerexception();
      58           0 :                 return NULL;
      59             :         }
      60             : 
      61       46132 :         java_lang_Object o(obj);
      62             : 
      63       46132 :         return (jclass) LLNI_classinfo_wrap(o.get_Class());
      64             : }
      65             : 
      66             : 
      67             : /*
      68             :  * Class:     java/lang/VMObject
      69             :  * Method:    clone
      70             :  * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
      71             :  */
      72         415 : JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv* env, jclass clazz, jobject _this)
      73             : {
      74         415 :         return builtin_clone(NULL, _this);
      75             : }
      76             : 
      77             : 
      78             : /*
      79             :  * Class:     java/lang/VMObject
      80             :  * Method:    notify
      81             :  * Signature: (Ljava/lang/Object;)V
      82             :  */
      83       17167 : JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv* env, jclass clazz, jobject _this)
      84             : {
      85       17167 :         lock_notify_object(_this);
      86       17167 : }
      87             : 
      88             : 
      89             : /*
      90             :  * Class:     java/lang/VMObject
      91             :  * Method:    notifyAll
      92             :  * Signature: (Ljava/lang/Object;)V
      93             :  */
      94          17 : JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv* env, jclass clazz, jobject _this)
      95             : {
      96          17 :         lock_notify_all_object(_this);
      97          17 : }
      98             : 
      99             : 
     100             : /*
     101             :  * Class:     java/lang/VMObject
     102             :  * Method:    wait
     103             :  * Signature: (Ljava/lang/Object;JI)V
     104             :  */
     105       20010 : JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv* env, jclass clazz, jobject o, jlong ms, jint ns)
     106             : {
     107       20010 :         lock_wait_for_object(o, ms, ns);
     108       20010 : }
     109             : 
     110             : } // extern "C"
     111             : 
     112             : 
     113             : /* native methods implemented by this file ************************************/
     114             : 
     115             : static JNINativeMethod methods[] = {
     116             :         { (char*) "getClass",  (char*) "(Ljava/lang/Object;)Ljava/lang/Class;",     (void*) (uintptr_t) &Java_java_lang_VMObject_getClass  },
     117             :         { (char*) "clone",     (char*) "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_VMObject_clone     },
     118             :         { (char*) "notify",    (char*) "(Ljava/lang/Object;)V",                     (void*) (uintptr_t) &Java_java_lang_VMObject_notify    },
     119             :         { (char*) "notifyAll", (char*) "(Ljava/lang/Object;)V",                     (void*) (uintptr_t) &Java_java_lang_VMObject_notifyAll },
     120             :         { (char*) "wait",      (char*) "(Ljava/lang/Object;JI)V",                   (void*) (uintptr_t) &Java_java_lang_VMObject_wait      },
     121             : };
     122             : 
     123             : 
     124             : /* _Jv_java_lang_VMObject_init *************************************************
     125             : 
     126             :    Register native functions.
     127             : 
     128             : *******************************************************************************/
     129             : 
     130         163 : void _Jv_java_lang_VMObject_init(void)
     131             : {
     132         163 :         Utf8String u = Utf8String::from_utf8("java/lang/VMObject");
     133             : 
     134         163 :         NativeMethods& nm = VM::get_current()->get_nativemethods();
     135         163 :         nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
     136         163 : }
     137             : 
     138             : 
     139             : /*
     140             :  * These are local overrides for various environment variables in Emacs.
     141             :  * Please do not remove this and leave it at the end of the file, where
     142             :  * Emacs will automagically detect them.
     143             :  * ---------------------------------------------------------------------
     144             :  * Local variables:
     145             :  * mode: c++
     146             :  * indent-tabs-mode: t
     147             :  * c-basic-offset: 4
     148             :  * tab-width: 4
     149             :  * End:
     150             :  */

Generated by: LCOV version 1.11