(threads_thread_set_object): Added.
* src/threads/threads-common.c: Use above functions throughout the code.
* src/threads/native/threads.c: Likewise.
* src/native/vm/java_lang_Thread.c: Likewise.
(_Jv_java_lang_Thread_start): Fixed compiler warning.
(_Jv_java_lang_Thread_currentThread) [ENABLE_JAVASE]: Fixed for handles.
void _Jv_java_lang_Thread_start(java_lang_Thread *this, s8 stacksize)
{
#if defined(ENABLE_THREADS)
- threads_thread_start(this);
+ threads_thread_start((java_handle_t *) this);
#endif
}
java_lang_Thread *_Jv_java_lang_Thread_currentThread(void)
{
#if defined(ENABLE_THREADS)
- threadobject *thread;
+ threadobject *thread;
+#endif
+ java_lang_Thread *t;
+#if defined(ENABLE_JAVASE)
+ java_lang_ThreadGroup *group;
#endif
- java_lang_Thread *t;
#if defined(ENABLE_THREADS)
thread = THREADOBJECT;
- t = LLNI_WRAP(thread->object);
+ t = (java_lang_Thread *) threads_thread_get_object(thread);
if (t == NULL)
log_text("t ptr is NULL\n");
# if defined(ENABLE_JAVASE)
- if (LLNI_field_direct(t, group) == NULL) {
+ LLNI_field_get_ref(t, group, group);
+
+ if (group == NULL) {
/* ThreadGroup of currentThread is not initialized */
- LLNI_field_direct(t, group) = (java_lang_ThreadGroup *)
+ group = (java_lang_ThreadGroup *)
native_new_and_init(class_java_lang_ThreadGroup);
- if (LLNI_field_direct(t, group) == NULL)
+ if (group == NULL)
log_text("unable to create ThreadGroup");
+
+ LLNI_field_set_ref(t, group, group);
}
# endif
#else
/* we just return a fake java.lang.Thread object, otherwise we get
- NullPointerException's in GNU classpath */
+ NullPointerException's in GNU classpath */
t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
#endif
/* set the object in the internal data structure */
- mainthread->object = LLNI_DIRECT(t);
+ threads_thread_set_object(mainthread, t);
#if defined(ENABLE_INTRP)
/* create interpreter stack */
/* get the java.lang.Thread object for this thread */
- object = (java_lang_Thread *) LLNI_WRAP(thread->object);
+ object = (java_lang_Thread *) threads_thread_get_object(thread);
/* set our priority */
if (t == NULL)
return false;
- thread->object = LLNI_DIRECT(t);
+ threads_thread_set_object(thread, t);
/* thread is completely initialized */
/* get the main thread */
mainthread = threads_list_first();
- mainthreado = (java_lang_Thread *) LLNI_WRAP(mainthread->object);
+ mainthreado = (java_lang_Thread *) threads_thread_get_object(mainthread);
group = LLNI_field_direct(mainthreado, group);
#endif
}
#endif
#if defined(ENABLE_JAVASE)
- object = (java_lang_Thread *) LLNI_WRAP(t->object);
+ object = (java_lang_Thread *) threads_thread_get_object(t);
LLNI_field_get_ref(object, group, group);
LLNI_field_set_val(object, vm_thread, (java_lang_Object *) t);
#endif
- t->object = LLNI_DIRECT(object);
+ threads_thread_set_object(t, object);
/* set java.lang.Thread fields */
/* link the two objects together */
- thread->object = LLNI_DIRECT(object);
+ threads_thread_set_object(thread, object);
#if defined(WITH_CLASSPATH_GNU)
LLNI_field_get_ref(o, vmThread, vmt);
/* the thread may be currently in initalization, don't print it */
- object = (java_lang_Thread *) LLNI_WRAP(t->object);
+ object = (java_lang_Thread *) threads_thread_get_object(t);
if (object != NULL) {
/* get thread name */
#include "vm/global.h"
-#include "native/jni.h"
+#include "native/llni.h"
#if defined(ENABLE_THREADS)
# include "threads/native/threads.h"
#endif
+/* inline functions ***********************************************************/
+
+/* threads_thread_get_object ***************************************************
+
+ Return the java.lang.Thread object for the given thread.
+
+*******************************************************************************/
+
+static inline java_handle_t *threads_thread_get_object(threadobject *t)
+{
+ return LLNI_WRAP(t->object);
+}
+
+
+/* threads_thread_set_object ***************************************************
+
+ Set the java.lang.Thread object for the given thread.
+
+*******************************************************************************/
+
+static inline void threads_thread_set_object(threadobject *t, java_handle_t *object)
+{
+ t->object = LLNI_DIRECT(object);
+}
+
+
/* function prototypes ********************************************************/
void threads_preinit(void);