1 /* src/native/vm/gnuclasspath/java_lang_VMObject.cpp - java/lang/VMObject
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
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.
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.
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
30 #include "native/jni.hpp"
31 #include "native/llni.h"
32 #include "native/native.h"
34 #if defined(ENABLE_JNI_HEADERS)
35 # include "native/vm/include/java_lang_VMObject.h"
38 #include "threads/lock-common.h"
40 #include "vm/jit/builtin.hpp"
41 #include "vm/exceptions.hpp"
42 #include "vm/javaobjects.hpp"
46 // Native functions are exported as C functions.
50 * Class: java/lang/VMObject
52 * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
54 JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, jobject obj)
57 exceptions_throw_nullpointerexception();
61 java_lang_Object o(obj);
63 return (jclass) LLNI_classinfo_wrap(o.get_Class());
68 * Class: java/lang/VMObject
70 * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
72 JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, jobject _this)
77 o = (java_handle_t *) _this;
79 co = builtin_clone(NULL, o);
86 * Class: java/lang/VMObject
88 * Signature: (Ljava/lang/Object;)V
90 JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, jobject _this)
92 #if defined(ENABLE_THREADS)
93 lock_notify_object((java_handle_t *) _this);
99 * Class: java/lang/VMObject
101 * Signature: (Ljava/lang/Object;)V
103 JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, jobject _this)
105 #if defined(ENABLE_THREADS)
106 lock_notify_all_object((java_handle_t *) _this);
112 * Class: java/lang/VMObject
114 * Signature: (Ljava/lang/Object;JI)V
116 JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, jobject o, jlong ms, jint ns)
118 #if defined(ENABLE_JVMTI)
120 if (jvmti) jvmti_MonitorWaiting(true, o, ms);
123 #if defined(ENABLE_THREADS)
124 lock_wait_for_object((java_handle_t *) o, ms, ns);
127 #if defined(ENABLE_JVMTI)
129 /* XXX: How do you know if wait timed out ?*/
130 if (jvmti) jvmti_MonitorWaiting(false, o, 0);
137 /* native methods implemented by this file ************************************/
139 static JNINativeMethod methods[] = {
140 { (char*) "getClass", (char*) "(Ljava/lang/Object;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMObject_getClass },
141 { (char*) "clone", (char*) "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_VMObject_clone },
142 { (char*) "notify", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notify },
143 { (char*) "notifyAll", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notifyAll },
144 { (char*) "wait", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_java_lang_VMObject_wait },
148 /* _Jv_java_lang_VMObject_init *************************************************
150 Register native functions.
152 *******************************************************************************/
156 void _Jv_java_lang_VMObject_init(void)
160 u = utf_new_char("java/lang/VMObject");
162 native_method_register(u, methods, NATIVE_METHODS_COUNT);
168 * These are local overrides for various environment variables in Emacs.
169 * Please do not remove this and leave it at the end of the file, where
170 * Emacs will automagically detect them.
171 * ---------------------------------------------------------------------
174 * indent-tabs-mode: t