CACAO
java_lang_VMObject.cpp
Go to the documentation of this file.
1 /* src/native/vm/gnuclasspath/java_lang_VMObject.cpp - java/lang/VMObject
2 
3  Copyright (C) 1996-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 
30 #include "native/jni.hpp"
31 #include "native/llni.hpp"
32 #include "native/native.hpp"
33 
34 #if defined(ENABLE_JNI_HEADERS)
35 # include "native/vm/include/java_lang_VMObject.h"
36 #endif
37 
38 #include "threads/lock.hpp"
39 
40 #include "vm/jit/builtin.hpp"
41 #include "vm/exceptions.hpp"
42 #include "vm/javaobjects.hpp"
43 #include "vm/utf8.hpp"
44 #include "vm/vm.hpp"
45 
46 // Native functions are exported as C functions.
47 extern "C" {
48 
49 /*
50  * Class: java/lang/VMObject
51  * Method: getClass
52  * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
53  */
54 JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv* env, jclass clazz, jobject obj)
55 {
56  if (obj == NULL) {
58  return NULL;
59  }
60 
61  java_lang_Object o(obj);
62 
63  return (jclass) LLNI_classinfo_wrap(o.get_Class());
64 }
65 
66 
67 /*
68  * Class: java/lang/VMObject
69  * Method: clone
70  * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
71  */
72 JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv* env, jclass clazz, jobject _this)
73 {
74  return builtin_clone(NULL, _this);
75 }
76 
77 
78 /*
79  * Class: java/lang/VMObject
80  * Method: notify
81  * Signature: (Ljava/lang/Object;)V
82  */
83 JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv* env, jclass clazz, jobject _this)
84 {
85  lock_notify_object(_this);
86 }
87 
88 
89 /*
90  * Class: java/lang/VMObject
91  * Method: notifyAll
92  * Signature: (Ljava/lang/Object;)V
93  */
94 JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv* env, jclass clazz, jobject _this)
95 {
97 }
98 
99 
100 /*
101  * Class: java/lang/VMObject
102  * Method: wait
103  * Signature: (Ljava/lang/Object;JI)V
104  */
105 JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv* env, jclass clazz, jobject o, jlong ms, jint ns)
106 {
107  lock_wait_for_object(o, ms, ns);
108 }
109 
110 } // extern "C"
111 
112 
113 /* native methods implemented by this file ************************************/
114 
115 static JNINativeMethod methods[] = {
116  { (char*) "getClass", (char*) "(Ljava/lang/Object;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMObject_getClass },
117  { (char*) "clone", (char*) "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_VMObject_clone },
118  { (char*) "notify", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notify },
119  { (char*) "notifyAll", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notifyAll },
120  { (char*) "wait", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_java_lang_VMObject_wait },
121 };
122 
123 
124 /* _Jv_java_lang_VMObject_init *************************************************
125 
126  Register native functions.
127 
128 *******************************************************************************/
129 
131 {
132  Utf8String u = Utf8String::from_utf8("java/lang/VMObject");
133 
136 }
137 
138 
139 /*
140  * These are local overrides for various environment variables in Emacs.
141  * Please do not remove this and leave it at the end of the file, where
142  * Emacs will automagically detect them.
143  * ---------------------------------------------------------------------
144  * Local variables:
145  * mode: c++
146  * indent-tabs-mode: t
147  * c-basic-offset: 4
148  * tab-width: 4
149  * End:
150  */
JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, jobject _this)
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
_Jv_JNIEnv JNIEnv
Definition: jni.hpp:112
#define NATIVE_METHODS_COUNT
Definition: native.hpp:45
classinfo * get_Class() const
JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, jobject obj)
JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, jobject _this)
static JNINativeMethod methods[]
#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 jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, 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
void _Jv_java_lang_VMObject_init(void)
java_handle_t * builtin_clone(void *env, java_handle_t *o)
Definition: builtin.cpp:2081
JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, jobject o, jlong ms, jint ns)
static VM * get_current()
Definition: vm.hpp:99