CACAO
java_lang_Object.cpp
Go to the documentation of this file.
1 /* src/native/vm/cldc1.1/java_lang_Object.c
2 
3  Copyright (C) 2006-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
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.
12 
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.
17 
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
21  02110-1301, USA.
22 
23 */
24 
25 
26 #include "config.h"
27 
28 #include <stdint.h>
29 #include <stdlib.h>
30 
31 #include "native/jni.hpp"
32 #include "native/llni.hpp"
33 #include "native/native.hpp"
34 
35 #if defined(ENABLE_JNI_HEADERS)
36 # include "native/include/java_lang_Object.h"
37 #endif
38 
39 #include "threads/lock.hpp"
40 
41 #include "vm/exceptions.hpp"
42 #include "vm/javaobjects.hpp"
43 
44 
45 // Native functions are exported as C functions.
46 extern "C" {
47 
48 /*
49  * Class: java/lang/Object
50  * Method: getClass
51  * Signature: ()Ljava/lang/Class;
52  */
54 {
55  if (obj == NULL) {
57  return NULL;
58  }
59 
60  java_lang_Object o(obj);
61 
62  return (jclass) LLNI_classinfo_wrap(o.get_Class());
63 }
64 
65 
66 /*
67  * Class: java/lang/Object
68  * Method: hashCode
69  * Signature: ()I
70  */
71 JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
72 {
73  java_lang_Object o(_this);
74 
75  return o.get_hashcode();
76 }
77 
78 
79 /*
80  * Class: java/lang/Object
81  * Method: notify
82  * Signature: ()V
83  */
84 JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this)
85 {
87 }
88 
89 
90 /*
91  * Class: java/lang/Object
92  * Method: notifyAll
93  * Signature: ()V
94  */
95 JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this)
96 {
98 }
99 
100 
101 /*
102  * Class: java/lang/Object
103  * Method: wait
104  * Signature: (J)V
105  */
106 JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout)
107 {
108  lock_wait_for_object((java_handle_t *) _this, timeout, 0);
109 }
110 
111 } // extern "C"
112 
113 
114 /* native methods implemented by this file ************************************/
115 
116 static JNINativeMethod methods[] = {
117  { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass },
118  { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode },
119  { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify },
120  { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
121  { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait },
122 };
123 
124 
125 /* _Jv_java_lang_Object_init ***************************************************
126 
127  Register native functions.
128 
129 *******************************************************************************/
130 
132 {
133  Utf8String u = Utf8String::from_utf8("java/lang/Object");
134 
137 }
138 
139 
140 /*
141  * These are local overrides for various environment variables in Emacs.
142  * Please do not remove this and leave it at the end of the file, where
143  * Emacs will automagically detect them.
144  * ---------------------------------------------------------------------
145  * Local variables:
146  * mode: c++
147  * indent-tabs-mode: t
148  * c-basic-offset: 4
149  * tab-width: 4
150  * End:
151  * vim:noexpandtab:sw=4:ts=4:
152  */
Table containing all native methods registered with the VM.
Definition: native.hpp:132
NativeMethods & get_nativemethods()
Definition: vm.hpp:128
void register_methods(Utf8String classname, const JNINativeMethod *methods, size_t count)
Register native methods with the VM.
Definition: native.cpp:242
static JNINativeMethod methods[]
int32_t get_hashcode() const
JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
_Jv_JNIEnv JNIEnv
Definition: jni.hpp:112
#define NATIVE_METHODS_COUNT
Definition: native.hpp:45
JNIEXPORT jclass JNICALL Java_java_lang_Object_getClass(JNIEnv *env, jobject obj)
classinfo * get_Class() const
void _Jv_java_lang_Object_init(void)
JNIEnv jthread jobject jlong timeout
Definition: jvmti.h:373
#define LLNI_classinfo_wrap(classinfo)
Definition: llni.hpp:110
void lock_notify_all_object(java_handle_t *o)
Definition: lock.cpp:1359
java/lang/Object
JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this)
JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this)
void lock_notify_object(java_handle_t *o)
Definition: lock.cpp:1340
void exceptions_throw_nullpointerexception(void)
static Utf8String from_utf8(const char *, size_t)
Definition: utf8.cpp:335
void lock_wait_for_object(java_handle_t *o, s8 millis, s4 nanos)
Definition: lock.cpp:1321
JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout)
static VM * get_current()
Definition: vm.hpp:99