* Merged with default branch at rev 16f3633aaa5a.
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Object.c
1 /* src/native/vm/cldc1.1/java_lang_Object.c
2
3    Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25 */
26
27
28 #include "config.h"
29
30 #include <stdlib.h>
31
32 #include "vm/types.h"
33
34 #include "native/jni.h"
35 #include "native/llni.h"
36 #include "native/native.h"
37
38 #include "native/include/java_lang_String.h"             /* required by j.l.C */
39 #include "native/include/java_lang_Class.h"
40
41 #include "native/include/java_lang_Object.h"
42
43 #include "native/vm/java_lang_Object.h"
44
45
46 /* native methods implemented by this file ************************************/
47  
48 static JNINativeMethod methods[] = {
49         { "getClass",  "()Ljava/lang/Class;",                   (void *) (ptrint) &Java_java_lang_Object_getClass  },
50         { "hashCode",  "()I",                                   (void *) (ptrint) &Java_java_lang_Object_hashCode  },
51         { "notify",    "()V",                                   (void *) (ptrint) &Java_java_lang_Object_notify    },
52         { "notifyAll", "()V",                                   (void *) (ptrint) &Java_java_lang_Object_notifyAll },
53         { "wait",      "(J)V",                                  (void *) (ptrint) &Java_java_lang_Object_wait      },
54 };
55  
56  
57 /* _Jv_java_lang_Object_init ***************************************************
58  
59    Register native functions.
60  
61 *******************************************************************************/
62  
63 void _Jv_java_lang_Object_init(void)
64 {
65         utf *u;
66  
67         u = utf_new_char("java/lang/Object");
68  
69         native_method_register(u, methods, NATIVE_METHODS_COUNT);
70 }
71
72
73 /*
74  * Class:     java/lang/Object
75  * Method:    getClass
76  * Signature: ()Ljava/lang/Class;
77  */
78 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj)
79 {
80         java_handle_t *o;
81         classinfo     *c;
82
83         o = (java_handle_t *) obj;
84
85         if (o == NULL)
86                 return NULL;
87
88         c = o->vftbl->class;
89
90         return LLNI_classinfo_wrap(c);
91 }
92
93
94 /*
95  * Class:     java/lang/Object
96  * Method:    hashCode
97  * Signature: ()I
98  */
99 JNIEXPORT s4 JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, java_lang_Object *this)
100 {
101 #if defined(ENABLE_GC_CACAO)
102         assert(0);
103 #else
104         return (s4) ((ptrint) this);
105 #endif
106 }
107
108
109 /*
110  * Class:     java/lang/Object
111  * Method:    notify
112  * Signature: ()V
113  */
114 JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, java_lang_Object *this)
115 {
116         _Jv_java_lang_Object_notify(this);
117 }
118
119
120 /*
121  * Class:     java/lang/Object
122  * Method:    notifyAll
123  * Signature: ()V
124  */
125 JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, java_lang_Object *this)
126 {
127         _Jv_java_lang_Object_notifyAll(this);
128 }
129
130
131 /*
132  * Class:     java/lang/Object
133  * Method:    wait
134  * Signature: (J)V
135  */
136 JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, java_lang_Object *this, s8 timeout)
137 {
138         _Jv_java_lang_Object_wait(this, timeout, 0);
139 }
140
141
142 /*
143  * These are local overrides for various environment variables in Emacs.
144  * Please do not remove this and leave it at the end of the file, where
145  * Emacs will automagically detect them.
146  * ---------------------------------------------------------------------
147  * Local variables:
148  * mode: c
149  * indent-tabs-mode: t
150  * c-basic-offset: 4
151  * tab-width: 4
152  * End:
153  * vim:noexpandtab:sw=4:ts=4:
154  */