-/* jni.c - implementation of the Java Native Interface functions
+/* native/jni.c - implementation of the Java Native Interface functions
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
- R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
- M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
- P. Tomsich, J. Wenninger, M. Platter
+ Copyright (C) 1996-2005 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
This file is part of CACAO.
Changes: Joseph Wenninger, Martin Platter
- $Id: jni.c 1470 2004-11-08 22:57:28Z motse $
+ $Id: jni.c 1735 2004-12-07 14:33:27Z twisti $
*/
#include <string.h>
-#include "exceptions.h"
-#include "main.h"
-#include "jni.h"
-#include "global.h"
-#include "loader.h"
-#include "tables.h"
-#include "native.h"
-#include "builtin.h"
-#include "options.h"
-#include "statistics.h"
-#include "threads/thread.h"
-#include "toolbox/logging.h"
-#include "toolbox/memory.h"
-#include "nat/java_lang_Byte.h"
-#include "nat/java_lang_Character.h"
-#include "nat/java_lang_Short.h"
-#include "nat/java_lang_Integer.h"
-#include "nat/java_lang_Boolean.h"
-#include "nat/java_lang_Long.h"
-#include "nat/java_lang_Float.h"
-#include "nat/java_lang_Double.h"
-#include "nat/java_lang_Throwable.h"
-#include "jit/jit.h"
-#include "asmpart.h"
+
#include "mm/boehm.h"
+#include "mm/memory.h"
+#include "native/jni.h"
+#include "native/native.h"
+#include "native/include/java_lang_Byte.h"
+#include "native/include/java_lang_Character.h"
+#include "native/include/java_lang_Short.h"
+#include "native/include/java_lang_Integer.h"
+#include "native/include/java_lang_Boolean.h"
+#include "native/include/java_lang_Long.h"
+#include "native/include/java_lang_Float.h"
+#include "native/include/java_lang_Double.h"
+#include "native/include/java_lang_Throwable.h"
+
+#if defined(USE_THREADS)
+# if defined(NATIVE_THREADS)
+# include "threads/native/threads.h"
+# else
+# include "threads/green/threads.h"
+# endif
+#endif
+
+#include "toolbox/logging.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/loader.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
+#include "vm/tables.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.h"
+
+
#define JNI_VERSION 0x00010002
/************* JNI Initialization ****************************************************/
jobject jni_init1(JNIEnv* env, jobject lobj) {
+#if defined(USE_THREADS)
while (initrunning) {yieldThread();} /* wait until init is done */
- if (global_ref_table != NULL) {
+#endif
+ if (global_ref_table == NULL) {
+ jni_init();
+ }
+#if defined(USE_THREADS)
+ else {
/* wait until jni_init is done */
MonitorEnter(env, *global_ref_table) ;
MonitorExit(env, *global_ref_table);
- } else {
- jni_init();
}
+#endif
return NewGlobalRef(env, lobj);
}
void jni_init2(JNIEnv* env, jobject gref) {
log_text("DeleteGlobalref called before NewGlobalref");
+#if defined(USE_THREADS)
while (initrunning) {yieldThread();} /* wait until init is done */
- if (global_ref_table != NULL) {
+#endif
+ if (global_ref_table == NULL) {
+ jni_init();
+ }
+#if defined(USE_THREADS)
+ else {
/* wait until jni_init is done */
MonitorEnter(env, *global_ref_table) ;
MonitorExit(env, *global_ref_table);
- } else {
- jni_init();
}
+#endif
DeleteGlobalRef(env, gref);
}
initrunning = true;
log_text("JNI-Init: initialize global_ref_table");
- // initalize global reference table
+ /* initalize global reference table */
ihmclass = FindClass(NULL, "java/util/IdentityHashMap");
if (ihmclass == NULL) {
if (!(methodID->flags & ACC_STATIC) && (!obj)) {
- *exceptionptr = new_exception_message(string_java_lang_NullPointerException,
- "Static mismatch in Java_java_lang_reflect_Method_invokeNative");
+ *exceptionptr =
+ new_exception_message(string_java_lang_NullPointerException,
+ "Static mismatch in Java_java_lang_reflect_Method_invokeNative");
return 0;
}