Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: java_lang_VMThread.c 6213 2006-12-18 17:36:06Z twisti $
-
*/
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_String.h"
#if defined(ENABLE_JAVASE)
# include "native/include/java_lang_ThreadGroup.h"
-# include "native/include/java_lang_VMThread.h"
+
+# if defined(WITH_CLASSPATH_GNU)
+# include "native/include/java_lang_VMThread.h"
+# endif
#endif
#include "threads/lock-common.h"
threadobject *thread;
#if defined(WITH_CLASSPATH_GNU)
- thread = (threadobject *) this->vmThread->vmdata;
+ thread = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata);
#elif defined(WITH_CLASSPATH_CLDC1_1)
thread = (threadobject *) this->vm_thread;
#endif
s4 _Jv_java_lang_Thread_isAlive(java_lang_Thread *this)
{
#if defined(ENABLE_THREADS)
- threadobject *thread;
+ threadobject *t;
-#if defined(WITH_CLASSPATH_GNU)
- thread = (threadobject *) this->vmThread->vmdata;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
- thread = (threadobject *) this->vm_thread;
-#endif
+# if defined(WITH_CLASSPATH_GNU)
+
+ t = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata);
+
+# elif defined(WITH_CLASSPATH_SUN)
+
+ /* XXX this is just a quick hack */
+
+ for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+ if (t->object == this)
+ break;
+ }
+
+ /* The threadobject is null when a thread is created in Java. The
+ priority is set later during startup. */
+
+ if (t == NULL)
+ return 0;
+
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+
+ t = (threadobject *) this->vm_thread;
+
+ if (t == NULL)
+ return 0;
+
+# else
+# error unknown classpath configuration
+# endif
- return threads_thread_is_alive(thread);
+ return threads_thread_is_alive(t);
#else
/* if threads are disabled, the only thread running is alive */
s4 _Jv_java_lang_Thread_isInterrupted(java_lang_Thread *this)
{
#if defined(ENABLE_THREADS)
- threadobject *thread;
+ threadobject *t;
-#if defined(WITH_CLASSPATH_GNU)
- thread = (threadobject *) this->vmThread->vmdata;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
- thread = (threadobject *) this->vm_thread;
-#endif
+# if defined(WITH_CLASSPATH_GNU)
+ t = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata);
+# elif defined(WITH_CLASSPATH_SUN)
+ /* XXX this is just a quick hack */
- return threads_thread_has_been_interrupted(thread);
+ for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+ if (t->object == this)
+ break;
+ }
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+ t = (threadobject *) this->vm_thread;
+# else
+# error unknown classpath configuration
+# endif
+
+ return threads_thread_has_been_interrupted(t);
#else
return 0;
#endif
void _Jv_java_lang_Thread_setPriority(java_lang_Thread *this, s4 priority)
{
#if defined(ENABLE_THREADS)
- threadobject *thread;
+ threadobject *t;
-#if defined(WITH_CLASSPATH_GNU)
- thread = (threadobject *) this->vmThread->vmdata;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
- thread = (threadobject *) this->vm_thread;
+# if defined(WITH_CLASSPATH_GNU)
+ t = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata);
+# elif defined(WITH_CLASSPATH_SUN)
+ /* XXX this is just a quick hack */
+
+ for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+ if (t->object == this)
+ break;
+ }
/* The threadobject is null when a thread is created in Java. The
priority is set later during startup. */
- if (thread == NULL)
+ if (t == NULL)
return;
-#endif
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+ t = (threadobject *) this->vm_thread;
+
+ /* The threadobject is null when a thread is created in Java. The
+ priority is set later during startup. */
+
+ if (t == NULL)
+ return;
+# else
+# error unknown classpath configuration
+# endif
- threads_set_thread_priority(thread->tid, priority);
+ threads_set_thread_priority(t->tid, priority);
#endif
}
log_text("t ptr is NULL\n");
# if defined(ENABLE_JAVASE)
- if (t->group == NULL) {
+ if (LLNI_field_direct(t, group) == NULL) {
/* ThreadGroup of currentThread is not initialized */
- t->group = (java_lang_ThreadGroup *)
+ LLNI_field_direct(t, group) = (java_lang_ThreadGroup *)
native_new_and_init(class_java_lang_ThreadGroup);
- if (t->group == NULL)
+ if (LLNI_field_direct(t, group) == NULL)
log_text("unable to create ThreadGroup");
}
# endif
s4 _Jv_java_lang_Thread_holdsLock(java_lang_Object* obj)
{
#if defined(ENABLE_THREADS)
- java_objectheader *o;
+ java_handle_t *o;
- o = (java_objectheader *) obj;
+ o = (java_handle_t *) obj;
if (o == NULL) {
exceptions_throw_nullpointerexception();
java_lang_String *_Jv_java_lang_Thread_getState(java_lang_Thread *this)
{
#if defined(ENABLE_THREADS)
- threadobject *thread;
- utf *u;
- java_objectheader *o;
+ threadobject *thread;
+ utf *u;
+ java_handle_t *o;
# if defined(WITH_CLASSPATH_GNU)
- thread = (threadobject *) this->vmThread->vmdata;
+ thread = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata);
# elif defined(WITH_CLASSPATH_CLDC1_1)
thread = (threadobject *) this->vm_thread;
# endif