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.h"
31 #include "native/llni.h"
32 #include "native/native.h"
34 #include "native/include/java_lang_Class.h" /* required by j.l.VMO */
35 #include "native/include/java_lang_Cloneable.h" /* required by j.l.VMO */
36 #include "native/include/java_lang_Object.h" /* required by j.l.VMO */
40 #include "native/include/java_lang_VMObject.h"
43 #include "threads/lock-common.h"
45 #include "vm/builtin.h"
46 #include "vm/exceptions.hpp"
48 #include "vmcore/utf8.h"
51 // Native functions are exported as C functions.
55 * Class: java/lang/VMObject
57 * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
59 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, java_lang_Object *obj)
64 exceptions_throw_nullpointerexception();
68 LLNI_class_get(obj, c);
70 return LLNI_classinfo_wrap(c);
75 * Class: java/lang/VMObject
77 * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
79 JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, java_lang_Cloneable *_this)
84 o = (java_handle_t *) _this;
86 co = builtin_clone(NULL, o);
88 return (java_lang_Object *) co;
93 * Class: java/lang/VMObject
95 * Signature: (Ljava/lang/Object;)V
97 JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *_this)
99 #if defined(ENABLE_THREADS)
100 lock_notify_object((java_handle_t *) _this);
106 * Class: java/lang/VMObject
108 * Signature: (Ljava/lang/Object;)V
110 JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *_this)
112 #if defined(ENABLE_THREADS)
113 lock_notify_all_object((java_handle_t *) _this);
119 * Class: java/lang/VMObject
121 * Signature: (Ljava/lang/Object;JI)V
123 JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, int64_t ms, int32_t ns)
125 #if defined(ENABLE_JVMTI)
127 if (jvmti) jvmti_MonitorWaiting(true, o, ms);
130 #if defined(ENABLE_THREADS)
131 lock_wait_for_object((java_handle_t *) o, ms, ns);
134 #if defined(ENABLE_JVMTI)
136 /* XXX: How do you know if wait timed out ?*/
137 if (jvmti) jvmti_MonitorWaiting(false, o, 0);
144 /* native methods implemented by this file ************************************/
146 static JNINativeMethod methods[] = {
147 { (char*) "getClass", (char*) "(Ljava/lang/Object;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMObject_getClass },
148 { (char*) "clone", (char*) "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_VMObject_clone },
149 { (char*) "notify", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notify },
150 { (char*) "notifyAll", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notifyAll },
151 { (char*) "wait", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_java_lang_VMObject_wait },
155 /* _Jv_java_lang_VMObject_init *************************************************
157 Register native functions.
159 *******************************************************************************/
163 void _Jv_java_lang_VMObject_init(void)
167 u = utf_new_char("java/lang/VMObject");
169 native_method_register(u, methods, NATIVE_METHODS_COUNT);
175 * These are local overrides for various environment variables in Emacs.
176 * Please do not remove this and leave it at the end of the file, where
177 * Emacs will automagically detect them.
178 * ---------------------------------------------------------------------
181 * indent-tabs-mode: t