* src/vm/primitive.c (native/jni.h): Added.
[cacao.git] / src / vm / finalizer.c
index 175b05cbc8a5b0733808b05b610935fdf205b17f..4c77e4af29107bb8bcb201ea3fc19c95ff9ab2fd 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/finalizer.c - finalizer linked list and thread
 
-   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: Christian Thalinger
-
-   $Id: finalizer.c 6228 2006-12-26 19:56:58Z twisti $
+   $Id: finalizer.c 7831 2007-04-26 12:48:16Z twisti $
 
 */
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
-#include "native/jni.h"
-#include "native/include/java_lang_Thread.h"
-#include "native/include/java_lang_VMThread.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
-#include "vm/options.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
+
 #include "vm/jit/asmpart.h"
 
+#include "vmcore/options.h"
+
 
 /* global variables ***********************************************************/
 
 #if defined(ENABLE_THREADS)
-static threadobject      *thread_finalizer;
 static java_objectheader *lock_thread_finalizer;
 #endif
 
@@ -74,7 +67,7 @@ bool finalizer_init(void)
 #if defined(ENABLE_THREADS)
        lock_thread_finalizer = NEW(java_objectheader);
 
-       lock_init_object_lock(lock_thread_finalizer);
+       LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer);
 #endif
 
        /* everything's ok */
@@ -124,33 +117,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
-
-       /* create the finalizer object */
+       utf *name;
 
-       thread_finalizer = (threadobject *) builtin_new(class_java_lang_Thread);
+       name = utf_new_char("Finalizer");
 
-       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->o.name     = javastring_new_from_ascii("Finalizer");
-       thread_finalizer->o.daemon   = true;
-       thread_finalizer->o.priority = 5;
-
-       /* actually start the finalizer thread */
-
-       threads_start_thread(thread_finalizer, finalizer_thread);
-
        /* everything's ok */
 
        return true;
@@ -205,7 +178,7 @@ void finalizer_run(void *o, void *p)
 
        /* if we had an exception in the finalizer, ignore it */
 
-       *exceptionptr = NULL;
+       exceptions_clear_exception();
 }