* Removed all Id tags.
[cacao.git] / src / vm / finalizer.c
index 5e683a9a2c99bd85af826d60ca802112b9f5496d..4716be0b12dba1a199b0afbb746947cb032cb6f4 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: finalizer.c 7280 2007-02-03 19:34:10Z twisti $
-
 */
 
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
-#include "native/jni.h"
-#include "native/include/java_lang_Thread.h"
-
-#if defined(WITH_CLASSPATH_GNU)
-# include "native/include/java_lang_VMThread.h"
-#endif
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -60,8 +50,7 @@
 /* global variables ***********************************************************/
 
 #if defined(ENABLE_THREADS)
-static threadobject      *thread_finalizer;
-static java_objectheader *lock_thread_finalizer;
+static java_object_t *lock_thread_finalizer;
 #endif
 
 
@@ -74,9 +63,9 @@ static java_objectheader *lock_thread_finalizer;
 bool finalizer_init(void)
 {
 #if defined(ENABLE_THREADS)
-       lock_thread_finalizer = NEW(java_objectheader);
+       lock_thread_finalizer = NEW(java_object_t);
 
-       lock_init_object_lock(lock_thread_finalizer);
+       LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer);
 #endif
 
        /* everything's ok */
@@ -126,37 +115,13 @@ static void finalizer_thread(void)
 #if defined(ENABLE_THREADS)
 bool finalizer_start_thread(void)
 {
-#if defined(WITH_CLASSPATH_GNU)
-       java_lang_VMThread *vmt;
-#endif
+       utf *name;
 
-       /* create the finalizer object */
+       name = utf_new_char("Finalizer");
 
-       thread_finalizer = (threadobject *) builtin_new(class_java_lang_Thread);
-
-       if (thread_finalizer == NULL)
+       if (!threads_thread_start_internal(name, finalizer_thread))
                return false;
 
-#if defined(WITH_CLASSPATH_GNU)
-       vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
-
-       vmt->thread = (java_lang_Thread *) thread_finalizer;
-
-       thread_finalizer->o.vmThread = vmt;
-#endif
-
-       thread_finalizer->flags      = THREAD_FLAG_DAEMON;
-
-       thread_finalizer->o.name     = javastring_new_from_ascii("Finalizer");
-#if defined(ENABLE_JAVASE)
-       thread_finalizer->o.daemon   = true;
-#endif
-       thread_finalizer->o.priority = 5;
-
-       /* actually start the finalizer thread */
-
-       threads_start_thread(thread_finalizer, finalizer_thread);
-
        /* everything's ok */
 
        return true;
@@ -201,9 +166,9 @@ void finalizer_notify(void)
 
 void finalizer_run(void *o, void *p)
 {
-       java_objectheader *ob;
+       java_object_t *ob;
 
-       ob = (java_objectheader *) o;
+       ob = (java_object_t *) o;
 
        /* call the finalizer function */