1 /* src/native/vm/cldc1.1/java_lang_Object.c
3 Copyright (C) 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
31 #include "native/jni.hpp"
32 #include "native/llni.h"
33 #include "native/native.hpp"
35 #if defined(ENABLE_JNI_HEADERS)
36 # include "native/include/java_lang_Object.h"
39 #include "threads/lock.hpp"
41 #include "vm/exceptions.hpp"
42 #include "vm/javaobjects.hpp"
45 // Native functions are exported as C functions.
49 * Class: java/lang/Object
51 * Signature: ()Ljava/lang/Class;
53 JNIEXPORT jclass JNICALL Java_java_lang_Object_getClass(JNIEnv *env, jobject obj)
56 exceptions_throw_nullpointerexception();
60 java_lang_Object o(obj);
62 return (jclass) LLNI_classinfo_wrap(o.get_Class());
67 * Class: java/lang/Object
71 JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
73 java_lang_Object o(_this);
75 return o.get_hashcode();
80 * Class: java/lang/Object
84 JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this)
86 #if defined(ENABLE_THREADS)
87 lock_notify_object((java_handle_t *) _this);
93 * Class: java/lang/Object
97 JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this)
99 #if defined(ENABLE_THREADS)
100 lock_notify_all_object((java_handle_t *) _this);
106 * Class: java/lang/Object
110 JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout)
112 #if defined(ENABLE_JVMTI)
114 if (jvmti) jvmti_MonitorWaiting(true, _this, timeout);
117 #if defined(ENABLE_THREADS)
118 lock_wait_for_object((java_handle_t *) _this, timeout, 0);
121 #if defined(ENABLE_JVMTI)
123 /* XXX: How do you know if wait timed out ?*/
124 if (jvmti) jvmti_MonitorWaiting(false, _this, 0);
131 /* native methods implemented by this file ************************************/
133 static JNINativeMethod methods[] = {
134 { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass },
135 { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode },
136 { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify },
137 { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
138 { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait },
142 /* _Jv_java_lang_Object_init ***************************************************
144 Register native functions.
146 *******************************************************************************/
148 void _Jv_java_lang_Object_init(void)
150 utf* u = utf_new_char("java/lang/Object");
152 NativeMethods& nm = VM::get_current()->get_nativemethods();
153 nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
158 * These are local overrides for various environment variables in Emacs.
159 * Please do not remove this and leave it at the end of the file, where
160 * Emacs will automagically detect them.
161 * ---------------------------------------------------------------------
164 * indent-tabs-mode: t
168 * vim:noexpandtab:sw=4:ts=4: