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.h"
32 #include "native/llni.h"
33 #include "native/native.h"
35 #include "native/include/java_lang_String.h" /* required by j.l.C */
36 #include "native/include/java_lang_Class.h"
40 #include "native/include/java_lang_Object.h"
43 #include "threads/lock-common.h"
45 #include "vm/exceptions.hpp"
48 /* native methods implemented by this file ************************************/
50 static JNINativeMethod methods[] = {
51 { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass },
52 { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode },
53 { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify },
54 { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
55 { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait },
59 /* _Jv_java_lang_Object_init ***************************************************
61 Register native functions.
63 *******************************************************************************/
67 void _Jv_java_lang_Object_init(void)
71 u = utf_new_char("java/lang/Object");
73 native_method_register(u, methods, NATIVE_METHODS_COUNT);
78 // Native functions are exported as C functions.
82 * Class: java/lang/Object
84 * Signature: ()Ljava/lang/Class;
86 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj)
91 exceptions_throw_nullpointerexception();
95 LLNI_class_get(obj, c);
97 return LLNI_classinfo_wrap(c);
102 * Class: java/lang/Object
106 JNIEXPORT int32_t JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, java_lang_Object *_this)
108 #if defined(ENABLE_GC_CACAO)
111 return (int32_t) ((intptr_t) _this);
117 * Class: java/lang/Object
121 JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, java_lang_Object *_this)
123 #if defined(ENABLE_THREADS)
124 lock_notify_object((java_handle_t *) _this);
130 * Class: java/lang/Object
134 JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, java_lang_Object *_this)
136 #if defined(ENABLE_THREADS)
137 lock_notify_all_object((java_handle_t *) _this);
143 * Class: java/lang/Object
147 JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, java_lang_Object *_this, s8 timeout)
149 #if defined(ENABLE_JVMTI)
151 if (jvmti) jvmti_MonitorWaiting(true, _this, timeout);
154 #if defined(ENABLE_THREADS)
155 lock_wait_for_object((java_handle_t *) _this, timeout, 0);
158 #if defined(ENABLE_JVMTI)
160 /* XXX: How do you know if wait timed out ?*/
161 if (jvmti) jvmti_MonitorWaiting(false, _this, 0);
169 * These are local overrides for various environment variables in Emacs.
170 * Please do not remove this and leave it at the end of the file, where
171 * Emacs will automagically detect them.
172 * ---------------------------------------------------------------------
175 * indent-tabs-mode: t
179 * vim:noexpandtab:sw=4:ts=4: