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.h"
35 #if defined(ENABLE_JNI_HEADERS)
36 # include "native/include/java_lang_Object.h"
39 #include "threads/lock-common.h"
41 #include "vm/exceptions.hpp"
44 // Native functions are exported as C functions.
48 * Class: java/lang/Object
50 * Signature: ()Ljava/lang/Class;
52 JNIEXPORT jclass JNICALL Java_java_lang_Object_getClass(JNIEnv *env, jobject obj)
57 exceptions_throw_nullpointerexception();
61 LLNI_class_get(obj, c);
63 return (jclass) LLNI_classinfo_wrap(c);
68 * Class: java/lang/Object
72 JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
74 #if defined(ENABLE_GC_CACAO)
77 return (int32_t) ((uintptr_t) _this);
83 * Class: java/lang/Object
87 JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this)
89 #if defined(ENABLE_THREADS)
90 lock_notify_object((java_handle_t *) _this);
96 * Class: java/lang/Object
100 JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this)
102 #if defined(ENABLE_THREADS)
103 lock_notify_all_object((java_handle_t *) _this);
109 * Class: java/lang/Object
113 JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout)
115 #if defined(ENABLE_JVMTI)
117 if (jvmti) jvmti_MonitorWaiting(true, _this, timeout);
120 #if defined(ENABLE_THREADS)
121 lock_wait_for_object((java_handle_t *) _this, timeout, 0);
124 #if defined(ENABLE_JVMTI)
126 /* XXX: How do you know if wait timed out ?*/
127 if (jvmti) jvmti_MonitorWaiting(false, _this, 0);
134 /* native methods implemented by this file ************************************/
136 static JNINativeMethod methods[] = {
137 { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass },
138 { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode },
139 { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify },
140 { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
141 { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait },
145 /* _Jv_java_lang_Object_init ***************************************************
147 Register native functions.
149 *******************************************************************************/
153 void _Jv_java_lang_Object_init(void)
157 u = utf_new_char("java/lang/Object");
159 native_method_register(u, methods, NATIVE_METHODS_COUNT);
165 * These are local overrides for various environment variables in Emacs.
166 * Please do not remove this and leave it at the end of the file, where
167 * Emacs will automagically detect them.
168 * ---------------------------------------------------------------------
171 * indent-tabs-mode: t
175 * vim:noexpandtab:sw=4:ts=4: