* Removed all Id tags.
[cacao.git] / src / native / vm / java_lang_Object.c
index a806876023e3c84fd404f1fcfca20bd590e5a26f..1438afec7b915d87f98f3a8e5ba82e12380c316d 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/java_lang_Object.c - java/lang/Object functions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-            Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMObject.c 6213 2006-12-18 17:36:06Z twisti $
-
 */
 
 
 #include "vm/types.h"
 
 #include "native/jni.h"
-#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Cloneable.h"
+#include "native/llni.h"
+
 #include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_String.h"            /* required by j.l.CL */
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_CLASSPATH_SUN)
+#  include "native/include/java_nio_ByteBuffer.h"       /* required by j.l.CL */
+# endif
+
+# include "native/include/java_lang_ClassLoader.h"       /* required by j.l.C */
+# include "native/include/java_lang_Cloneable.h"
 #endif
 
+#include "native/include/java_lang_Class.h"
+
+#include "threads/lock-common.h"
+
 #include "vm/builtin.h"
-#include "vm/options.h"
+#include "vm/exceptions.h"
+
+#include "vmcore/options.h"
 
 #if defined(ENABLE_JVMTI)
 #include "native/jvmti/cacaodbg.h"
  */
 java_lang_Class *_Jv_java_lang_Object_getClass(java_lang_Object *obj)
 {
-       classinfo *c;
+       classinfo     *c;
 
-       if (obj == NULL)
+       if (obj == NULL) {
+               exceptions_throw_nullpointerexception();
                return NULL;
+       }
 
-       c = ((java_objectheader *) obj)->vftbl->class;
-
-       return (java_lang_Class *) c;
-}
-
-
-/*
- * Class:     java/lang/Object
- * Method:    clone
- * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
- */
-java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this)
-{
-       java_objectheader *o;
-       java_objectheader *co;
-
-       o = (java_objectheader *) this;
-
-       co = builtin_clone(NULL, o);
+       LLNI_class_get(obj, c);
 
-       return (java_lang_Object *) co;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -101,7 +88,7 @@ java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this)
 void _Jv_java_lang_Object_notify(java_lang_Object *this)
 {
 #if defined(ENABLE_THREADS)
-       lock_notify_object(&this->header);
+       lock_notify_object(&LLNI_field_direct(this, header));
 #endif
 }
 
@@ -114,7 +101,7 @@ void _Jv_java_lang_Object_notify(java_lang_Object *this)
 void _Jv_java_lang_Object_notifyAll(java_lang_Object *this)
 {
 #if defined(ENABLE_THREADS)
-       lock_notify_all_object(&this->header);
+       lock_notify_all_object(&LLNI_field_direct(this, header));
 #endif
 }
 
@@ -131,8 +118,14 @@ void _Jv_java_lang_Object_wait(java_lang_Object *o, s8 ms, s4 ns)
        if (jvmti) jvmti_MonitorWaiting(true, o, ms);
 #endif
 
+    if (ms < 0) {
+/*             exceptions_throw_illegalargumentexception("argument out of range"); */
+               exceptions_throw_illegalargumentexception();
+               return;
+       }
+
 #if defined(ENABLE_THREADS)
-       lock_wait_for_object(&o->header, ms, ns);
+       lock_wait_for_object(&LLNI_field_direct(o, header), ms, ns);
 #endif
 
 #if defined(ENABLE_JVMTI)
@@ -143,6 +136,28 @@ void _Jv_java_lang_Object_wait(java_lang_Object *o, s8 ms, s4 ns)
 }
 
 
+#if defined(ENABLE_JAVASE)
+
+/*
+ * Class:     java/lang/Object
+ * Method:    clone
+ * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
+ */
+java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this)
+{
+       java_handle_t *o;
+       java_handle_t *co;
+
+       o = (java_handle_t *) this;
+
+       co = builtin_clone(NULL, o);
+
+       return (java_lang_Object *) co;
+}
+
+#endif /* ENABLE_JAVASE */
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where