/* src/native/jni.c - implementation of the Java Native Interface functions
- 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
+ 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
This file is part of CACAO.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
- Contact: cacao@complang.tuwien.ac.at
-
- Authors: Rainhard Grafl
- Roman Obermaisser
-
- Changes: Joseph Wenninger
- Martin Platter
- Christian Thalinger
-
- $Id: jni.c 2439 2005-05-04 15:23:13Z twisti $
+ $Id: jni.c 7723 2007-04-16 18:03:08Z michi $
*/
+#include "config.h"
+
+#include <assert.h>
#include <string.h>
-#include "config.h"
-#include "mm/boehm.h"
+#include "vm/types.h"
+
+#include "mm/gc-common.h"
#include "mm/memory.h"
#include "native/jni.h"
#include "native/native.h"
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_CLASSPATH_GNU)
+# include "native/include/gnu_classpath_Pointer.h"
+
+# if SIZEOF_VOID_P == 8
+# include "native/include/gnu_classpath_Pointer64.h"
+# else
+# include "native/include/gnu_classpath_Pointer32.h"
+# endif
+# endif
+#endif
+
#include "native/include/java_lang_Object.h"
#include "native/include/java_lang_Byte.h"
#include "native/include/java_lang_Character.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_String.h"
#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_reflect_Method.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_Class.h" /* for java_lang_VMClass.h */
-#include "native/include/java_lang_VMClass.h"
-#include "native/include/java_lang_VMClassLoader.h"
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_ClassLoader.h"
-#if defined(USE_THREADS)
-# if defined(NATIVE_THREADS)
-# include "threads/native/threads.h"
-# else
-# include "threads/green/threads.h"
-# endif
+# include "native/include/java_lang_reflect_Constructor.h"
+# include "native/include/java_lang_reflect_Field.h"
+# include "native/include/java_lang_reflect_Method.h"
+
+# include "native/include/java_nio_Buffer.h"
+# include "native/include/java_nio_DirectByteBufferImpl.h"
+#endif
+
+#if defined(ENABLE_JVMTI)
+# include "native/jvmti/cacaodbg.h"
+#endif
+
+#include "native/vm/java_lang_Class.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/vm/java_lang_ClassLoader.h"
+#endif
+
+#if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
+# include "threads/native/threads.h"
+#else
+# include "threads/none/lock.h"
+# include "threads/none/threads.h"
#endif
#include "toolbox/logging.h"
+
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
-#include "vm/loader.h"
-#include "vm/options.h"
-#include "vm/resolve.h"
-#include "vm/statistics.h"
#include "vm/stringlocal.h"
-#include "vm/tables.h"
+#include "vm/vm.h"
+
#include "vm/jit/asmpart.h"
#include "vm/jit/jit.h"
-#include "vm/statistics.h"
-
-/* XXX TWISTI hack: define it extern so they can be found in this file */
-extern const struct JNIInvokeInterface JNI_JavaVMTable;
-extern struct JNINativeInterface JNI_JNIEnvTable;
-
-/* pointers to VM and the environment needed by GetJavaVM and GetEnv */
-static JavaVM ptr_jvm = (JavaVM) &JNI_JavaVMTable;
-static void* ptr_env = (void*) &JNI_JNIEnvTable;
-
-
-#define PTR_TO_ITEM(ptr) ((u8)(size_t)(ptr))
-
-/* global reference table */
-static jobject *global_ref_table;
-static bool initrunning=false;
-
-/* jmethodID and jclass caching variables for NewGlobalRef and DeleteGlobalRef*/
-static jmethodID getmid = NULL;
-static jmethodID putmid = NULL;
-static jclass intclass = NULL;
-static jmethodID intvalue = NULL;
-static jmethodID newint = NULL;
-static jclass ihmclass = NULL;
-static jmethodID removemid = NULL;
-
-#define JWCLINITDEBUG(x)
-
-
-/********************* accessing instance-fields **********************************/
-
-#define setField(obj,typ,var,val) *((typ*) ((long int) obj + (long int) var->offset))=val;
-#define getField(obj,typ,var) *((typ*) ((long int) obj + (long int) var->offset))
-#define setfield_critical(clazz,obj,name,sig,jdatatype,val) setField(obj,jdatatype,getFieldID_critical(env,clazz,name,sig),val);
-
-static void fill_callblock(void *obj, methoddesc *descr, jni_callblock blk[], va_list data, int rettype)
-{
- int cnt;
- u4 dummy;
- int i;
- typedesc *paramtype;
-
- if (obj) {
- /* the this pointer */
- blk[0].itemtype = TYPE_ADR;
- blk[0].item = PTR_TO_ITEM(obj);
- cnt = 1;
- }
- else
- cnt = 0;
-
- paramtype = descr->paramtypes;
- for (i=0; i<descr->paramcount; ++i,++cnt,++paramtype) {
- switch (paramtype->decltype) {
- /* primitive types */
- case PRIMITIVETYPE_BYTE:
- case PRIMITIVETYPE_CHAR:
- case PRIMITIVETYPE_SHORT:
- case PRIMITIVETYPE_BOOLEAN:
- blk[cnt].itemtype = TYPE_INT;
- blk[cnt].item = (u8) va_arg(data, int);
- break;
+#include "vm/jit/stacktrace.h"
- case PRIMITIVETYPE_INT:
- blk[cnt].itemtype = TYPE_INT;
- dummy = va_arg(data, u4);
- /*printf("fill_callblock: pos:%d, value:%d\n",cnt,dummy);*/
- blk[cnt].item = (u8) dummy;
- break;
+#include "vmcore/loader.h"
+#include "vmcore/options.h"
+#include "vm/resolve.h"
+#include "vmcore/statistics.h"
- case PRIMITIVETYPE_LONG:
- blk[cnt].itemtype = TYPE_LNG;
- blk[cnt].item = (u8) va_arg(data, jlong);
- break;
- case PRIMITIVETYPE_FLOAT:
- blk[cnt].itemtype = TYPE_FLT;
- *((jfloat *) (&blk[cnt].item)) = (jfloat) va_arg(data, jdouble);
- break;
+/* global variables ***********************************************************/
- case PRIMITIVETYPE_DOUBLE:
- blk[cnt].itemtype = TYPE_DBL;
- *((jdouble *) (&blk[cnt].item)) = (jdouble) va_arg(data, jdouble);
- break;
+/* global reference table *****************************************************/
- case TYPE_ADR:
- blk[cnt].itemtype = TYPE_ADR;
- blk[cnt].item = PTR_TO_ITEM(va_arg(data, void*));
- break;
- }
- }
+/* hashsize must be power of 2 */
+
+#define HASHTABLE_GLOBAL_REF_SIZE 64 /* initial size of globalref-hash */
+
+hashtable *hashtable_global_ref; /* hashtable for globalrefs */
+
+
+/* direct buffer stuff ********************************************************/
+
+#if defined(ENABLE_JAVASE)
+static classinfo *class_java_nio_Buffer;
+static classinfo *class_java_nio_DirectByteBufferImpl;
+static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite;
+
+# if defined(WITH_CLASSPATH_GNU)
+# if SIZEOF_VOID_P == 8
+static classinfo *class_gnu_classpath_Pointer64;
+# else
+static classinfo *class_gnu_classpath_Pointer32;
+# endif
+# endif
+
+static methodinfo *dbbirw_init;
+#endif
+
+
+/* local reference table ******************************************************/
+
+#if !defined(ENABLE_THREADS)
+localref_table *_no_threads_localref_table;
+#endif
+
+
+/* accessing instance fields macros *******************************************/
+
+#define SET_FIELD(o,type,f,value) \
+ *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset)) = (type) (value)
+
+#define GET_FIELD(o,type,f) \
+ *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset))
+
+
+/* some forward declarations **************************************************/
+
+jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref);
+jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity);
+
+
+/* jni_init ********************************************************************
+
+ Initialize the JNI subsystem.
+
+*******************************************************************************/
+
+bool jni_init(void)
+{
+ /* create global ref hashtable */
+
+ hashtable_global_ref = NEW(hashtable);
+
+ hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
- /*the standard doesn't say anything about return value checking, but it appears to be usefull*/
- if (rettype != descr->returntype.decltype)
- log_text("\n====\nWarning call*Method called for function with wrong return type\n====");
+
+#if defined(ENABLE_JAVASE)
+ /* direct buffer stuff */
+
+ if (!(class_java_nio_Buffer =
+ load_class_bootstrap(utf_new_char("java/nio/Buffer"))) ||
+ !link_class(class_java_nio_Buffer))
+ return false;
+
+ if (!(class_java_nio_DirectByteBufferImpl =
+ load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
+ !link_class(class_java_nio_DirectByteBufferImpl))
+ return false;
+
+ if (!(class_java_nio_DirectByteBufferImpl_ReadWrite =
+ load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) ||
+ !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite))
+ return false;
+
+ if (!(dbbirw_init =
+ class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite,
+ utf_init,
+ utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
+ return false;
+
+# if defined(WITH_CLASSPATH_GNU)
+# if SIZEOF_VOID_P == 8
+ if (!(class_gnu_classpath_Pointer64 =
+ load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
+ !link_class(class_gnu_classpath_Pointer64))
+ return false;
+# else
+ if (!(class_gnu_classpath_Pointer32 =
+ load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) ||
+ !link_class(class_gnu_classpath_Pointer32))
+ return false;
+# endif
+# endif
+#endif /* defined(ENABLE_JAVASE) */
+
+ return true;
+}
+
+
+/* jni_init_localref_table *****************************************************
+
+ Initializes the local references table of the current thread.
+
+*******************************************************************************/
+
+bool jni_init_localref_table(void)
+{
+ localref_table *lrt;
+
+#if defined(ENABLE_GC_CACAO)
+ /* XXX this one will never get freed for the main thread;
+ call jni_free_localref_table() if you want to do it! */
+ lrt = NEW(localref_table);
+#else
+ lrt = GCNEW(localref_table);
+#endif
+
+ if (lrt == NULL)
+ return false;
+
+ lrt->capacity = LOCALREFTABLE_CAPACITY;
+ lrt->used = 0;
+ lrt->localframes = 1;
+ lrt->prev = LOCALREFTABLE;
+
+ /* clear the references array (memset is faster then a for-loop) */
+
+ MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
+
+ LOCALREFTABLE = lrt;
+
+ return true;
+}
+
+
+/* jni_init_localref_table *****************************************************
+
+ Frees the local references table of the current thread.
+
+*******************************************************************************/
+
+bool jni_free_localref_table(void)
+{
+ localref_table *lrt;
+
+#if defined(ENABLE_GC_CACAO)
+ lrt = LOCALREFTABLE;
+
+ assert(lrt);
+ assert(lrt->prev == NULL);
+
+ FREE(lrt, localref_table);
+
+ LOCALREFTABLE = NULL;
+#endif
+
+ return true;
}
-/* XXX it could be considered if we should do typechecking here in the future */
-static bool fill_callblock_objA(void *obj, methoddesc *descr, jni_callblock blk[], java_objectarray* params,
- int *rettype)
+
+/* _Jv_jni_vmargs_from_objectarray *********************************************
+
+ XXX
+
+*******************************************************************************/
+
+static bool _Jv_jni_vmargs_from_objectarray(java_objectheader *o,
+ methoddesc *descr,
+ vm_arg *vmargs,
+ java_objectarray *params)
{
- jobject param;
- int cnt;
- int cnts;
- typedesc *paramtype;
+ java_objectheader *param;
+ s4 paramcount;
+ typedesc *paramtypes;
+ classinfo *c;
+ s4 i;
+ s4 j;
+ s8 value;
+
+ paramcount = descr->paramcount;
+ paramtypes = descr->paramtypes;
+
+ /* if method is non-static fill first block and skip `this' pointer */
- /* determine number of parameters */
- if (obj) {
+ i = 0;
+
+ if (o != NULL) {
/* this pointer */
- blk[0].itemtype = TYPE_ADR;
- blk[0].item = PTR_TO_ITEM(obj);
- cnt=1;
- } else {
- cnt = 0;
+ vmargs[0].type = TYPE_ADR;
+ vmargs[0].data.l = (u8) (ptrint) o;
+
+ paramtypes++;
+ paramcount--;
+ i++;
}
- paramtype = descr->paramtypes;
- for (cnts=0; cnts < descr->paramcount; ++cnts,++cnt,++paramtype) {
- switch (paramtype->type) {
- /* primitive types */
- case TYPE_INT:
- case TYPE_LONG:
- case TYPE_FLOAT:
- case TYPE_DOUBLE:
-
- param = params->data[cnts];
- if (!param)
+ for (j = 0; j < paramcount; i++, j++, paramtypes++) {
+ switch (paramtypes->type) {
+ /* primitive types */
+ case TYPE_INT:
+ case TYPE_LNG:
+ case TYPE_FLT:
+ case TYPE_DBL:
+ param = params->data[j];
+
+ if (param == NULL)
+ goto illegal_arg;
+
+ /* internally used data type */
+ vmargs[i].type = paramtypes->type;
+
+ /* convert the value according to its declared type */
+
+ c = param->vftbl->class;
+
+ switch (paramtypes->decltype) {
+ case PRIMITIVETYPE_BOOLEAN:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ value = (s8) ((java_lang_Boolean *) param)->value;
+ else
goto illegal_arg;
- /* internally used data type */
- blk[cnt].itemtype = paramtype->type;
-
- /* convert the value according to its declared type */
- switch (paramtype->decltype) {
- case PRIMITIVETYPE_BOOLEAN:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Boolean *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_BYTE:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Byte *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_CHAR:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Character *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_SHORT:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Short *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Byte *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_INT:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Integer *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_SHORT].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Short *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Byte *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_LONG:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Long *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_INT].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Integer *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_SHORT].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Short *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
- blk[cnt].item = (u8) ((java_lang_Byte *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_FLOAT:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- *((jfloat *) (&blk[cnt].item)) = (jfloat) ((java_lang_Float *) param)->value;
- else
- goto illegal_arg;
- break;
- case PRIMITIVETYPE_DOUBLE:
- if (param->vftbl->class == primitivetype_table[paramtype->decltype].class_wrap)
- *((jdouble *) (&blk[cnt].item)) = (jdouble) ((java_lang_Float *) param)->value;
- else if (param->vftbl->class == primitivetype_table[PRIMITIVETYPE_FLOAT].class_wrap)
- *((jfloat *) (&blk[cnt].item)) = (jfloat) ((java_lang_Float *) param)->value;
- else
- goto illegal_arg;
- break;
- default:
- goto illegal_arg;
- } /* end declared type switch */
+ vmargs[i].data.l = value;
+ break;
+
+ case PRIMITIVETYPE_BYTE:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ value = (s8) ((java_lang_Byte *) param)->value;
+ else
+ goto illegal_arg;
+
+ vmargs[i].data.l = value;
+ break;
+
+ case PRIMITIVETYPE_CHAR:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ value = (s8) ((java_lang_Character *) param)->value;
+ else
+ goto illegal_arg;
+
+ vmargs[i].data.l = value;
+ break;
+
+ case PRIMITIVETYPE_SHORT:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ value = (s8) ((java_lang_Short *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
+ value = (s8) ((java_lang_Byte *) param)->value;
+ else
+ goto illegal_arg;
+
+ vmargs[i].data.l = value;
+ break;
+
+ case PRIMITIVETYPE_INT:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ value = (s8) ((java_lang_Integer *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_SHORT].class_wrap)
+ value = (s8) ((java_lang_Short *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
+ value = (s8) ((java_lang_Byte *) param)->value;
+ else
+ goto illegal_arg;
+
+ vmargs[i].data.l = value;
+ break;
+
+ case PRIMITIVETYPE_LONG:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ value = (s8) ((java_lang_Long *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_INT].class_wrap)
+ value = (s8) ((java_lang_Integer *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_SHORT].class_wrap)
+ value = (s8) ((java_lang_Short *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_BYTE].class_wrap)
+ value = (s8) ((java_lang_Byte *) param)->value;
+ else
+ goto illegal_arg;
+
+ vmargs[i].data.l = value;
+ break;
+
+ case PRIMITIVETYPE_FLOAT:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ vmargs[i].data.f = (jfloat) ((java_lang_Float *) param)->value;
+ else
+ goto illegal_arg;
+ break;
+
+ case PRIMITIVETYPE_DOUBLE:
+ if (c == primitivetype_table[paramtypes->decltype].class_wrap)
+ vmargs[i].data.d = (jdouble) ((java_lang_Double *) param)->value;
+ else if (c == primitivetype_table[PRIMITIVETYPE_FLOAT].class_wrap)
+ vmargs[i].data.f = (jfloat) ((java_lang_Float *) param)->value;
+ else
+ goto illegal_arg;
break;
+
+ default:
+ goto illegal_arg;
+ }
+ break;
- case TYPE_ADDRESS:
- {
- classinfo *cls;
-
- if (!resolve_class_from_typedesc(paramtype,true,&cls))
- return false; /* exception */
- if (params->data[cnts] != 0) {
- if (paramtype->arraydim > 0) {
- if (!builtin_arrayinstanceof(params->data[cnts], cls->vftbl))
- goto illegal_arg;
- }
- else {
- if (!builtin_instanceof(params->data[cnts], cls))
- goto illegal_arg;
- }
+ case TYPE_ADR:
+ if (!resolve_class_from_typedesc(paramtypes, true, true, &c))
+ return false;
+
+ if (params->data[j] != 0) {
+ if (paramtypes->arraydim > 0) {
+ if (!builtin_arrayinstanceof(params->data[j], c))
+ goto illegal_arg;
+
+ } else {
+ if (!builtin_instanceof(params->data[j], c))
+ goto illegal_arg;
}
- blk[cnt].itemtype = TYPE_ADR;
- blk[cnt].item = PTR_TO_ITEM(params->data[cnts]);
}
- break;
+
+ vmargs[i].type = TYPE_ADR;
+ vmargs[i].data.l = (u8) (ptrint) params->data[j];
+ break;
default:
goto illegal_arg;
- } /* end param type switch */
+ }
+ }
- } /* end param loop */
+/* if (rettype) */
+/* *rettype = descr->returntype.decltype; */
- if (rettype)
- *rettype = descr->returntype.decltype;
return true;
-illegal_arg:
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- return false;
-}
+illegal_arg:
+ exceptions_throw_illegalargumentexception();
+ return false;
+}
+
+
+/* _Jv_jni_CallObjectMethod ****************************************************
+
+ Internal function to call Java Object methods.
+
+*******************************************************************************/
+
+static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o,
+ vftbl_t *vftbl,
+ methodinfo *m, va_list ap)
+{
+ methodinfo *resm;
+ java_objectheader *ro;
+
+ STATISTICS(jniinvokation());
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return NULL;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ ro = vm_call_method_valist(resm, o, ap);
+
+ return ro;
+}
+
+
+/* _Jv_jni_CallObjectMethodA ***************************************************
+
+ Internal function to call Java Object methods.
+
+*******************************************************************************/
+
+static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o,
+ vftbl_t *vftbl,
+ methodinfo *m, jvalue *args)
+{
+ methodinfo *resm;
+ java_objectheader *ro;
+
+ STATISTICS(jniinvokation());
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return NULL;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ ro = vm_call_method_jvalue(resm, o, args);
+
+ return ro;
+}
+
+
+/* _Jv_jni_CallIntMethod *******************************************************
+
+ Internal function to call Java integer class methods (boolean,
+ byte, char, short, int).
+
+*******************************************************************************/
+
+static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, va_list ap)
+{
+ methodinfo *resm;
+ jint i;
+
+ STATISTICS(jniinvokation());
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return 0;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ i = vm_call_method_int_valist(resm, o, ap);
+
+ return i;
+}
+
+
+/* _Jv_jni_CallIntMethodA ******************************************************
+
+ Internal function to call Java integer class methods (boolean,
+ byte, char, short, int).
+
+*******************************************************************************/
+
+static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, jvalue *args)
+{
+ methodinfo *resm;
+ jint i;
+
+ STATISTICS(jniinvokation());
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return 0;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ i = vm_call_method_int_jvalue(resm, o, args);
+
+ return i;
+}
+
+
+/* _Jv_jni_CallLongMethod ******************************************************
+
+ Internal function to call Java long methods.
+
+*******************************************************************************/
+
+static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, va_list ap)
+{
+ methodinfo *resm;
+ jlong l;
+
+ STATISTICS(jniinvokation());
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return 0;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ l = vm_call_method_long_valist(resm, o, ap);
+
+ return l;
+}
+
+
+/* _Jv_jni_CallFloatMethod *****************************************************
+
+ Internal function to call Java float methods.
+
+*******************************************************************************/
+
+static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, va_list ap)
+{
+ methodinfo *resm;
+ jfloat f;
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ f = vm_call_method_float_valist(resm, o, ap);
+
+ return f;
+}
+
+
+/* _Jv_jni_CallDoubleMethod ****************************************************
+
+ Internal function to call Java double methods.
+
+*******************************************************************************/
+
+static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, va_list ap)
+{
+ methodinfo *resm;
+ jdouble d;
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ d = vm_call_method_double_valist(resm, o, ap);
+
+ return d;
+}
+
+
+/* _Jv_jni_CallVoidMethod ******************************************************
+
+ Internal function to call Java void methods.
+
+*******************************************************************************/
+
+static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, va_list ap)
+{
+ methodinfo *resm;
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ (void) vm_call_method_valist(resm, o, ap);
+}
+
+
+/* _Jv_jni_CallVoidMethodA *****************************************************
+
+ Internal function to call Java void methods.
+
+*******************************************************************************/
+
+static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
+ methodinfo *m, jvalue *args)
+{
+ methodinfo *resm;
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return;
+ }
+
+ /* Class initialization is done by the JIT compiler. This is ok
+ since a static method always belongs to the declaring class. */
+
+ if (m->flags & ACC_STATIC) {
+ /* For static methods we reset the object. */
+
+ if (o != NULL)
+ o = NULL;
+
+ /* for convenience */
+
+ resm = m;
+
+ } else {
+ /* For instance methods we make a virtual function table lookup. */
+
+ resm = method_vftbl_lookup(vftbl, m);
+ }
+
+ STATISTICS(jnicallXmethodnvokation());
+
+ (void) vm_call_method_jvalue(resm, o, args);
+}
+
+
+/* _Jv_jni_invokeNative ********************************************************
+
+ Invoke a method on the given object with the given arguments.
+
+ For instance methods OBJ must be != NULL and the method is looked up
+ in the vftbl of the object.
+
+ For static methods, OBJ is ignored.
+
+*******************************************************************************/
+
+java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
+ java_objectarray *params)
+{
+ methodinfo *resm;
+ vm_arg *vmargs;
+ java_objectheader *ro;
+ s4 argcount;
+ s4 paramcount;
+ java_objectheader *xptr;
+
+ if (m == NULL) {
+ exceptions_throw_nullpointerexception();
+ return NULL;
+ }
+
+ argcount = m->parseddesc->paramcount;
+ paramcount = argcount;
+
+ /* if method is non-static, remove the `this' pointer */
+
+ if (!(m->flags & ACC_STATIC))
+ paramcount--;
+
+ /* For instance methods the object has to be an instance of the
+ class the method belongs to. For static methods the obj
+ parameter is ignored. */
+
+ if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) {
+ exceptions_throw_illegalargumentexception();
+ return NULL;
+ }
+
+ /* check if we got the right number of arguments */
+
+ if (((params == NULL) && (paramcount != 0)) ||
+ (params && (params->header.size != paramcount)))
+ {
+ exceptions_throw_illegalargumentexception();
+ return NULL;
+ }
+
+ /* for instance methods we need an object */
+
+ if (!(m->flags & ACC_STATIC) && (o == NULL)) {
+ /* XXX not sure if that is the correct exception */
+ exceptions_throw_nullpointerexception();
+ return NULL;
+ }
+
+ /* for static methods, zero object to make subsequent code simpler */
+ if (m->flags & ACC_STATIC)
+ o = NULL;
+
+ if (o != NULL) {
+ /* for instance methods we must do a vftbl lookup */
+ resm = method_vftbl_lookup(o->vftbl, m);
+ }
+ else {
+ /* for static methods, just for convenience */
+ resm = m;
+ }
+
+ vmargs = MNEW(vm_arg, argcount);
+
+ if (!_Jv_jni_vmargs_from_objectarray(o, resm->parseddesc, vmargs, params)) {
+ MFREE(vmargs, vm_arg, argcount);
+ return NULL;
+ }
+
+ switch (resm->parseddesc->returntype.decltype) {
+ case TYPE_VOID:
+ (void) vm_call_method_vmarg(resm, argcount, vmargs);
+
+ ro = NULL;
+ break;
+
+ case PRIMITIVETYPE_BOOLEAN: {
+ s4 i;
+ java_lang_Boolean *bo;
+
+ i = vm_call_method_int_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Boolean);
+
+ /* setting the value of the object direct */
+
+ bo = (java_lang_Boolean *) ro;
+ bo->value = i;
+ }
+ break;
+
+ case PRIMITIVETYPE_BYTE: {
+ s4 i;
+ java_lang_Byte *bo;
+
+ i = vm_call_method_int_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Byte);
+
+ /* setting the value of the object direct */
+
+ bo = (java_lang_Byte *) ro;
+ bo->value = i;
+ }
+ break;
+
+ case PRIMITIVETYPE_CHAR: {
+ s4 i;
+ java_lang_Character *co;
+
+ i = vm_call_method_int_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Character);
+
+ /* setting the value of the object direct */
+
+ co = (java_lang_Character *) ro;
+ co->value = i;
+ }
+ break;
+
+ case PRIMITIVETYPE_SHORT: {
+ s4 i;
+ java_lang_Short *so;
+
+ i = vm_call_method_int_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Short);
+
+ /* setting the value of the object direct */
+
+ so = (java_lang_Short *) ro;
+ so->value = i;
+ }
+ break;
+
+ case PRIMITIVETYPE_INT: {
+ s4 i;
+ java_lang_Integer *io;
+
+ i = vm_call_method_int_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Integer);
+
+ /* setting the value of the object direct */
+
+ io = (java_lang_Integer *) ro;
+ io->value = i;
+ }
+ break;
+
+ case PRIMITIVETYPE_LONG: {
+ s8 l;
+ java_lang_Long *lo;
+
+ l = vm_call_method_long_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Long);
+
+ /* setting the value of the object direct */
+
+ lo = (java_lang_Long *) ro;
+ lo->value = l;
+ }
+ break;
+
+ case PRIMITIVETYPE_FLOAT: {
+ float f;
+ java_lang_Float *fo;
+
+ f = vm_call_method_float_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Float);
+
+ /* setting the value of the object direct */
+
+ fo = (java_lang_Float *) ro;
+ fo->value = f;
+ }
+ break;
+
+ case PRIMITIVETYPE_DOUBLE: {
+ double d;
+ java_lang_Double *_do;
+
+ d = vm_call_method_double_vmarg(resm, argcount, vmargs);
+
+ ro = builtin_new(class_java_lang_Double);
+
+ /* setting the value of the object direct */
+
+ _do = (java_lang_Double *) ro;
+ _do->value = d;
+ }
+ break;
+
+ case TYPE_ADR:
+ ro = vm_call_method_vmarg(resm, argcount, vmargs);
+ break;
+
+ default:
+ /* if this happens the exception has already been set by
+ fill_callblock_from_objectarray */
+
+ MFREE(vmargs, vm_arg, argcount);
+
+ return NULL;
+ }
+
+ MFREE(vmargs, vm_arg, argcount);
+
+ xptr = exceptions_get_exception();
+
+ if (xptr != NULL) {
+ /* clear exception pointer, we are calling JIT code again */
+
+ exceptions_clear_exception();
+
+ exceptions_throw_invocationtargetexception(xptr);
+ }
+
+ return ro;
+}
+
+
+/* GetVersion ******************************************************************
+
+ Returns the major version number in the higher 16 bits and the
+ minor version number in the lower 16 bits.
+
+*******************************************************************************/
+
+jint _Jv_JNI_GetVersion(JNIEnv *env)
+{
+ STATISTICS(jniinvokation());
+
+ /* we support JNI 1.4 */
+
+ return JNI_VERSION_1_4;
+}
+
+
+/* Class Operations ***********************************************************/
+
+/* DefineClass *****************************************************************
+
+ Loads a class from a buffer of raw class data. The buffer
+ containing the raw class data is not referenced by the VM after the
+ DefineClass call returns, and it may be discarded if desired.
+
+*******************************************************************************/
+
+jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
+ const jbyte *buf, jsize bufLen)
+{
+#if defined(ENABLE_JAVASE)
+ java_lang_ClassLoader *cl;
+ java_lang_String *s;
+ java_bytearray *ba;
+ jclass c;
+
+ STATISTICS(jniinvokation());
+
+ cl = (java_lang_ClassLoader *) loader;
+ s = (java_lang_String *) javastring_new_from_utf_string(name);
+ ba = (java_bytearray *) buf;
+
+ c = (jclass) _Jv_java_lang_ClassLoader_defineClass(cl, s, ba, 0, bufLen,
+ NULL);
+
+ return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
+#else
+ vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
+
+ /* keep compiler happy */
+
+ return 0;
+#endif
+}
+
+
+/* FindClass *******************************************************************
+
+ This function loads a locally-defined class. It searches the
+ directories and zip files specified by the CLASSPATH environment
+ variable for the class with the specified name.
+
+*******************************************************************************/
+
+jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
+{
+#if defined(ENABLE_JAVASE)
+ utf *u;
+ classinfo *cc;
+ classinfo *c;
+
+ STATISTICS(jniinvokation());
+
+ u = utf_new_char_classname((char *) name);
+
+ /* Check stacktrace for classloader, if one found use it,
+ otherwise use the system classloader. */
+
+ /* Quote from the JNI documentation:
+
+ In the Java 2 Platform, FindClass locates the class loader
+ associated with the current native method. If the native code
+ belongs to a system class, no class loader will be
+ involved. Otherwise, the proper class loader will be invoked to
+ load and link the named class. When FindClass is called through
+ the Invocation Interface, there is no current native method or
+ its associated class loader. In that case, the result of
+ ClassLoader.getBaseClassLoader is used." */
+
+ cc = stacktrace_getCurrentClass();
+
+ if (cc == NULL)
+ c = load_class_from_sysloader(u);
+ else
+ c = load_class_from_classloader(u, cc->classloader);
+
+ if (c == NULL)
+ return NULL;
+
+ if (!link_class(c))
+ return NULL;
+
+ return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
+#else
+ vm_abort("_Jv_JNI_FindClass: not implemented in this configuration");
+
+ /* keep compiler happy */
+
+ return NULL;
+#endif
+}
+
+
+/* GetSuperclass ***************************************************************
+
+ If clazz represents any class other than the class Object, then
+ this function returns the object that represents the superclass of
+ the class specified by clazz.
+
+*******************************************************************************/
+
+jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
+{
+ classinfo *c;
+
+ STATISTICS(jniinvokation());
+
+ c = ((classinfo *) sub)->super.cls;
+
+ if (!c)
+ return NULL;
+
+ return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
+}
+
+
+/* IsAssignableFrom ************************************************************
+
+ Determines whether an object of sub can be safely cast to sup.
+
+*******************************************************************************/
+
+jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
+{
+ java_lang_Class *csup;
+ java_lang_Class *csub;
+
+ csup = (java_lang_Class *) sup;
+ csub = (java_lang_Class *) sub;
+
+ STATISTICS(jniinvokation());
+
+ return _Jv_java_lang_Class_isAssignableFrom(csup, csub);
+}
+
+
+/* Throw ***********************************************************************
+
+ Causes a java.lang.Throwable object to be thrown.
+
+*******************************************************************************/
+
+jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj)
+{
+ java_objectheader *o;
+
+ STATISTICS(jniinvokation());
+
+ o = (java_objectheader *) obj;
+
+ exceptions_set_exception(o);
+
+ return JNI_OK;
+}
+
+
+/* ThrowNew ********************************************************************
+
+ Constructs an exception object from the specified class with the
+ message specified by message and causes that exception to be
+ thrown.
+
+*******************************************************************************/
+
+jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
+{
+ classinfo *c;
+ java_objectheader *o;
+ java_objectheader *s;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ s = javastring_new_from_utf_string(msg);
+
+ /* instantiate exception object */
+
+ o = native_new_and_init_string(c, s);
+
+ if (o == NULL)
+ return -1;
+
+ exceptions_set_exception(o);
+
+ return 0;
+}
+
+
+/* ExceptionOccurred ***********************************************************
+
+ Determines if an exception is being thrown. The exception stays
+ being thrown until either the native code calls ExceptionClear(),
+ or the Java code handles the exception.
+
+*******************************************************************************/
+
+jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
+{
+ java_objectheader *o;
+
+ STATISTICS(jniinvokation());
+
+ o = exceptions_get_exception();
+
+ return _Jv_JNI_NewLocalRef(env, (jthrowable) o);
+}
+
+
+/* ExceptionDescribe ***********************************************************
+
+ Prints an exception and a backtrace of the stack to a system
+ error-reporting channel, such as stderr. This is a convenience
+ routine provided for debugging.
+
+*******************************************************************************/
+
+void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
+{
+ java_objectheader *o;
+ methodinfo *m;
+
+ STATISTICS(jniinvokation());
+
+ o = exceptions_get_exception();
+
+ if (o == NULL) {
+ /* clear exception, because we are calling jit code again */
+
+ exceptions_clear_exception();
+
+ /* get printStackTrace method from exception class */
+
+ m = class_resolveclassmethod(o->vftbl->class,
+ utf_printStackTrace,
+ utf_void__void,
+ NULL,
+ true);
+
+ if (m == NULL)
+ /* XXX what should we do? */
+ return;
+
+ /* print the stacktrace */
+
+ (void) vm_call_method(m, o);
+ }
+}
+
+
+/* ExceptionClear **************************************************************
+
+ Clears any exception that is currently being thrown. If no
+ exception is currently being thrown, this routine has no effect.
+
+*******************************************************************************/
+
+void _Jv_JNI_ExceptionClear(JNIEnv *env)
+{
+ STATISTICS(jniinvokation());
+
+ exceptions_clear_exception();
+}
+
+
+/* FatalError ******************************************************************
+
+ Raises a fatal error and does not expect the VM to recover. This
+ function does not return.
+
+*******************************************************************************/
+
+void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
+{
+ STATISTICS(jniinvokation());
+
+ /* this seems to be the best way */
+
+ vm_abort(msg);
+}
+
+
+/* PushLocalFrame **************************************************************
+
+ Creates a new local reference frame, in which at least a given
+ number of local references can be created.
+
+*******************************************************************************/
+
+jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity)
+{
+ s4 additionalrefs;
+ localref_table *lrt;
+ localref_table *nlrt;
+
+ STATISTICS(jniinvokation());
+
+ if (capacity <= 0)
+ return -1;
+
+ /* Allocate new local reference table on Java heap. Calculate the
+ additional memory we have to allocate. */
+
+ if (capacity > LOCALREFTABLE_CAPACITY)
+ additionalrefs = capacity - LOCALREFTABLE_CAPACITY;
+ else
+ additionalrefs = 0;
+
+#if defined(ENABLE_GC_CACAO)
+ nlrt = MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
+#else
+ nlrt = GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
+#endif
+
+ if (nlrt == NULL)
+ return -1;
+
+ /* get current local reference table from thread */
+
+ lrt = LOCALREFTABLE;
+
+ /* Set up the new local reference table and add it to the local
+ frames chain. */
+
+ nlrt->capacity = capacity;
+ nlrt->used = 0;
+ nlrt->localframes = lrt->localframes + 1;
+ nlrt->prev = lrt;
+
+ /* store new local reference table in thread */
+
+ LOCALREFTABLE = nlrt;
+
+ return 0;
+}
+
+
+/* PopLocalFrame ***************************************************************
+
+ Pops off the current local reference frame, frees all the local
+ references, and returns a local reference in the previous local
+ reference frame for the given result object.
+
+*******************************************************************************/
+
+jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result)
+{
+ localref_table *lrt;
+ localref_table *plrt;
+ s4 localframes;
+ s4 additionalrefs;
+
+ STATISTICS(jniinvokation());
+
+ /* get current local reference table from thread */
+
+ lrt = LOCALREFTABLE;
+ localframes = lrt->localframes;
-static jmethodID get_virtual(jobject obj,jmethodID methodID) {
- if (obj->vftbl->class==methodID->class) return methodID;
- return class_resolvemethod (obj->vftbl->class, methodID->name, methodID->descriptor);
-}
+ /* Don't delete the top local frame, as this one is allocated in
+ the native stub on the stack and is freed automagically on
+ return. */
+ if (localframes == 1)
+ return _Jv_JNI_NewLocalRef(env, result);
-static jmethodID get_nonvirtual(jclass clazz,jmethodID methodID) {
- if (clazz==methodID->class) return methodID;
-/*class_resolvemethod -> classfindmethod? (JOWENN)*/
- return class_resolvemethod (clazz, methodID->name, methodID->descriptor);
-}
+ /* release all current local frames */
+ for (; localframes >= 1; localframes--) {
+ /* get previous frame */
-static jobject callObjectMethod (jobject obj, jmethodID methodID, va_list args)
-{
- int argcount;
- jni_callblock *blk;
- jobject ret;
+ plrt = lrt->prev;
+ /* clear all reference entries */
+ MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity);
- if (methodID == 0) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+ lrt->prev = NULL;
- argcount = methodID->parseddesc->paramcount;
+#if defined(ENABLE_GC_CACAO)
+ /* for the exact GC local reference tables are not on the heap,
+ so we need to free them explicitly here. */
- if (!( ((methodID->flags & ACC_STATIC) && (obj == 0)) ||
- ((!(methodID->flags & ACC_STATIC)) && (obj != 0)) )) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+ if (lrt->capacity > LOCALREFTABLE_CAPACITY)
+ additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY;
+ else
+ additionalrefs = 0;
- if (obj && !builtin_instanceof(obj, methodID->class)) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+ MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P);
+#endif
-#ifdef arglimit
+ /* set new local references table */
- if (argcount > 3) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- log_text("Too many arguments. CallObjectMethod does not support that");
- return 0;
+ lrt = plrt;
}
-#endif
- blk = MNEW(jni_callblock, /*4 */argcount+2);
+ /* store new local reference table in thread */
- fill_callblock(obj, methodID->parseddesc, blk, args, TYPE_ADR);
- /* printf("parameter: obj: %p",blk[0].item); */
- STATS(jnicallXmethodnvokation();)
- ret = asm_calljavafunction2(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- MFREE(blk, jni_callblock, argcount + 1);
- /* printf("(CallObjectMethodV)-->%p\n",ret); */
+ LOCALREFTABLE = lrt;
- return ret;
+ /* add local reference and return the value */
+
+ return _Jv_JNI_NewLocalRef(env, result);
}
-/*
- core function for integer class methods (bool, byte, short, integer)
- This is basically needed for i386
-*/
-static jint callIntegerMethod(jobject obj, jmethodID methodID, int retType, va_list args)
-{
- int argcount;
- jni_callblock *blk;
- jint ret;
-
- STATS(jniinvokation();)
-
- /*
- log_text("JNI-Call: CallObjectMethodV");
- utf_display(methodID->name);
- utf_display(methodID->descriptor);
- printf("\nParmaeter count: %d\n",argcount);
- utf_display(obj->vftbl->class->name);
- printf("\n");
- */
- if (methodID == 0) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
-
- argcount = methodID->parseddesc->paramcount;
+/* DeleteLocalRef **************************************************************
- if (!( ((methodID->flags & ACC_STATIC) && (obj == 0)) ||
- ((!(methodID->flags & ACC_STATIC)) && (obj != 0)) )) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+ Deletes the local reference pointed to by localRef.
- if (obj && !builtin_instanceof(obj, methodID->class)) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+*******************************************************************************/
-#ifdef arglimit
- if (argcount > 3) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- log_text("Too many arguments. CallIntegerMethod does not support that");
- return 0;
- }
-#endif
+void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef)
+{
+ java_objectheader *o;
+ localref_table *lrt;
+ s4 i;
- blk = MNEW(jni_callblock, /*4 */ argcount+2);
+ STATISTICS(jniinvokation());
- fill_callblock(obj, methodID->parseddesc, blk, args, retType);
+ o = (java_objectheader *) localRef;
- /* printf("parameter: obj: %p",blk[0].item); */
- STATS(jnicallXmethodnvokation();)
- ret = asm_calljavafunction2int(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
+ /* get local reference table (thread specific) */
- MFREE(blk, jni_callblock, argcount + 1);
- /* printf("(CallObjectMethodV)-->%p\n",ret); */
+ lrt = LOCALREFTABLE;
- return ret;
-}
+ /* go through all local frames */
+ for (; lrt != NULL; lrt = lrt->prev) {
-/*core function for long class functions*/
-static jlong callLongMethod(jobject obj, jmethodID methodID, va_list args)
-{
- int argcount;
- jni_callblock *blk;
- jlong ret;
+ /* and try to remove the reference */
- STATS(jniinvokation();)
+ for (i = 0; i < lrt->capacity; i++) {
+ if (lrt->refs[i] == o) {
+ lrt->refs[i] = NULL;
+ lrt->used--;
-/*
- log_text("JNI-Call: CallObjectMethodV");
- utf_display(methodID->name);
- utf_display(methodID->descriptor);
- printf("\nParmaeter count: %d\n",argcount);
- utf_display(obj->vftbl->class->name);
- printf("\n");
-*/
- if (methodID == 0) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
+ return;
+ }
+ }
}
- argcount = methodID->parseddesc->paramcount;
-
- if (!( ((methodID->flags & ACC_STATIC) && (obj == 0)) ||
- ((!(methodID->flags & ACC_STATIC)) && (obj!=0)) )) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+ /* this should not happen */
- if (obj && !builtin_instanceof(obj,methodID->class)) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return 0;
- }
+/* if (opt_checkjni) */
+/* FatalError(env, "Bad global or local ref passed to JNI"); */
+ log_text("JNI-DeleteLocalRef: Local ref passed to JNI not found");
+}
-#ifdef arglimit
- if (argcount > 3) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- log_text("Too many arguments. CallObjectMethod does not support that");
- return 0;
- }
-#endif
- blk = MNEW(jni_callblock,/* 4 */argcount+2);
+/* IsSameObject ****************************************************************
- fill_callblock(obj, methodID->parseddesc, blk, args, TYPE_LNG);
+ Tests whether two references refer to the same Java object.
- /* printf("parameter: obj: %p",blk[0].item); */
- STATS(jnicallXmethodnvokation();)
- ret = asm_calljavafunction2long(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
+*******************************************************************************/
- MFREE(blk, jni_callblock, argcount + 1);
- /* printf("(CallObjectMethodV)-->%p\n",ret); */
+jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
+{
+ STATISTICS(jniinvokation());
- return ret;
+ if (ref1 == ref2)
+ return JNI_TRUE;
+ else
+ return JNI_FALSE;
}
-/*core function for float class methods (float,double)*/
-static jdouble callFloatMethod(jobject obj, jmethodID methodID, va_list args,int retType)
-{
- int argcount = methodID->parseddesc->paramcount;
- jni_callblock *blk;
- jdouble ret;
+/* NewLocalRef *****************************************************************
- STATS(jniinvokation();)
+ Creates a new local reference that refers to the same object as ref.
- /*
- log_text("JNI-Call: CallObjectMethodV");
- utf_display(methodID->name);
- utf_display(methodID->descriptor);
- printf("\nParmaeter count: %d\n",argcount);
- utf_display(obj->vftbl->class->name);
- printf("\n");
- */
+*******************************************************************************/
-#ifdef arglimit
- if (argcount > 3) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- log_text("Too many arguments. CallObjectMethod does not support that");
- return 0;
- }
-#endif
+jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref)
+{
+ localref_table *lrt;
+ s4 i;
- blk = MNEW(jni_callblock, /*4 */ argcount+2);
+ STATISTICS(jniinvokation());
- fill_callblock(obj, methodID->parseddesc, blk, args, retType);
+ if (ref == NULL)
+ return NULL;
- /* printf("parameter: obj: %p",blk[0].item); */
- STATS(jnicallXmethodnvokation();)
- ret = asm_calljavafunction2double(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
+ /* get local reference table (thread specific) */
- MFREE(blk, jni_callblock, argcount + 1);
- /* printf("(CallObjectMethodV)-->%p\n",ret); */
+ lrt = LOCALREFTABLE;
- return ret;
-}
+ /* Check if we have space for the requested reference? No,
+ allocate a new frame. This is actually not what the spec says,
+ but for compatibility reasons... */
+ if (lrt->used == lrt->capacity) {
+ if (_Jv_JNI_EnsureLocalCapacity(env, 16) != 0)
+ return NULL;
-/*************************** function: jclass_findfield ****************************
-
- searches for field with specified name and type in a 'classinfo'-structur
- if no such field is found NULL is returned
+ /* get the new local reference table */
-************************************************************************************/
+ lrt = LOCALREFTABLE;
+ }
-static fieldinfo *jclass_findfield (classinfo *c, utf *name, utf *desc)
-{
- s4 i;
- STATS(jniinvokation();)
-
-/* printf(" FieldCount: %d\n",c->fieldscount);
- utf_display(c->name); */
- for (i = 0; i < c->fieldscount; i++) {
-/* utf_display(c->fields[i].name);
- printf("\n");
- utf_display(c->fields[i].descriptor);
- printf("\n");*/
- if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc))
- return &(c->fields[i]);
+ /* insert the reference */
+
+ for (i = 0; i < lrt->capacity; i++) {
+ if (lrt->refs[i] == NULL) {
+ lrt->refs[i] = (java_objectheader *) ref;
+ lrt->used++;
+
+ return ref;
}
+ }
- if (c->super.cls) return jclass_findfield(c->super.cls,name,desc);
+ /* should not happen, just to be sure */
+
+ assert(0);
+
+ /* keep compiler happy */
return NULL;
}
-/* GetVersion ******************************************************************
+/* EnsureLocalCapacity *********************************************************
- Returns the major version number in the higher 16 bits and the
- minor version number in the lower 16 bits.
+ Ensures that at least a given number of local references can be
+ created in the current thread
*******************************************************************************/
-jint GetVersion(JNIEnv *env)
+jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
{
- /* GNU classpath currently supports JNI 1.2 */
- STATS(jniinvokation();)
- return JNI_VERSION_1_2;
-}
-
+ localref_table *lrt;
-/* Class Operations ***********************************************************/
-
-/* DefineClass *****************************************************************
+ STATISTICS(jniinvokation());
- Loads a class from a buffer of raw class data. The buffer
- containing the raw class data is not referenced by the VM after the
- DefineClass call returns, and it may be discarded if desired.
+ /* get local reference table (thread specific) */
-*******************************************************************************/
+ lrt = LOCALREFTABLE;
-jclass DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize bufLen)
-{
- jclass c;
- STATS(jniinvokation();)
+ /* check if capacity elements are available in the local references table */
- c = (jclass) Java_java_lang_VMClassLoader_defineClass(env,
- NULL,
- (java_lang_ClassLoader *) loader,
- javastring_new_char(name),
- (java_bytearray *) buf,
- 0,
- bufLen,
- NULL);
+ if ((lrt->used + capacity) > lrt->capacity)
+ return _Jv_JNI_PushLocalFrame(env, capacity);
- return c;
+ return 0;
}
-/* FindClass *******************************************************************
+/* AllocObject *****************************************************************
- This function loads a locally-defined class. It searches the
- directories and zip files specified by the CLASSPATH environment
- variable for the class with the specified name.
+ Allocates a new Java object without invoking any of the
+ constructors for the object. Returns a reference to the object.
*******************************************************************************/
-jclass FindClass(JNIEnv *env, const char *name)
+jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
{
- classinfo *c = NULL;
- STATS(jniinvokation();)
-
- if (!load_class_bootstrap(utf_new_char_classname((char *) name),&c) || !link_class(c)) {
+ classinfo *c;
+ java_objectheader *o;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+
+ if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
+ exceptions_throw_instantiationexception(c);
return NULL;
}
+
+ o = builtin_new(c);
- use_class_as_object(c);
-
- return c;
+ return _Jv_JNI_NewLocalRef(env, o);
}
-
-/*******************************************************************************
- converts java.lang.reflect.Method or
- java.lang.reflect.Constructor object to a method ID
-
+/* NewObject *******************************************************************
+
+ Programmers place all arguments that are to be passed to the
+ constructor immediately following the methodID
+ argument. NewObject() accepts these arguments and passes them to
+ the Java method that the programmer wishes to invoke.
+
*******************************************************************************/
-
-jmethodID FromReflectedMethod(JNIEnv* env, jobject method_or_constr)
+
+jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- struct methodinfo *mi;
- classinfo *c;
- s4 slot;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+
+ STATISTICS(jniinvokation());
- STATS(jniinvokation();)
+ m = (methodinfo *) methodID;
+
+ /* create object */
- if (method_or_constr==0) return 0;
+ o = builtin_new(clazz);
- if (builtin_instanceof(method_or_constr, class_java_lang_reflect_Method))
- {
- java_lang_reflect_Method *rm=(java_lang_reflect_Method*) method_or_constr;
- slot=rm->slot;
- c= (classinfo *) (rm->declaringClass);
- }
- else if (builtin_instanceof(method_or_constr, class_java_lang_reflect_Constructor))
- {
- java_lang_reflect_Constructor *rc=(java_lang_reflect_Constructor*) method_or_constr;
- slot=rc->slot;
- c= (classinfo*) (rc->clazz);
- }
- else return 0;
+ if (o == NULL)
+ return NULL;
+
+ /* call constructor */
+ va_start(ap, methodID);
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- printf ("slot %d,methodscount %d\n",slot,c->methodscount);
- if ((slot < 0) || (slot >= c->methodscount)) {
- /*this usually means a severe internal cacao error or somebody
- tempered around with the reflected method*/
- panic("error illegal slot for method in class(FromReflectedMethod)");
- }
- mi = &(c->methods[slot]);
- return mi;
+ return _Jv_JNI_NewLocalRef(env, o);
}
-/* GetSuperclass ***************************************************************
+/* NewObjectV ******************************************************************
- If clazz represents any class other than the class Object, then
- this function returns the object that represents the superclass of
- the class specified by clazz.
+ Programmers place all arguments that are to be passed to the
+ constructor in an args argument of type va_list that immediately
+ follows the methodID argument. NewObjectV() accepts these
+ arguments, and, in turn, passes them to the Java method that the
+ programmer wishes to invoke.
*******************************************************************************/
-
-jclass GetSuperclass(JNIEnv *env, jclass sub)
+
+jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
+ va_list args)
{
- classinfo *c;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
- c = ((classinfo *) sub)->super.cls;
+ STATISTICS(jniinvokation());
- if (!c)
- return NULL;
+ m = (methodinfo *) methodID;
- use_class_as_object(c);
+ /* create object */
- return c;
-}
-
-
-/* IsAssignableFrom ************************************************************
+ o = builtin_new(clazz);
+
+ if (o == NULL)
+ return NULL;
- Determines whether an object of sub can be safely cast to sup.
+ /* call constructor */
-*******************************************************************************/
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
-jboolean IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup)
-{
- STATS(jniinvokation();)
- return Java_java_lang_VMClass_isAssignableFrom(env,
- NULL,
- (java_lang_Class *) sup,
- (java_lang_Class *) sub);
+ return _Jv_JNI_NewLocalRef(env, o);
}
-/***** converts a field ID derived from cls to a java.lang.reflect.Field object ***/
+/* NewObjectA *****************************************************************
+
+ Programmers place all arguments that are to be passed to the
+ constructor in an args array of jvalues that immediately follows
+ the methodID argument. NewObjectA() accepts the arguments in this
+ array, and, in turn, passes them to the Java method that the
+ programmer wishes to invoke.
+
+*******************************************************************************/
-jobject ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic)
+jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
+ jvalue *args)
{
- log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!!!");
- STATS(jniinvokation();)
- return NULL;
-}
+ java_objectheader *o;
+ methodinfo *m;
+ STATISTICS(jniinvokation());
-/* Throw ***********************************************************************
+ m = (methodinfo *) methodID;
- Causes a java.lang.Throwable object to be thrown.
+ /* create object */
-*******************************************************************************/
+ o = builtin_new(clazz);
+
+ if (o == NULL)
+ return NULL;
-jint Throw(JNIEnv *env, jthrowable obj)
-{
- *exceptionptr = (java_objectheader *) obj;
- STATS(jniinvokation();)
+ /* call constructor */
- return JNI_OK;
+ _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
+
+ return _Jv_JNI_NewLocalRef(env, o);
}
-/* ThrowNew ********************************************************************
+/* GetObjectClass **************************************************************
- Constructs an exception object from the specified class with the
- message specified by message and causes that exception to be
- thrown.
+ Returns the class of an object.
*******************************************************************************/
-jint ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
+jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
{
- java_lang_Throwable *o;
- java_lang_String *s;
- STATS(jniinvokation();)
-
- s = (java_lang_String *) javastring_new_char(msg);
+ java_objectheader *o;
+ classinfo *c;
- /* instantiate exception object */
+ STATISTICS(jniinvokation());
- o = (java_lang_Throwable *) native_new_and_init_string((classinfo *) clazz,
- s);
+ o = (java_objectheader *) obj;
- if (!o)
- return -1;
+ if ((o == NULL) || (o->vftbl == NULL))
+ return NULL;
- *exceptionptr = (java_objectheader *) o;
+ c = o->vftbl->class;
- return 0;
+ return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
}
-/* ExceptionOccurred ***********************************************************
+/* IsInstanceOf ****************************************************************
- Determines if an exception is being thrown. The exception stays
- being thrown until either the native code calls ExceptionClear(),
- or the Java code handles the exception.
+ Tests whether an object is an instance of a class.
*******************************************************************************/
-jthrowable ExceptionOccurred(JNIEnv *env)
+jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
{
- STATS(jniinvokation();)
- return (jthrowable) *exceptionptr;
+ java_lang_Class *c;
+ java_lang_Object *o;
+
+ STATISTICS(jniinvokation());
+
+ c = (java_lang_Class *) clazz;
+ o = (java_lang_Object *) obj;
+
+ return _Jv_java_lang_Class_isInstance(c, o);
}
-/* ExceptionDescribe ***********************************************************
+/* Reflection Support *********************************************************/
- Prints an exception and a backtrace of the stack to a system
- error-reporting channel, such as stderr. This is a convenience
- routine provided for debugging.
+/* FromReflectedMethod *********************************************************
+ Converts java.lang.reflect.Method or java.lang.reflect.Constructor
+ object to a method ID.
+
*******************************************************************************/
-
-void ExceptionDescribe(JNIEnv *env)
+
+jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
{
- java_objectheader *e;
- methodinfo *m;
- STATS(jniinvokation();)
+#if defined(ENABLE_JAVASE)
+ methodinfo *mi;
+ classinfo *c;
+ s4 slot;
- e = *exceptionptr;
+ STATISTICS(jniinvokation());
- if (e) {
- /* clear exception, because we are calling jit code again */
+ if (method == NULL)
+ return NULL;
+
+ if (builtin_instanceof(method, class_java_lang_reflect_Method)) {
+ java_lang_reflect_Method *rm;
- *exceptionptr = NULL;
+ rm = (java_lang_reflect_Method *) method;
+ c = (classinfo *) (rm->declaringClass);
+ slot = rm->slot;
+ }
+ else if (builtin_instanceof(method, class_java_lang_reflect_Constructor)) {
+ java_lang_reflect_Constructor *rc;
- /* get printStackTrace method from exception class */
+ rc = (java_lang_reflect_Constructor *) method;
+ c = (classinfo *) (rc->clazz);
+ slot = rc->slot;
+ }
+ else
+ return NULL;
- m = class_resolveclassmethod(e->vftbl->class,
- utf_printStackTrace,
- utf_void__void,
- NULL,
- true);
+ mi = &(c->methods[slot]);
- if (!m)
- /* XXX what should we do? */
- return;
+ return (jmethodID) mi;
+#else
+ vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
- /* print the stacktrace */
+ /* keep compiler happy */
- asm_calljavafunction(m, e, NULL, NULL, NULL);
- }
+ return NULL;
+#endif
}
-/* ExceptionClear **************************************************************
+/* FromReflectedField **********************************************************
- Clears any exception that is currently being thrown. If no
- exception is currently being thrown, this routine has no effect.
+ Converts a java.lang.reflect.Field to a field ID.
*******************************************************************************/
-
-void ExceptionClear(JNIEnv *env)
+
+jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
{
- STATS(jniinvokation();)
- *exceptionptr = NULL;
-}
+#if defined(ENABLE_JAVASE)
+ java_lang_reflect_Field *rf;
+ classinfo *c;
+ fieldinfo *f;
+ STATISTICS(jniinvokation());
-/* FatalError ******************************************************************
-
- Raises a fatal error and does not expect the VM to recover. This
- function does not return.
+ rf = (java_lang_reflect_Field *) field;
-*******************************************************************************/
+ if (rf == NULL)
+ return NULL;
-void FatalError(JNIEnv *env, const char *msg)
-{
- STATS(jniinvokation();)
- throw_cacao_exception_exit(string_java_lang_InternalError, msg);
-}
+ c = (classinfo *) rf->declaringClass;
+ f = &(c->fields[rf->slot]);
-/******************* creates a new local reference frame **************************/
+ return (jfieldID) f;
+#else
+ vm_abort("_Jv_JNI_FromReflectedField: not implemented in this configuration");
-jint PushLocalFrame(JNIEnv* env, jint capacity)
-{
- log_text("JNI-Call: PushLocalFrame: IMPLEMENT ME!");
- STATS(jniinvokation();)
+ /* keep compiler happy */
- return 0;
+ return NULL;
+#endif
}
-/**************** Pops off the current local reference frame **********************/
-jobject PopLocalFrame(JNIEnv* env, jobject result)
+/* ToReflectedMethod ***********************************************************
+
+ Converts a method ID derived from cls to an instance of the
+ java.lang.reflect.Method class or to an instance of the
+ java.lang.reflect.Constructor class.
+
+*******************************************************************************/
+
+jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID,
+ jboolean isStatic)
{
- log_text("JNI-Call: PopLocalFrame: IMPLEMENT ME!");
- STATS(jniinvokation();)
+ STATISTICS(jniinvokation());
+
+ log_text("JNI-Call: ToReflectedMethod: IMPLEMENT ME!");
return NULL;
}
-/* DeleteLocalRef **************************************************************
+/* ToReflectedField ************************************************************
- Deletes the local reference pointed to by localRef.
+ Converts a field ID derived from cls to an instance of the
+ java.lang.reflect.Field class.
*******************************************************************************/
-void DeleteLocalRef(JNIEnv *env, jobject localRef)
+jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID,
+ jboolean isStatic)
{
- log_text("JNI-Call: DeleteLocalRef: IMPLEMENT ME!");
- STATS(jniinvokation();)
+ STATISTICS(jniinvokation());
+ log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!");
+
+ return NULL;
}
-/* IsSameObject ****************************************************************
+/* Calling Instance Methods ***************************************************/
- Tests whether two references refer to the same Java object.
+/* GetMethodID *****************************************************************
+
+ Returns the method ID for an instance (nonstatic) method of a class
+ or interface. The method may be defined in one of the clazz's
+ superclasses and inherited by clazz. The method is determined by
+ its name and signature.
+
+ GetMethodID() causes an uninitialized class to be initialized.
*******************************************************************************/
-jboolean IsSameObject(JNIEnv *env, jobject ref1, jobject ref2)
+jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
+ const char *sig)
{
- STATS(jniinvokation();)
- return (ref1 == ref2);
-}
+ classinfo *c;
+ utf *uname;
+ utf *udesc;
+ methodinfo *m;
+ STATISTICS(jniinvokation());
-/* NewLocalRef *****************************************************************
+ c = (classinfo *) clazz;
- Creates a new local reference that refers to the same object as ref.
+ if (!c)
+ return NULL;
-*******************************************************************************/
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return NULL;
+
+ /* try to get the method of the class or one of it's superclasses */
+
+ uname = utf_new_char((char *) name);
+ udesc = utf_new_char((char *) sig);
+
+ m = class_resolvemethod(clazz, uname, udesc);
+
+ if ((m == NULL) || (m->flags & ACC_STATIC)) {
+ exceptions_throw_nosuchmethoderror(c, uname, udesc);
+
+ return NULL;
+ }
-jobject NewLocalRef(JNIEnv *env, jobject ref)
-{
- log_text("JNI-Call: NewLocalRef: IMPLEMENT ME!");
- STATS(jniinvokation();)
- return ref;
+ return (jmethodID) m;
}
-/***********************************************************************************
-
- Ensures that at least a given number of local references can
- be created in the current thread
- **********************************************************************************/
+/* JNI-functions for calling instance methods *********************************/
-jint EnsureLocalCapacity (JNIEnv* env, jint capacity)
+jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
+ ...)
{
- STATS(jniinvokation();)
- return 0; /* return 0 on success */
-}
+ java_objectheader *o;
+ methodinfo *m;
+ java_objectheader *ret;
+ va_list ap;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
-/* AllocObject *****************************************************************
+ va_start(ap, methodID);
+ ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- Allocates a new Java object without invoking any of the
- constructors for the object. Returns a reference to the object.
+ return _Jv_JNI_NewLocalRef(env, ret);
+}
-*******************************************************************************/
-jobject AllocObject(JNIEnv *env, jclass clazz)
+jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
java_objectheader *o;
- STATS(jniinvokation();)
+ methodinfo *m;
+ java_objectheader *ret;
- if ((clazz->flags & ACC_INTERFACE) || (clazz->flags & ACC_ABSTRACT)) {
- *exceptionptr =
- new_exception_utfmessage(string_java_lang_InstantiationException,
- clazz->name);
- return NULL;
- }
-
- o = builtin_new(clazz);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args);
- return o;
+ return _Jv_JNI_NewLocalRef(env, ret);
}
-/* NewObject *******************************************************************
+jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
+{
+ java_objectheader *o;
+ methodinfo *m;
+ java_objectheader *ret;
- Constructs a new Java object. The method ID indicates which
- constructor method to invoke. This ID must be obtained by calling
- GetMethodID() with <init> as the method name and void (V) as the
- return type.
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ ret = _Jv_jni_CallObjectMethodA(o, o->vftbl, m, args);
+
+ return _Jv_JNI_NewLocalRef(env, ret);
+}
-*******************************************************************************/
-jobject NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jboolean _Jv_JNI_CallBooleanMethod(JNIEnv *env, jobject obj, jmethodID methodID,
+ ...)
{
java_objectheader *o;
- void* args[3];
- int argcount=methodID->parseddesc->paramcount;
- int i;
- va_list vaargs;
- STATS(jniinvokation();)
-
-#ifdef arglimit
- if (argcount > 3) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- log_text("Too many arguments. NewObject does not support that");
- return 0;
- }
-#endif
-
- /* create object */
+ methodinfo *m;
+ va_list ap;
+ jboolean b;
- o = builtin_new(clazz);
-
- if (!o)
- return NULL;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- for (i = 0; i < argcount; i++) {
- args[i] = va_arg(vaargs, void*);
- }
- va_end(vaargs);
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- /* call constructor */
+ return b;
+}
- asm_calljavafunction(methodID, o, args[0], args[1], args[2]);
- return o;
-}
+jboolean _Jv_JNI_CallBooleanMethodV(JNIEnv *env, jobject obj,
+ jmethodID methodID, va_list args)
+{
+ java_objectheader *o;
+ methodinfo *m;
+ jboolean b;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
-/***********************************************************************************
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
- Constructs a new Java object
- arguments that are to be passed to the constructor are placed in va_list args
+ return b;
+}
-***********************************************************************************/
-jobject NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args)
+jboolean _Jv_JNI_CallBooleanMethodA(JNIEnv *env, jobject obj,
+ jmethodID methodID, jvalue *args)
{
- log_text("JNI-Call: NewObjectV");
- STATS(jniinvokation();)
-
- return NULL;
-}
+ java_objectheader *o;
+ methodinfo *m;
+ jboolean b;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
-/***********************************************************************************
+ b = _Jv_jni_CallIntMethodA(o, o->vftbl, m, args);
- Constructs a new Java object
- arguments that are to be passed to the constructor are placed in
- args array of jvalues
+ return b;
+}
-***********************************************************************************/
-jobject NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, jvalue *args)
+jbyte _Jv_JNI_CallByteMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- log_text("JNI-Call: NewObjectA");
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jbyte b;
- return NULL;
-}
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
+ va_end(ap);
-/* GetObjectClass **************************************************************
+ return b;
- Returns the class of an object.
+}
-*******************************************************************************/
-jclass GetObjectClass(JNIEnv *env, jobject obj)
+jbyte _Jv_JNI_CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- classinfo *c;
- STATS(jniinvokation();)
-
- if (!obj || !obj->vftbl)
- return NULL;
-
- c = obj->vftbl->class;
- use_class_as_object(c);
- return c;
-}
+ java_objectheader *o;
+ methodinfo *m;
+ jbyte b;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
-/* IsInstanceOf ****************************************************************
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
- Tests whether an object is an instance of a class.
+ return b;
+}
-*******************************************************************************/
-jboolean IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
+jbyte _Jv_JNI_CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
+ log_text("JNI-Call: CallByteMethodA: IMPLEMENT ME!");
- return Java_java_lang_VMClass_isInstance(env,
- NULL,
- (java_lang_Class *) clazz,
- (java_lang_Object *) obj);
+ return 0;
}
-/***************** converts a java.lang.reflect.Field to a field ID ***************/
-
-jfieldID FromReflectedField(JNIEnv* env, jobject field)
+jchar _Jv_JNI_CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- java_lang_reflect_Field *f;
- classinfo *c;
- jfieldID fid; /* the JNI-fieldid of the wrapping object */
- STATS(jniinvokation();)
- /*log_text("JNI-Call: FromReflectedField");*/
-
- f=(java_lang_reflect_Field *)field;
- if (f==0) return 0;
- c=(classinfo*)(f->declaringClass);
- if ( (f->slot<0) || (f->slot>=c->fieldscount)) {
- /*this usually means a severe internal cacao error or somebody
- tempered around with the reflected method*/
- panic("error illegal slot for field in class(FromReflectedField)");
- }
- fid=&(c->fields[f->slot]);
- return fid;
-}
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jchar c;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
-/**********************************************************************************
+ va_start(ap, methodID);
+ c = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- converts a method ID to a java.lang.reflect.Method or
- java.lang.reflect.Constructor object
+ return c;
+}
-**********************************************************************************/
-jobject ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic)
+jchar _Jv_JNI_CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- log_text("JNI-Call: ToReflectedMethod");
- STATS(jniinvokation();)
-
- return NULL;
-}
+ java_objectheader *o;
+ methodinfo *m;
+ jchar c;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
-/* GetMethodID *****************************************************************
+ c = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
- returns the method ID for an instance method
+ return c;
+}
-*******************************************************************************/
-jmethodID GetMethodID(JNIEnv* env, jclass clazz, const char *name, const char *sig)
+jchar _Jv_JNI_CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- jmethodID m;
- STATS(jniinvokation();)
-
- m = class_resolvemethod(clazz,
- utf_new_char((char *) name),
- utf_new_char((char *) sig));
-
- if (!m || (m->flags & ACC_STATIC)) {
- *exceptionptr =
- new_exception_message(string_java_lang_NoSuchMethodError, name);
-
- return 0;
- }
+ log_text("JNI-Call: CallCharMethodA: IMPLEMENT ME!");
- return m;
+ return 0;
}
-/******************** JNI-functions for calling instance methods ******************/
-
-jobject CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+jshort _Jv_JNI_CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID,
+ ...)
{
- jobject ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jshort s;
-/* log_text("JNI-Call: CallObjectMethod");*/
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = callObjectMethod(obj, methodID, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ s = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- return ret;
+ return s;
}
-jobject CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jshort _Jv_JNI_CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- return callObjectMethod(obj,methodID,args);
+ java_objectheader *o;
+ methodinfo *m;
+ jshort s;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ s = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
+
+ return s;
}
-jobject CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+jshort _Jv_JNI_CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- log_text("JNI-Call: CallObjectMethodA");
- STATS(jniinvokation();)
+ log_text("JNI-Call: CallShortMethodA: IMPLEMENT ME!");
- return NULL;
+ return 0;
}
-
-jboolean CallBooleanMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+jint _Jv_JNI_CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- jboolean ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jint i;
-/* log_text("JNI-Call: CallBooleanMethod");*/
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = (jboolean)callIntegerMethod(obj,get_virtual(obj,methodID),PRIMITIVETYPE_BOOLEAN,vaargs);
- va_end(vaargs);
- return ret;
+ va_start(ap, methodID);
+ i = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap);
+ va_end(ap);
+ return i;
}
-jboolean CallBooleanMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+
+jint _Jv_JNI_CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ jint i;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return (jboolean)callIntegerMethod(obj,get_virtual(obj,methodID),PRIMITIVETYPE_BOOLEAN,args);
+ i = _Jv_jni_CallIntMethod(o, o->vftbl, m, args);
+ return i;
}
-jboolean CallBooleanMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+
+jint _Jv_JNI_CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallBooleanMethodA");
+ log_text("JNI-Call: CallIntMethodA: IMPLEMENT ME!");
return 0;
}
-jbyte CallByteMethod (JNIEnv *env, jobject obj, jmethodID methodID, ...)
+
+
+jlong _Jv_JNI_CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- jbyte ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jlong l;
-/* log_text("JNI-Call: CallVyteMethod");*/
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj,get_virtual(obj,methodID),PRIMITIVETYPE_BYTE,vaargs);
- va_end(vaargs);
- return ret;
+ va_start(ap, methodID);
+ l = _Jv_jni_CallLongMethod(o, o->vftbl, m, ap);
+ va_end(ap);
+ return l;
}
-jbyte CallByteMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+
+jlong _Jv_JNI_CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
-/* log_text("JNI-Call: CallByteMethodV");*/
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ jlong l;
- return callIntegerMethod(obj,methodID,PRIMITIVETYPE_BYTE,args);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ l = _Jv_jni_CallLongMethod(o, o->vftbl, m, args);
+
+ return l;
}
-jbyte CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+jlong _Jv_JNI_CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- log_text("JNI-Call: CallByteMethodA");
- STATS(jniinvokation();)
+ log_text("JNI-Call: CallLongMethodA: IMPLEMENT ME!");
return 0;
}
-jchar CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+
+jfloat _Jv_JNI_CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID,
+ ...)
{
- jchar ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jfloat f;
-/* log_text("JNI-Call: CallCharMethod");*/
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj, get_virtual(obj, methodID),PRIMITIVETYPE_CHAR, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- return ret;
+ return f;
}
-jchar CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jfloat _Jv_JNI_CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ jfloat f;
-/* log_text("JNI-Call: CallCharMethodV");*/
- return callIntegerMethod(obj,get_virtual(obj,methodID),PRIMITIVETYPE_CHAR,args);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, args);
+
+ return f;
}
-jchar CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+jfloat _Jv_JNI_CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
-
- log_text("JNI-Call: CallCharMethodA");
+ log_text("JNI-Call: CallFloatMethodA: IMPLEMENT ME!");
return 0;
}
-jshort CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+
+jdouble _Jv_JNI_CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID,
+ ...)
{
- jshort ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jdouble d;
-/* log_text("JNI-Call: CallShortMethod");*/
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = callIntegerMethod(obj, get_virtual(obj, methodID),PRIMITIVETYPE_SHORT, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, ap);
+ va_end(ap);
- return ret;
+ return d;
}
-jshort CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jdouble _Jv_JNI_CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- return callIntegerMethod(obj, get_virtual(obj, methodID),PRIMITIVETYPE_SHORT, args);
+ java_objectheader *o;
+ methodinfo *m;
+ jdouble d;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, args);
+
+ return d;
}
-jshort CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+jdouble _Jv_JNI_CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallShortMethodA");
+ log_text("JNI-Call: CallDoubleMethodA: IMPLEMENT ME!");
return 0;
}
-jint CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- jint ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj, get_virtual(obj, methodID),PRIMITIVETYPE_INT, vaargs);
- va_end(vaargs);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ va_start(ap, methodID);
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
+ va_end(ap);
}
-jint CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- return callIntegerMethod(obj, get_virtual(obj, methodID),PRIMITIVETYPE_INT, args);
+ java_objectheader *o;
+ methodinfo *m;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
}
-jint CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallIntMethodA");
+ java_objectheader *o;
+ methodinfo *m;
- return 0;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
}
-jlong CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ ...)
{
- jlong ret;
- va_list vaargs;
- STATS(jniinvokation();)
-
- va_start(vaargs,methodID);
- ret = callLongMethod(obj,get_virtual(obj, methodID),vaargs);
- va_end(vaargs);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ java_objectheader *r;
+ va_list ap;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return ret;
+ va_start(ap, methodID);
+ r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
+ va_end(ap);
+
+ return _Jv_JNI_NewLocalRef(env, r);
}
-jlong CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- return callLongMethod(obj,get_virtual(obj, methodID),args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ java_objectheader *r;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
+
+ return _Jv_JNI_NewLocalRef(env, r);
}
-jlong CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallLongMethodA");
+ log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
- return 0;
+ return _Jv_JNI_NewLocalRef(env, NULL);
}
-jfloat CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+jboolean _Jv_JNI_CallNonvirtualBooleanMethod(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ ...)
{
- jfloat ret;
- va_list vaargs;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jboolean b;
- STATS(jniinvokation();)
-/* log_text("JNI-Call: CallFloatMethod");*/
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callFloatMethod(obj, get_virtual(obj, methodID), vaargs, PRIMITIVETYPE_FLOAT);
- va_end(vaargs);
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
+ va_end(ap);
- return ret;
+ return b;
}
-jfloat CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jboolean _Jv_JNI_CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallFloatMethodV");
- return callFloatMethod(obj, get_virtual(obj, methodID), args, PRIMITIVETYPE_FLOAT);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jboolean b;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
+
+ return b;
}
-jfloat CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+jboolean _Jv_JNI_CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallFloatMethodA");
+ log_text("JNI-Call: CallNonvirtualBooleanMethodA: IMPLEMENT ME!");
return 0;
}
-
-jdouble CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+jbyte _Jv_JNI_CallNonvirtualByteMethod(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, ...)
{
- jdouble ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jbyte b;
-/* log_text("JNI-Call: CallDoubleMethod");*/
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callFloatMethod(obj, get_virtual(obj, methodID), vaargs, PRIMITIVETYPE_DOUBLE);
- va_end(vaargs);
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
+ va_end(ap);
- return ret;
+ return b;
}
-jdouble CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jbyte _Jv_JNI_CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallDoubleMethodV");
- return callFloatMethod(obj, get_virtual(obj, methodID), args, PRIMITIVETYPE_DOUBLE);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jbyte b;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
+
+ return b;
}
-jdouble CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID, jvalue *args)
+jbyte _Jv_JNI_CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallDoubleMethodA");
+ log_text("JNI-Call: CallNonvirtualByteMethodA: IMPLEMENT ME!");
+
return 0;
}
-void CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
+jchar _Jv_JNI_CallNonvirtualCharMethod(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, ...)
{
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jchar ch;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- (void) callIntegerMethod(obj, get_virtual(obj, methodID),TYPE_VOID, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
+ va_end(ap);
+
+ return ch;
}
-void CallVoidMethodV (JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
+jchar _Jv_JNI_CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, va_list args)
{
- log_text("JNI-Call: CallVoidMethodV");
- STATS(jniinvokation();)
- (void)callIntegerMethod(obj,get_virtual(obj,methodID),TYPE_VOID,args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jchar ch;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
+
+ return ch;
}
-void CallVoidMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args)
+jchar _Jv_JNI_CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallVoidMethodA");
+ log_text("JNI-Call: CallNonvirtualCharMethodA: IMPLEMENT ME!");
+
+ return 0;
}
-jobject CallNonvirtualObjectMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jshort _Jv_JNI_CallNonvirtualShortMethod(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID, ...)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualObjectMethod");
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jshort s;
- return NULL;
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ va_start(ap, methodID);
+ s = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
+ va_end(ap);
+
+ return s;
}
-jobject CallNonvirtualObjectMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jshort _Jv_JNI_CallNonvirtualShortMethodV(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualObjectMethodV");
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jshort s;
- return NULL;
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ s = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
+
+ return s;
}
-jobject CallNonvirtualObjectMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+jshort _Jv_JNI_CallNonvirtualShortMethodA(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualObjectMethodA");
+ log_text("JNI-Call: CallNonvirtualShortMethodA: IMPLEMENT ME!");
- return NULL;
+ return 0;
}
-jboolean CallNonvirtualBooleanMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jint _Jv_JNI_CallNonvirtualIntMethod(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, ...)
{
- jboolean ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jint i;
-/* log_text("JNI-Call: CallNonvirtualBooleanMethod");*/
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = (jboolean)callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_BOOLEAN,vaargs);
- va_end(vaargs);
- return ret;
+ va_start(ap, methodID);
+ i = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap);
+ va_end(ap);
+ return i;
}
-jboolean CallNonvirtualBooleanMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jint _Jv_JNI_CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
-/* log_text("JNI-Call: CallNonvirtualBooleanMethodV");*/
- return (jboolean)callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_BOOLEAN,args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jint i;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ i = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);
+
+ return i;
}
-jboolean CallNonvirtualBooleanMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
+jint _Jv_JNI_CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualBooleanMethodA");
+ log_text("JNI-Call: CallNonvirtualIntMethodA: IMPLEMENT ME!");
return 0;
}
-jbyte CallNonvirtualByteMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jlong _Jv_JNI_CallNonvirtualLongMethod(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, ...)
{
- jbyte ret;
- va_list vaargs;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jlong l;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- STATS(jniinvokation();)
-/* log_text("JNI-Call: CallNonvirutalByteMethod");*/
+ va_start(ap, methodID);
+ l = _Jv_jni_CallLongMethod(o, c->vftbl, m, ap);
+ va_end(ap);
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_BYTE,vaargs);
- va_end(vaargs);
- return ret;
+ return l;
}
-jbyte CallNonvirtualByteMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jlong _Jv_JNI_CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- /*log_text("JNI-Call: CallNonvirtualByteMethodV"); */
- return callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_BYTE,args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jlong l;
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ l = _Jv_jni_CallLongMethod(o, c->vftbl, m, args);
+
+ return l;
}
-jbyte CallNonvirtualByteMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+jlong _Jv_JNI_CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualByteMethodA");
+ log_text("JNI-Call: CallNonvirtualLongMethodA: IMPLEMENT ME!");
return 0;
}
-jchar CallNonvirtualCharMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jfloat _Jv_JNI_CallNonvirtualFloatMethod(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID, ...)
{
- jchar ret;
- va_list vaargs;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jfloat f;
- STATS(jniinvokation();)
-/* log_text("JNI-Call: CallNonVirtualCharMethod");*/
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_CHAR,vaargs);
- va_end(vaargs);
- return ret;
+ va_start(ap, methodID);
+ f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, ap);
+ va_end(ap);
+
+ return f;
}
-jchar CallNonvirtualCharMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jfloat _Jv_JNI_CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- /*log_text("JNI-Call: CallNonvirtualCharMethodV");*/
- return callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_CHAR,args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jfloat f;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, args);
+
+ return f;
}
-jchar CallNonvirtualCharMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+jfloat _Jv_JNI_CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualCharMethodA");
+ log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!");
return 0;
}
-jshort CallNonvirtualShortMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jdouble _Jv_JNI_CallNonvirtualDoubleMethod(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ ...)
{
- jshort ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jdouble d;
- /*log_text("JNI-Call: CallNonvirtualShortMethod");*/
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_SHORT,vaargs);
- va_end(vaargs);
- return ret;
+ va_start(ap, methodID);
+ d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, ap);
+ va_end(ap);
+
+ return d;
}
-jshort CallNonvirtualShortMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jdouble _Jv_JNI_CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ va_list args)
{
- STATS(jniinvokation();)
- /*log_text("JNI-Call: CallNonvirtualShortMethodV");*/
- return callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_SHORT,args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jdouble d;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, args);
+
+ return d;
}
-jshort CallNonvirtualShortMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
+jdouble _Jv_JNI_CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj,
+ jclass clazz, jmethodID methodID,
+ jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualShortMethodA");
+ log_text("JNI-Call: CallNonvirtualDoubleMethodA: IMPLEMENT ME!");
return 0;
}
-jint CallNonvirtualIntMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, ...)
{
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
- jint ret;
- va_list vaargs;
- STATS(jniinvokation();)
-
- /*log_text("JNI-Call: CallNonvirtualIntMethod");*/
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_INT,vaargs);
- va_end(vaargs);
- return ret;
+ va_start(ap, methodID);
+ _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
+ va_end(ap);
}
-jint CallNonvirtualIntMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- /*log_text("JNI-Call: CallNonvirtualIntMethodV");*/
- return callIntegerMethod(obj,get_nonvirtual(clazz,methodID),PRIMITIVETYPE_INT,args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
}
-jint CallNonvirtualIntMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualIntMethodA");
+void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
+ jmethodID methodID, jvalue * args)
+{
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
- return 0;
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
}
+/* Accessing Fields of Objects ************************************************/
-jlong CallNonvirtualLongMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualLongMethod");
+/* GetFieldID ******************************************************************
- return 0;
-}
+ Returns the field ID for an instance (nonstatic) field of a
+ class. The field is specified by its name and signature. The
+ Get<type>Field and Set<type>Field families of accessor functions
+ use field IDs to retrieve object fields.
+*******************************************************************************/
-jlong CallNonvirtualLongMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
+ const char *sig)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualLongMethodV");
+ classinfo *c;
+ fieldinfo *f;
+ utf *uname;
+ utf *udesc;
- return 0;
-}
+ STATISTICS(jniinvokation());
+ c = (classinfo *) clazz;
-jlong CallNonvirtualLongMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualLongMethodA");
+ uname = utf_new_char((char *) name);
+ udesc = utf_new_char((char *) sig);
- return 0;
+ f = class_findfield(clazz, uname, udesc);
+
+ if (f == NULL)
+ exceptions_throw_nosuchfielderror(c, uname);
+
+ return (jfieldID) f;
}
+/* Get<type>Field Routines *****************************************************
-jfloat CallNonvirtualFloatMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
-{
- jfloat ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ This family of accessor routines returns the value of an instance
+ (nonstatic) field of an object. The field to access is specified by
+ a field ID obtained by calling GetFieldID().
+
+*******************************************************************************/
- /*log_text("JNI-Call: CallNonvirtualFloatMethod");*/
+jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
+{
+ java_objectheader *o;
+ STATISTICS(jniinvokation());
- va_start(vaargs,methodID);
- ret = callFloatMethod(obj,get_nonvirtual(clazz,methodID),vaargs,PRIMITIVETYPE_FLOAT);
- va_end(vaargs);
- return ret;
+ o = GET_FIELD(obj, java_objectheader*, fieldID);
+ return _Jv_JNI_NewLocalRef(env, o);
}
-jfloat CallNonvirtualFloatMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jboolean _Jv_JNI_GetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualFloatMethodV");
- return callFloatMethod(obj,get_nonvirtual(clazz,methodID),args,PRIMITIVETYPE_FLOAT);
-}
+ s4 i;
+ STATISTICS(jniinvokation());
-jfloat CallNonvirtualFloatMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualFloatMethodA");
+ i = GET_FIELD(obj, s4, fieldID);
- return 0;
+ return (jboolean) i;
}
-
-jdouble CallNonvirtualDoubleMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jbyte _Jv_JNI_GetByteField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- jdouble ret;
- va_list vaargs;
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualDoubleMethod");
+ s4 i;
+
+ STATISTICS(jniinvokation());
- va_start(vaargs,methodID);
- ret = callFloatMethod(obj,get_nonvirtual(clazz,methodID),vaargs,PRIMITIVETYPE_DOUBLE);
- va_end(vaargs);
- return ret;
+ i = GET_FIELD(obj, s4, fieldID);
+ return (jbyte) i;
}
-jdouble CallNonvirtualDoubleMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jchar _Jv_JNI_GetCharField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- STATS(jniinvokation();)
-/* log_text("JNI-Call: CallNonvirtualDoubleMethodV");*/
- return callFloatMethod(obj,get_nonvirtual(clazz,methodID),args,PRIMITIVETYPE_DOUBLE);
-}
+ s4 i;
+ STATISTICS(jniinvokation());
-jdouble CallNonvirtualDoubleMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualDoubleMethodA");
+ i = GET_FIELD(obj, s4, fieldID);
- return 0;
+ return (jchar) i;
}
-
-void CallNonvirtualVoidMethod (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
+jshort _Jv_JNI_GetShortField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- va_list vaargs;
- STATS(jniinvokation();)
+ s4 i;
-/* log_text("JNI-Call: CallNonvirtualVoidMethod");*/
+ STATISTICS(jniinvokation());
- va_start(vaargs,methodID);
- (void)callIntegerMethod(obj,get_nonvirtual(clazz,methodID),TYPE_VOID,vaargs);
- va_end(vaargs);
+ i = GET_FIELD(obj, s4, fieldID);
+ return (jshort) i;
}
-void CallNonvirtualVoidMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jint _Jv_JNI_GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
-/* log_text("JNI-Call: CallNonvirtualVoidMethodV");*/
- STATS(jniinvokation();)
+ java_objectheader *o;
+ fieldinfo *f;
+ s4 i;
- (void)callIntegerMethod(obj,get_nonvirtual(clazz,methodID),TYPE_VOID,args);
+ STATISTICS(jniinvokation());
-}
+ o = (java_objectheader *) obj;
+ f = (fieldinfo *) fieldID;
+ i = GET_FIELD(o, s4, f);
-void CallNonvirtualVoidMethodA (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue * args)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallNonvirtualVoidMethodA");
+ return i;
}
-/************************* JNI-functions for accessing fields ************************/
-jfieldID GetFieldID (JNIEnv *env, jclass clazz, const char *name, const char *sig)
+jlong _Jv_JNI_GetLongField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- jfieldID f;
- STATS(jniinvokation();)
+ s8 l;
-/* log_text("========================= searching for:");
- log_text(name);
- log_text(sig);*/
- f = jclass_findfield(clazz,
- utf_new_char ((char*) name),
- utf_new_char ((char*) sig)
- );
-
- if (!f) {
- /*utf_display(clazz->name);
- log_text(name);
- log_text(sig);*/
- *exceptionptr = new_exception(string_java_lang_NoSuchFieldError);
- }
- return f;
+ STATISTICS(jniinvokation());
+
+ l = GET_FIELD(obj, s8, fieldID);
+
+ return l;
}
-/*************************** retrieve fieldid, abort on error ************************/
-jfieldID getFieldID_critical(JNIEnv *env, jclass clazz, char *name, char *sig)
+jfloat _Jv_JNI_GetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- jfieldID id = GetFieldID(env, clazz, name, sig);
- STATS(jniinvokation();)
+ float f;
- if (!id) {
- log_text("class:");
- utf_display(clazz->name);
- log_text("\nfield:");
- log_text(name);
- log_text("sig:");
- log_text(sig);
+ STATISTICS(jniinvokation());
- panic("setfield_critical failed");
- }
- return id;
+ f = GET_FIELD(obj, float, fieldID);
+
+ return f;
}
-jobject GetObjectField (JNIEnv *env, jobject obj, jfieldID fieldID)
+
+jdouble _Jv_JNI_GetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- /*
- jobject dbg,dretval,*dpretval;
- long int dli1, dli2, dli3;
+ double d;
- printf("GetObjectField(1): thread: %s obj: %p name: %s desc: %s \n",GetStringUTFChars(env,
- ((threadobject *) THREADOBJECT)->o
- .thread->name,NULL)
- ,obj,((fieldinfo*)fieldID)->name->text,(fieldID->descriptor)->text);
+ STATISTICS(jniinvokation());
- dbg = getField(obj,jobject,fieldID);
- dli1 = (long int) obj;
- dli2 = (long int) fieldID->offset;
- dli3 = dli1+dli2;
- dpretval = (jobject*) dli3;
- dretval = *dpretval;
- jclass tmp;
- jmethodID mid;
- jstring jstr;
+ d = GET_FIELD(obj, double, fieldID);
- tmp = FindClass(env, "java/lang/Object");
- mid = GetMethodID(env,tmp,"toString","()Ljava/lang/String;");
- jstr = CallObjectMethod(env,dbg,mid);*/
+ return d;
+}
-/* printf("GetObjectField(2): retval %p (obj: %#lx + offset: %#lx = %#lx (jobject*) %p (jobject) %p\n"
- ,dbg, dli1, dli2, dli3,dpretval, dretval);*/
+/* Set<type>Field Routines *****************************************************
-/* return dbg;*/
- STATS(jniinvokation();)
+ This family of accessor routines sets the value of an instance
+ (nonstatic) field of an object. The field to access is specified by
+ a field ID obtained by calling GetFieldID().
- return getField(obj,jobject,fieldID);
-}
+*******************************************************************************/
-jboolean GetBooleanField (JNIEnv *env, jobject obj, jfieldID fieldID)
+void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jobject value)
{
- STATS(jniinvokation();)
- return getField(obj,jboolean,fieldID);
-}
-
+ STATISTICS(jniinvokation());
-jbyte GetByteField (JNIEnv *env, jobject obj, jfieldID fieldID)
-{
- STATS(jniinvokation();)
- return getField(obj,jbyte,fieldID);
+ SET_FIELD(obj, java_objectheader*, fieldID, value);
}
-jchar GetCharField (JNIEnv *env, jobject obj, jfieldID fieldID)
+void _Jv_JNI_SetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jboolean value)
{
- STATS(jniinvokation();)
- return getField(obj,jchar,fieldID);
-}
+ STATISTICS(jniinvokation());
-
-jshort GetShortField (JNIEnv *env, jobject obj, jfieldID fieldID)
-{
- STATS(jniinvokation();)
- return getField(obj,jshort,fieldID);
+ SET_FIELD(obj, s4, fieldID, value);
}
-jint GetIntField (JNIEnv *env, jobject obj, jfieldID fieldID)
+void _Jv_JNI_SetByteField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jbyte value)
{
- STATS(jniinvokation();)
- return getField(obj,jint,fieldID);
-}
-
+ STATISTICS(jniinvokation());
-jlong GetLongField (JNIEnv *env, jobject obj, jfieldID fieldID)
-{
- STATS(jniinvokation();)
- return getField(obj,jlong,fieldID);
+ SET_FIELD(obj, s4, fieldID, value);
}
-jfloat GetFloatField (JNIEnv *env, jobject obj, jfieldID fieldID)
+void _Jv_JNI_SetCharField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jchar value)
{
- STATS(jniinvokation();)
- return getField(obj,jfloat,fieldID);
+ STATISTICS(jniinvokation());
+
+ SET_FIELD(obj, s4, fieldID, value);
}
-jdouble GetDoubleField (JNIEnv *env, jobject obj, jfieldID fieldID)
+void _Jv_JNI_SetShortField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jshort value)
{
- STATS(jniinvokation();)
- return getField(obj,jdouble,fieldID);
-}
+ STATISTICS(jniinvokation());
-void SetObjectField (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val)
-{
- STATS(jniinvokation();)
- setField(obj,jobject,fieldID,val);
+ SET_FIELD(obj, s4, fieldID, value);
}
-void SetBooleanField (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val)
+void _Jv_JNI_SetIntField(JNIEnv *env, jobject obj, jfieldID fieldID, jint value)
{
- STATS(jniinvokation();)
- setField(obj,jboolean,fieldID,val);
+ STATISTICS(jniinvokation());
+
+ SET_FIELD(obj, s4, fieldID, value);
}
-void SetByteField (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val)
+void _Jv_JNI_SetLongField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jlong value)
{
- STATS(jniinvokation();)
- setField(obj,jbyte,fieldID,val);
+ STATISTICS(jniinvokation());
+
+ SET_FIELD(obj, s8, fieldID, value);
}
-void SetCharField (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val)
+void _Jv_JNI_SetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jfloat value)
{
- STATS(jniinvokation();)
- setField(obj,jchar,fieldID,val);
+ STATISTICS(jniinvokation());
+
+ SET_FIELD(obj, float, fieldID, value);
}
-void SetShortField (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val)
+void _Jv_JNI_SetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID,
+ jdouble value)
{
- STATS(jniinvokation();)
- setField(obj,jshort,fieldID,val);
+ STATISTICS(jniinvokation());
+
+ SET_FIELD(obj, double, fieldID, value);
}
-void SetIntField (JNIEnv *env, jobject obj, jfieldID fieldID, jint val)
-{
- STATS(jniinvokation();)
- setField(obj,jint,fieldID,val);
-}
+/* Calling Static Methods *****************************************************/
+/* GetStaticMethodID ***********************************************************
-void SetLongField (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val)
-{
- STATS(jniinvokation();)
- setField(obj,jlong,fieldID,val);
-}
+ Returns the method ID for a static method of a class. The method is
+ specified by its name and signature.
+ GetStaticMethodID() causes an uninitialized class to be
+ initialized.
-void SetFloatField (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val)
+*******************************************************************************/
+
+jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
+ const char *sig)
{
- STATS(jniinvokation();)
- setField(obj,jfloat,fieldID,val);
-}
+ classinfo *c;
+ utf *uname;
+ utf *udesc;
+ methodinfo *m;
+ STATISTICS(jniinvokation());
-void SetDoubleField (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val)
-{
- STATS(jniinvokation();)
- setField(obj,jdouble,fieldID,val);
-}
+ c = (classinfo *) clazz;
+ if (!c)
+ return NULL;
-/**************** JNI-functions for calling static methods **********************/
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return NULL;
-jmethodID GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig)
-{
- jmethodID m;
- STATS(jniinvokation();)
+ /* try to get the static method of the class */
- m = class_resolvemethod(clazz,
- utf_new_char((char *) name),
- utf_new_char((char *) sig));
+ uname = utf_new_char((char *) name);
+ udesc = utf_new_char((char *) sig);
- if (!m || !(m->flags & ACC_STATIC)) {
- *exceptionptr =
- new_exception_message(string_java_lang_NoSuchMethodError, name);
+ m = class_resolvemethod(c, uname, udesc);
+
+ if ((m == NULL) || !(m->flags & ACC_STATIC)) {
+ exceptions_throw_nosuchmethoderror(c, uname, udesc);
return NULL;
}
- return m;
+ return (jmethodID) m;
}
-jobject CallStaticObjectMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jobject ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ java_objectheader *o;
+ va_list ap;
- /* log_text("JNI-Call: CallStaticObjectMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = callObjectMethod(0, methodID, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return _Jv_JNI_NewLocalRef(env, o);
}
-jobject CallStaticObjectMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- /* log_text("JNI-Call: CallStaticObjectMethodV"); */
-
- return callObjectMethod(0,methodID,args);
+ methodinfo *m;
+ java_objectheader *o;
+
+ m = (methodinfo *) methodID;
+
+ o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
+
+ return _Jv_JNI_NewLocalRef(env, o);
}
-jobject CallStaticObjectMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticObjectMethodA");
+ methodinfo *m;
+ java_objectheader *o;
- return NULL;
+ m = (methodinfo *) methodID;
+
+ o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
+
+ return _Jv_JNI_NewLocalRef(env, o);
}
-jboolean CallStaticBooleanMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jboolean _Jv_JNI_CallStaticBooleanMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jboolean ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jboolean b;
- va_start(vaargs, methodID);
- ret = (jboolean) callIntegerMethod(0, methodID, PRIMITIVETYPE_BOOLEAN, vaargs);
- va_end(vaargs);
+ m = (methodinfo *) methodID;
- return ret;
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
+ va_end(ap);
+
+ return b;
}
-jboolean CallStaticBooleanMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- return (jboolean) callIntegerMethod(0, methodID, PRIMITIVETYPE_BOOLEAN, args);
+ methodinfo *m;
+ jboolean b;
+
+ m = (methodinfo *) methodID;
+
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
+
+ return b;
}
-jboolean CallStaticBooleanMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticBooleanMethodA");
+ log_text("JNI-Call: CallStaticBooleanMethodA: IMPLEMENT ME!");
return 0;
}
-jbyte CallStaticByteMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jbyte _Jv_JNI_CallStaticByteMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jbyte ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jbyte b;
- /* log_text("JNI-Call: CallStaticByteMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = (jbyte) callIntegerMethod(0, methodID, PRIMITIVETYPE_BYTE, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return b;
}
-jbyte CallStaticByteMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- return (jbyte) callIntegerMethod(0, methodID, PRIMITIVETYPE_BYTE, args);
+ methodinfo *m;
+ jbyte b;
+
+ m = (methodinfo *) methodID;
+
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
+
+ return b;
}
-jbyte CallStaticByteMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticByteMethodA");
+ log_text("JNI-Call: CallStaticByteMethodA: IMPLEMENT ME!");
return 0;
}
-jchar CallStaticCharMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jchar _Jv_JNI_CallStaticCharMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jchar ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jchar c;
- /* log_text("JNI-Call: CallStaticByteMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = (jchar) callIntegerMethod(0, methodID, PRIMITIVETYPE_CHAR, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ c = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return c;
}
-jchar CallStaticCharMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- return (jchar) callIntegerMethod(0, methodID, PRIMITIVETYPE_CHAR, args);
+ methodinfo *m;
+ jchar c;
+
+ m = (methodinfo *) methodID;
+
+ c = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
+
+ return c;
}
-jchar CallStaticCharMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticCharMethodA");
+ log_text("JNI-Call: CallStaticCharMethodA: IMPLEMENT ME!");
return 0;
}
-
-jshort CallStaticShortMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jshort _Jv_JNI_CallStaticShortMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jshort ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jshort s;
- /* log_text("JNI-Call: CallStaticByteMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = (jshort) callIntegerMethod(0, methodID, PRIMITIVETYPE_SHORT, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ s = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return s;
}
-jshort CallStaticShortMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- /*log_text("JNI-Call: CallStaticShortMethodV");*/
- return (jshort) callIntegerMethod(0, methodID, PRIMITIVETYPE_SHORT, args);
+ methodinfo *m;
+ jshort s;
+
+ m = (methodinfo *) methodID;
+
+ s = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
+
+ return s;
}
-jshort CallStaticShortMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticShortMethodA");
+ log_text("JNI-Call: CallStaticShortMethodA: IMPLEMENT ME!");
return 0;
}
-
-jint CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jint _Jv_JNI_CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID,
+ ...)
{
- jint ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jint i;
- /* log_text("JNI-Call: CallStaticIntMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = callIntegerMethod(0, methodID, PRIMITIVETYPE_INT, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ i = _Jv_jni_CallIntMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return i;
}
-jint CallStaticIntMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticIntMethodV");
+ methodinfo *m;
+ jint i;
+
+ m = (methodinfo *) methodID;
- return callIntegerMethod(0, methodID, PRIMITIVETYPE_INT, args);
+ i = _Jv_jni_CallIntMethod(NULL, NULL, m, args);
+
+ return i;
}
-jint CallStaticIntMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticIntMethodA");
+ log_text("JNI-Call: CallStaticIntMethodA: IMPLEMENT ME!");
return 0;
}
-
-jlong CallStaticLongMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jlong _Jv_JNI_CallStaticLongMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jlong ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jlong l;
- /* log_text("JNI-Call: CallStaticLongMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = callLongMethod(0, methodID, vaargs);
- va_end(vaargs);
+ va_start(ap, methodID);
+ l = _Jv_jni_CallLongMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return l;
}
-jlong CallStaticLongMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticLongMethodV");
+ methodinfo *m;
+ jlong l;
- return callLongMethod(0,methodID,args);
+ m = (methodinfo *) methodID;
+
+ l = _Jv_jni_CallLongMethod(NULL, NULL, m, args);
+
+ return l;
}
-jlong CallStaticLongMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticLongMethodA");
+ log_text("JNI-Call: CallStaticLongMethodA: IMPLEMENT ME!");
return 0;
}
-jfloat CallStaticFloatMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jfloat _Jv_JNI_CallStaticFloatMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jfloat ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jfloat f;
- /* log_text("JNI-Call: CallStaticLongMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs, methodID);
- ret = callFloatMethod(0, methodID, vaargs, PRIMITIVETYPE_FLOAT);
- va_end(vaargs);
+ va_start(ap, methodID);
+ f = _Jv_jni_CallFloatMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return f;
}
-jfloat CallStaticFloatMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
+ methodinfo *m;
+ jfloat f;
+
+ m = (methodinfo *) methodID;
- return callFloatMethod(0, methodID, args, PRIMITIVETYPE_FLOAT);
+ f = _Jv_jni_CallFloatMethod(NULL, NULL, m, args);
+ return f;
}
-jfloat CallStaticFloatMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticFloatMethodA");
+ log_text("JNI-Call: CallStaticFloatMethodA: IMPLEMENT ME!");
return 0;
}
-
-jdouble CallStaticDoubleMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
+jdouble _Jv_JNI_CallStaticDoubleMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- jdouble ret;
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
+ jdouble d;
- /* log_text("JNI-Call: CallStaticDoubleMethod");*/
+ m = (methodinfo *) methodID;
- va_start(vaargs,methodID);
- ret = callFloatMethod(0, methodID, vaargs, PRIMITIVETYPE_DOUBLE);
- va_end(vaargs);
+ va_start(ap, methodID);
+ d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, ap);
+ va_end(ap);
- return ret;
+ return d;
}
-jdouble CallStaticDoubleMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
+jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticDoubleMethodV");
+ methodinfo *m;
+ jdouble d;
- return callFloatMethod(0, methodID, args, PRIMITIVETYPE_DOUBLE);
+ m = (methodinfo *) methodID;
+
+ d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, args);
+
+ return d;
}
-jdouble CallStaticDoubleMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, jvalue *args)
+jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue *args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticDoubleMethodA");
+ log_text("JNI-Call: CallStaticDoubleMethodA: IMPLEMENT ME!");
return 0;
}
-void CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...)
+void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz,
+ jmethodID methodID, ...)
{
- va_list vaargs;
- STATS(jniinvokation();)
+ methodinfo *m;
+ va_list ap;
- va_start(vaargs, methodID);
- (void) callIntegerMethod(0, methodID, TYPE_VOID, vaargs);
- va_end(vaargs);
+ m = (methodinfo *) methodID;
+
+ va_start(ap, methodID);
+ _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
+ va_end(ap);
}
-void CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)
+void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
+ jmethodID methodID, va_list args)
{
- log_text("JNI-Call: CallStaticVoidMethodV");
- STATS(jniinvokation();)
- (void)callIntegerMethod(0, methodID, TYPE_VOID, args);
+ methodinfo *m;
+
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
}
-void CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, jvalue * args)
+void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
+ jmethodID methodID, jvalue * args)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: CallStaticVoidMethodA");
+ methodinfo *m;
+
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethodA(NULL, NULL, m, args);
}
*******************************************************************************/
-jfieldID GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)
+jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
+ const char *sig)
{
- jfieldID f;
- STATS(jniinvokation();)
+ classinfo *c;
+ fieldinfo *f;
+ utf *uname;
+ utf *usig;
- f = jclass_findfield(clazz,
- utf_new_char((char *) name),
- utf_new_char((char *) sig));
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+
+ uname = utf_new_char((char *) name);
+ usig = utf_new_char((char *) sig);
+
+ f = class_findfield(clazz, uname, usig);
- if (!f)
- *exceptionptr = new_exception(string_java_lang_NoSuchFieldError);
+ if (f == NULL)
+ exceptions_throw_nosuchfielderror(c, uname);
- return f;
+ return (jfieldID) f;
}
*******************************************************************************/
-jobject GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
+ jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticObjectField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return NULL;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- return fieldID->value.a;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return NULL;
+
+ return _Jv_JNI_NewLocalRef(env, f->value.a);
}
-jboolean GetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jboolean _Jv_JNI_GetStaticBooleanField(JNIEnv *env, jclass clazz,
+ jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticBooleanField: calling initialize_class %s\n",clazz->name->text);)
+ classinfo *c;
+ fieldinfo *f;
- if (!initialize_class(clazz))
- return false;
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- return fieldID->value.i;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return false;
+
+ return f->value.i;
}
-jbyte GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jbyte _Jv_JNI_GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticByteField: calling initialize_class %s\n",clazz->name->text);)
+ classinfo *c;
+ fieldinfo *f;
- if (!initialize_class(clazz))
- return 0;
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- return fieldID->value.i;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0;
+
+ return f->value.i;
}
-jchar GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jchar _Jv_JNI_GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticCharField: calling initialize_class %s\n",clazz->name->text);)
+ classinfo *c;
+ fieldinfo *f;
- if (!initialize_class(clazz))
- return 0;
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- return fieldID->value.i;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0;
+
+ return f->value.i;
}
-jshort GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jshort _Jv_JNI_GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticShorttField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return 0;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
- return fieldID->value.i;
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0;
+
+ return f->value.i;
}
-jint GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jint _Jv_JNI_GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticIntField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return 0;
+ classinfo *c;
+ fieldinfo *f;
- return fieldID->value.i;
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0;
+
+ return f->value.i;
}
-jlong GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jlong _Jv_JNI_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticLongField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return 0;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0;
- return fieldID->value.l;
+ return f->value.l;
}
-jfloat GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jfloat _Jv_JNI_GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticFloatField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return 0.0;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0.0;
- return fieldID->value.f;
+ return f->value.f;
}
-jdouble GetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID)
+jdouble _Jv_JNI_GetStaticDoubleField(JNIEnv *env, jclass clazz,
+ jfieldID fieldID)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("GetStaticDoubleField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return 0.0;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return 0.0;
- return fieldID->value.d;
+ return f->value.d;
}
*******************************************************************************/
-void SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)
+void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jobject value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticObjectField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- fieldID->value.a = value;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.a = value;
}
-void SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value)
+void _Jv_JNI_SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jboolean value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticBooleanField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
- fieldID->value.i = value;
+ f->value.i = value;
}
-void SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value)
+void _Jv_JNI_SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jbyte value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticByteField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- fieldID->value.i = value;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.i = value;
}
-void SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value)
+void _Jv_JNI_SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jchar value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticCharField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
- fieldID->value.i = value;
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.i = value;
}
-void SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value)
+void _Jv_JNI_SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jshort value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticShortField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- fieldID->value.i = value;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.i = value;
}
-void SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID, jint value)
+void _Jv_JNI_SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jint value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticIntField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
- fieldID->value.i = value;
+ f->value.i = value;
}
-void SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value)
+void _Jv_JNI_SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jlong value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticLongField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- fieldID->value.l = value;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.l = value;
}
-void SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value)
+void _Jv_JNI_SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jfloat value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticFloatField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
- fieldID->value.f = value;
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.f = value;
}
-void SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value)
+void _Jv_JNI_SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID,
+ jdouble value)
{
- STATS(jniinvokation();)
- JWCLINITDEBUG(printf("SetStaticDoubleField: calling initialize_class %s\n",clazz->name->text);)
- if (!initialize_class(clazz))
- return;
+ classinfo *c;
+ fieldinfo *f;
+
+ STATISTICS(jniinvokation());
+
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
- fieldID->value.d = value;
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
+ return;
+
+ f->value.d = value;
}
+/* String Operations **********************************************************/
+
/* NewString *******************************************************************
Create new java.lang.String object from an array of Unicode
*******************************************************************************/
-jstring NewString(JNIEnv *env, const jchar *buf, jsize len)
+jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len)
{
java_lang_String *s;
java_chararray *a;
u4 i;
- STATS(jniinvokation();)
+
+ STATISTICS(jniinvokation());
s = (java_lang_String *) builtin_new(class_java_lang_String);
a = builtin_newarray_char(len);
/* javastring or characterarray could not be created */
- if (!a || !s)
+ if ((a == NULL) || (s == NULL))
return NULL;
/* copy text */
for (i = 0; i < len; i++)
a->data[i] = buf[i];
- s->value = a;
+ s->value = a;
s->offset = 0;
- s->count = len;
+ s->count = len;
- return (jstring) s;
+ return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
}
-static char emptyString[]="";
static jchar emptyStringJ[]={0,0};
-/******************* returns the length of a Java string ***************************/
+/* GetStringLength *************************************************************
-jsize GetStringLength (JNIEnv *env, jstring str)
+ Returns the length (the count of Unicode characters) of a Java
+ string.
+
+*******************************************************************************/
+
+jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
{
- return ((java_lang_String*) str)->count;
+ return ((java_lang_String *) str)->count;
}
/******************** convertes javastring to u2-array ****************************/
-u2 *javastring_tou2 (jstring so)
+u2 *javastring_tou2(jstring so)
{
- java_lang_String *s = (java_lang_String*) so;
- java_chararray *a;
- u4 i;
- u2 *stringbuffer;
- STATS(jniinvokation();)
+ java_lang_String *s;
+ java_chararray *a;
+ u2 *stringbuffer;
+ u4 i;
+
+ STATISTICS(jniinvokation());
- if (!s) return NULL;
+ s = (java_lang_String *) so;
+
+ if (!s)
+ return NULL;
a = s->value;
- if (!a) return NULL;
+
+ if (!a)
+ return NULL;
/* allocate memory */
- stringbuffer = MNEW( u2 , s->count + 1 );
+
+ stringbuffer = MNEW(u2, s->count + 1);
/* copy text */
- for (i=0; i<s->count; i++) stringbuffer[i] = a->data[s->offset+i];
+
+ for (i = 0; i < s->count; i++)
+ stringbuffer[i] = a->data[s->offset + i];
/* terminate string */
+
stringbuffer[i] = '\0';
return stringbuffer;
}
-/********* returns a pointer to an array of Unicode characters of the string *******/
-const jchar *GetStringChars (JNIEnv *env, jstring str, jboolean *isCopy)
+/* GetStringChars **************************************************************
+
+ Returns a pointer to the array of Unicode characters of the
+ string. This pointer is valid until ReleaseStringChars() is called.
+
+*******************************************************************************/
+
+const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
{
- jchar *jc=javastring_tou2(str);
- STATS(jniinvokation();)
+ jchar *jc;
+
+ STATISTICS(jniinvokation());
+
+ jc = javastring_tou2(str);
if (jc) {
- if (isCopy) *isCopy=JNI_TRUE;
+ if (isCopy)
+ *isCopy = JNI_TRUE;
+
return jc;
}
- if (isCopy) *isCopy=JNI_TRUE;
+
+ if (isCopy)
+ *isCopy = JNI_TRUE;
+
return emptyStringJ;
}
-/**************** native code no longer needs access to chars **********************/
-void ReleaseStringChars (JNIEnv *env, jstring str, const jchar *chars)
+/* ReleaseStringChars **********************************************************
+
+ Informs the VM that the native code no longer needs access to
+ chars. The chars argument is a pointer obtained from string using
+ GetStringChars().
+
+*******************************************************************************/
+
+void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
{
- STATS(jniinvokation();)
- if (chars==emptyStringJ) return;
- MFREE(((jchar*) chars),jchar,((java_lang_String*) str)->count+1);
+ STATISTICS(jniinvokation());
+
+ if (chars == emptyStringJ)
+ return;
+
+ MFREE(((jchar *) chars), jchar, ((java_lang_String *) str)->count + 1);
}
/* NewStringUTF ****************************************************************
- Constructs a new java.lang.String object from an array of UTF-8 characters.
+ Constructs a new java.lang.String object from an array of UTF-8
+ characters.
*******************************************************************************/
-jstring NewStringUTF(JNIEnv *env, const char *bytes)
+jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
{
- STATS(jniinvokation();)
- return (jstring) javastring_new(utf_new_char(bytes));
+ java_lang_String *s;
+
+ STATISTICS(jniinvokation());
+
+ s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
+
+ return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
}
/****************** returns the utf8 length in bytes of a string *******************/
-jsize GetStringUTFLength (JNIEnv *env, jstring string)
+jsize _Jv_JNI_GetStringUTFLength (JNIEnv *env, jstring string)
{
java_lang_String *s = (java_lang_String*) string;
- STATS(jniinvokation();)
+
+ STATISTICS(jniinvokation());
return (jsize) u2_utflength(s->value->data, s->count);
}
-/************ converts a Javastring to an array of UTF-8 characters ****************/
+/* GetStringUTFChars ***********************************************************
-const char* GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)
+ Returns a pointer to an array of UTF-8 characters of the
+ string. This array is valid until it is released by
+ ReleaseStringUTFChars().
+
+*******************************************************************************/
+
+const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
+ jboolean *isCopy)
{
- utf *u;
- STATS(jniinvokation();)
+ utf *u;
- u = javastring_toutf((java_lang_String *) string, false);
+ STATISTICS(jniinvokation());
- if (isCopy)
- *isCopy = JNI_FALSE;
+ if (string == NULL)
+ return "";
+
+ if (isCopy)
+ *isCopy = JNI_TRUE;
- if (u)
+ u = javastring_toutf((java_objectheader *) string, false);
+
+ if (u != NULL)
return u->text;
- return emptyString;
-
+ return "";
+}
+
+
+/* ReleaseStringUTFChars *******************************************************
+
+ Informs the VM that the native code no longer needs access to
+ utf. The utf argument is a pointer derived from string using
+ GetStringUTFChars().
+
+*******************************************************************************/
+
+void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf)
+{
+ STATISTICS(jniinvokation());
+
+ /* XXX we don't release utf chars right now, perhaps that should be done
+ later. Since there is always one reference the garbage collector will
+ never get them */
}
-/***************** native code no longer needs access to utf ***********************/
+/* Array Operations ***********************************************************/
-void ReleaseStringUTFChars (JNIEnv *env, jstring str, const char* chars)
-{
- STATS(jniinvokation();)
+/* GetArrayLength **************************************************************
- /*we don't release utf chars right now, perhaps that should be done later. Since there is always one reference
- the garbage collector will never get them*/
- /*
- log_text("JNI-Call: ReleaseStringUTFChars");
- utf_display(utf_new_char(chars));
- */
-}
+ Returns the number of elements in the array.
-/************************** array operations ***************************************/
+*******************************************************************************/
-jsize GetArrayLength(JNIEnv *env, jarray array)
+jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
{
- STATS(jniinvokation();)
+ java_arrayheader *a;
- return array->size;
+ STATISTICS(jniinvokation());
+
+ a = (java_arrayheader *) array;
+
+ return a->size;
}
*******************************************************************************/
-jobjectArray NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)
+jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
+ jclass elementClass, jobject initialElement)
{
java_objectarray *oa;
- s4 i;
- STATS(jniinvokation();)
+ s4 i;
+
+ STATISTICS(jniinvokation());
if (length < 0) {
- *exceptionptr = new_negativearraysizeexception();
+ exceptions_throw_negativearraysizeexception();
return NULL;
}
oa = builtin_anewarray(length, elementClass);
- if (!oa)
+ if (oa == NULL)
return NULL;
/* set all elements to initialElement */
for (i = 0; i < length; i++)
oa->data[i] = initialElement;
- return oa;
+ return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa);
}
-jobject GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)
+jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
+ jsize index)
{
- jobject j = NULL;
- STATS(jniinvokation();)
+ java_objectarray *oa;
+ jobject o;
- if (index < array->header.size)
- j = array->data[index];
- else
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
-
- return j;
+ STATISTICS(jniinvokation());
+
+ oa = (java_objectarray *) array;
+
+ if (index >= oa->header.size) {
+ exceptions_throw_arrayindexoutofboundsexception();
+ return NULL;
+ }
+
+ o = oa->data[index];
+
+ return _Jv_JNI_NewLocalRef(env, o);
}
-void SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject val)
+void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
+ jsize index, jobject val)
{
- STATS(jniinvokation();)
- if (index >= array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_objectarray *oa;
+ java_objectheader *o;
- else {
- /* check if the class of value is a subclass of the element class of the array */
- if (!builtin_canstore((java_objectarray *) array, (java_objectheader *) val))
- *exceptionptr = new_exception(string_java_lang_ArrayStoreException);
+ STATISTICS(jniinvokation());
- else
- array->data[index] = val;
- }
-}
+ oa = (java_objectarray *) array;
+ o = (java_objectheader *) val;
+
+ if (index >= oa->header.size) {
+ exceptions_throw_arrayindexoutofboundsexception();
+ return;
+ }
+
+ /* check if the class of value is a subclass of the element class
+ of the array */
+ if (!builtin_canstore(oa, o))
+ return;
+
+ oa->data[index] = val;
+}
-jbooleanArray NewBooleanArray(JNIEnv *env, jsize len)
+jbooleanArray _Jv_JNI_NewBooleanArray(JNIEnv *env, jsize len)
{
- java_booleanarray *j;
- STATS(jniinvokation();)
+ java_booleanarray *ba;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_boolean(len);
+ ba = builtin_newarray_boolean(len);
- return j;
+ return (jbooleanArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
}
-jbyteArray NewByteArray(JNIEnv *env, jsize len)
+jbyteArray _Jv_JNI_NewByteArray(JNIEnv *env, jsize len)
{
- java_bytearray *j;
- STATS(jniinvokation();)
+ java_bytearray *ba;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_byte(len);
+ ba = builtin_newarray_byte(len);
- return j;
+ return (jbyteArray) _Jv_JNI_NewLocalRef(env, (jobject) ba);
}
-jcharArray NewCharArray(JNIEnv *env, jsize len)
+jcharArray _Jv_JNI_NewCharArray(JNIEnv *env, jsize len)
{
- java_chararray *j;
- STATS(jniinvokation();)
+ java_chararray *ca;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_char(len);
+ ca = builtin_newarray_char(len);
- return j;
+ return (jcharArray) _Jv_JNI_NewLocalRef(env, (jobject) ca);
}
-jshortArray NewShortArray(JNIEnv *env, jsize len)
+jshortArray _Jv_JNI_NewShortArray(JNIEnv *env, jsize len)
{
- java_shortarray *j;
- STATS(jniinvokation();)
+ java_shortarray *sa;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_short(len);
+ sa = builtin_newarray_short(len);
- return j;
+ return (jshortArray) _Jv_JNI_NewLocalRef(env, (jobject) sa);
}
-jintArray NewIntArray(JNIEnv *env, jsize len)
+jintArray _Jv_JNI_NewIntArray(JNIEnv *env, jsize len)
{
- java_intarray *j;
- STATS(jniinvokation();)
+ java_intarray *ia;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_int(len);
+ ia = builtin_newarray_int(len);
- return j;
+ return (jintArray) _Jv_JNI_NewLocalRef(env, (jobject) ia);
}
-jlongArray NewLongArray(JNIEnv *env, jsize len)
+jlongArray _Jv_JNI_NewLongArray(JNIEnv *env, jsize len)
{
- java_longarray *j;
- STATS(jniinvokation();)
+ java_longarray *la;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_long(len);
+ la = builtin_newarray_long(len);
- return j;
+ return (jlongArray) _Jv_JNI_NewLocalRef(env, (jobject) la);
}
-jfloatArray NewFloatArray(JNIEnv *env, jsize len)
+jfloatArray _Jv_JNI_NewFloatArray(JNIEnv *env, jsize len)
{
- java_floatarray *j;
- STATS(jniinvokation();)
+ java_floatarray *fa;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_float(len);
+ fa = builtin_newarray_float(len);
- return j;
+ return (jfloatArray) _Jv_JNI_NewLocalRef(env, (jobject) fa);
}
-jdoubleArray NewDoubleArray(JNIEnv *env, jsize len)
+jdoubleArray _Jv_JNI_NewDoubleArray(JNIEnv *env, jsize len)
{
- java_doublearray *j;
- STATS(jniinvokation();)
+ java_doublearray *da;
+
+ STATISTICS(jniinvokation());
- if (len < 0) {
- *exceptionptr = new_exception(string_java_lang_NegativeArraySizeException);
+ if (len < 0) {
+ exceptions_throw_negativearraysizeexception();
return NULL;
- }
+ }
- j = builtin_newarray_double(len);
+ da = builtin_newarray_double(len);
- return j;
+ return (jdoubleArray) _Jv_JNI_NewLocalRef(env, (jobject) da);
}
-jboolean * GetBooleanArrayElements (JNIEnv *env, jbooleanArray array, jboolean *isCopy)
+/* Get<PrimitiveType>ArrayElements *********************************************
+
+ A family of functions that returns the body of the primitive array.
+
+*******************************************************************************/
+
+jboolean *_Jv_JNI_GetBooleanArrayElements(JNIEnv *env, jbooleanArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_booleanarray *ba;
+
+ STATISTICS(jniinvokation());
+
+ ba = (java_booleanarray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return ba->data;
}
-jbyte * GetByteArrayElements (JNIEnv *env, jbyteArray array, jboolean *isCopy)
+jbyte *_Jv_JNI_GetByteArrayElements(JNIEnv *env, jbyteArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_bytearray *ba;
+
+ STATISTICS(jniinvokation());
+
+ ba = (java_bytearray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return ba->data;
}
-jchar * GetCharArrayElements (JNIEnv *env, jcharArray array, jboolean *isCopy)
+jchar *_Jv_JNI_GetCharArrayElements(JNIEnv *env, jcharArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_chararray *ca;
+
+ STATISTICS(jniinvokation());
+
+ ca = (java_chararray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return ca->data;
}
-jshort * GetShortArrayElements (JNIEnv *env, jshortArray array, jboolean *isCopy)
+jshort *_Jv_JNI_GetShortArrayElements(JNIEnv *env, jshortArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_shortarray *sa;
+
+ STATISTICS(jniinvokation());
+
+ sa = (java_shortarray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return sa->data;
}
-jint * GetIntArrayElements (JNIEnv *env, jintArray array, jboolean *isCopy)
+jint *_Jv_JNI_GetIntArrayElements(JNIEnv *env, jintArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_intarray *ia;
+
+ STATISTICS(jniinvokation());
+
+ ia = (java_intarray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return ia->data;
}
-jlong * GetLongArrayElements (JNIEnv *env, jlongArray array, jboolean *isCopy)
+jlong *_Jv_JNI_GetLongArrayElements(JNIEnv *env, jlongArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_longarray *la;
+
+ STATISTICS(jniinvokation());
+
+ la = (java_longarray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ /* We cast this one to prevent a compiler warning on 64-bit
+ systems since GNU Classpath typedef jlong to long long. */
+
+ return (jlong *) la->data;
}
-jfloat * GetFloatArrayElements (JNIEnv *env, jfloatArray array, jboolean *isCopy)
+jfloat *_Jv_JNI_GetFloatArrayElements(JNIEnv *env, jfloatArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_floatarray *fa;
+
+ STATISTICS(jniinvokation());
+
+ fa = (java_floatarray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return fa->data;
}
-jdouble * GetDoubleArrayElements (JNIEnv *env, jdoubleArray array, jboolean *isCopy)
+jdouble *_Jv_JNI_GetDoubleArrayElements(JNIEnv *env, jdoubleArray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- if (isCopy) *isCopy = JNI_FALSE;
- return array->data;
+ java_doublearray *da;
+
+ STATISTICS(jniinvokation());
+
+ da = (java_doublearray *) array;
+
+ if (isCopy)
+ *isCopy = JNI_FALSE;
+
+ return da->data;
}
+/* Release<PrimitiveType>ArrayElements *****************************************
-void ReleaseBooleanArrayElements (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode)
+ A family of functions that informs the VM that the native code no
+ longer needs access to elems. The elems argument is a pointer
+ derived from array using the corresponding
+ Get<PrimitiveType>ArrayElements() function. If necessary, this
+ function copies back all changes made to elems to the original
+ array.
+
+*******************************************************************************/
+
+void _Jv_JNI_ReleaseBooleanArrayElements(JNIEnv *env, jbooleanArray array,
+ jboolean *elems, jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_booleanarray *ba;
+
+ STATISTICS(jniinvokation());
+
+ ba = (java_booleanarray *) array;
+
+ if (elems != ba->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(ba->data, elems, u1, ba->header.size);
+ break;
+ case 0:
+ MCOPY(ba->data, elems, u1, ba->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseByteArrayElements (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode)
+void _Jv_JNI_ReleaseByteArrayElements(JNIEnv *env, jbyteArray array,
+ jbyte *elems, jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_bytearray *ba;
+
+ STATISTICS(jniinvokation());
+
+ ba = (java_bytearray *) array;
+
+ if (elems != ba->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(ba->data, elems, s1, ba->header.size);
+ break;
+ case 0:
+ MCOPY(ba->data, elems, s1, ba->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseCharArrayElements (JNIEnv *env, jcharArray array, jchar *elems, jint mode)
+void _Jv_JNI_ReleaseCharArrayElements(JNIEnv *env, jcharArray array,
+ jchar *elems, jint mode)
{
- /* empty */
+ java_chararray *ca;
+
+ STATISTICS(jniinvokation());
+
+ ca = (java_chararray *) array;
+
+ if (elems != ca->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(ca->data, elems, u2, ca->header.size);
+ break;
+ case 0:
+ MCOPY(ca->data, elems, u2, ca->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseShortArrayElements (JNIEnv *env, jshortArray array, jshort *elems, jint mode)
+void _Jv_JNI_ReleaseShortArrayElements(JNIEnv *env, jshortArray array,
+ jshort *elems, jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_shortarray *sa;
+
+ STATISTICS(jniinvokation());
+
+ sa = (java_shortarray *) array;
+
+ if (elems != sa->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(sa->data, elems, s2, sa->header.size);
+ break;
+ case 0:
+ MCOPY(sa->data, elems, s2, sa->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseIntArrayElements (JNIEnv *env, jintArray array, jint *elems, jint mode)
+void _Jv_JNI_ReleaseIntArrayElements(JNIEnv *env, jintArray array, jint *elems,
+ jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_intarray *ia;
+
+ STATISTICS(jniinvokation());
+
+ ia = (java_intarray *) array;
+
+ if (elems != ia->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(ia->data, elems, s4, ia->header.size);
+ break;
+ case 0:
+ MCOPY(ia->data, elems, s4, ia->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseLongArrayElements (JNIEnv *env, jlongArray array, jlong *elems, jint mode)
+void _Jv_JNI_ReleaseLongArrayElements(JNIEnv *env, jlongArray array,
+ jlong *elems, jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_longarray *la;
+
+ STATISTICS(jniinvokation());
+
+ la = (java_longarray *) array;
+
+ /* We cast this one to prevent a compiler warning on 64-bit
+ systems since GNU Classpath typedef jlong to long long. */
+
+ if ((s8 *) elems != la->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(la->data, elems, s8, la->header.size);
+ break;
+ case 0:
+ MCOPY(la->data, elems, s8, la->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseFloatArrayElements (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode)
+void _Jv_JNI_ReleaseFloatArrayElements(JNIEnv *env, jfloatArray array,
+ jfloat *elems, jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_floatarray *fa;
+
+ STATISTICS(jniinvokation());
+
+ fa = (java_floatarray *) array;
+
+ if (elems != fa->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(fa->data, elems, float, fa->header.size);
+ break;
+ case 0:
+ MCOPY(fa->data, elems, float, fa->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void ReleaseDoubleArrayElements (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode)
+void _Jv_JNI_ReleaseDoubleArrayElements(JNIEnv *env, jdoubleArray array,
+ jdouble *elems, jint mode)
{
- STATS(jniinvokation();)
- /* empty */
+ java_doublearray *da;
+
+ STATISTICS(jniinvokation());
+
+ da = (java_doublearray *) array;
+
+ if (elems != da->data) {
+ switch (mode) {
+ case JNI_COMMIT:
+ MCOPY(da->data, elems, double, da->header.size);
+ break;
+ case 0:
+ MCOPY(da->data, elems, double, da->header.size);
+ /* XXX TWISTI how should it be freed? */
+ break;
+ case JNI_ABORT:
+ /* XXX TWISTI how should it be freed? */
+ break;
+ }
+ }
}
-void GetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize len, jboolean *buf)
+/* Get<PrimitiveType>ArrayRegion **********************************************
+
+ A family of functions that copies a region of a primitive array
+ into a buffer.
+
+*******************************************************************************/
+
+void _Jv_JNI_GetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
+ jsize start, jsize len, jboolean *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_booleanarray *ba;
+ STATISTICS(jniinvokation());
+
+ ba = (java_booleanarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ MCOPY(buf, &ba->data[start], u1, len);
}
-void GetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte *buf)
+void _Jv_JNI_GetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
+ jsize len, jbyte *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_bytearray *ba;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ ba = (java_bytearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &ba->data[start], s1, len);
}
-void GetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, jchar *buf)
+void _Jv_JNI_GetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
+ jsize len, jchar *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_chararray *ca;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ ca = (java_chararray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ca->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &ca->data[start], u2, len);
}
-void GetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, jshort *buf)
+void _Jv_JNI_GetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
+ jsize len, jshort *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_shortarray *sa;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ sa = (java_shortarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > sa->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &sa->data[start], s2, len);
}
-void GetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, jint *buf)
+void _Jv_JNI_GetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
+ jsize len, jint *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_intarray *ia;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ ia = (java_intarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ia->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &ia->data[start], s4, len);
}
-void GetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, jlong *buf)
+void _Jv_JNI_GetLongArrayRegion(JNIEnv *env, jlongArray array, jsize start,
+ jsize len, jlong *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_longarray *la;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ la = (java_longarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > la->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &la->data[start], s8, len);
}
-void GetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat *buf)
+void _Jv_JNI_GetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
+ jsize len, jfloat *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_floatarray *fa;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ fa = (java_floatarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > fa->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &fa->data[start], float, len);
}
-void GetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble *buf)
+void _Jv_JNI_GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
+ jsize len, jdouble *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start+len>array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_doublearray *da;
- else
- memcpy(buf, &array->data[start], len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ da = (java_doublearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > da->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(buf, &da->data[start], double, len);
}
-void SetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize len, jboolean *buf)
+/* Set<PrimitiveType>ArrayRegion **********************************************
+
+ A family of functions that copies back a region of a primitive
+ array from a buffer.
+
+*******************************************************************************/
+
+void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
+ jsize start, jsize len, jboolean *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_booleanarray *ba;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ ba = (java_booleanarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&ba->data[start], buf, u1, len);
}
-void SetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte *buf)
+void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
+ jsize len, jbyte *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_bytearray *ba;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ ba = (java_bytearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&ba->data[start], buf, s1, len);
}
-void SetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, jchar *buf)
+void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
+ jsize len, jchar *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_chararray *ca;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ ca = (java_chararray *) array;
+ if ((start < 0) || (len < 0) || (start + len > ca->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&ca->data[start], buf, u2, len);
}
-void SetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, jshort *buf)
+void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
+ jsize len, jshort *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_shortarray *sa;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ sa = (java_shortarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > sa->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&sa->data[start], buf, s2, len);
}
-void SetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, jint *buf)
+void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
+ jsize len, jint *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_intarray *ia;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+ ia = (java_intarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ia->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&ia->data[start], buf, s4, len);
}
-void SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, jlong *buf)
+void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start,
+ jsize len, jlong *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_longarray *la;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+ la = (java_longarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > la->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&la->data[start], buf, s8, len);
}
-void SetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat *buf)
+void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
+ jsize len, jfloat *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_floatarray *fa;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+ fa = (java_floatarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > fa->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&fa->data[start], buf, float, len);
}
-void SetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble *buf)
+void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
+ jsize len, jdouble *buf)
{
- STATS(jniinvokation();)
- if (start < 0 || len < 0 || start + len > array->header.size)
- *exceptionptr = new_exception(string_java_lang_ArrayIndexOutOfBoundsException);
+ java_doublearray *da;
- else
- memcpy(&array->data[start], buf, len * sizeof(array->data[0]));
+ STATISTICS(jniinvokation());
+
+ da = (java_doublearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > da->header.size))
+ exceptions_throw_arrayindexoutofboundsexception();
+ else
+ MCOPY(&da->data[start], buf, double, len);
}
-jint RegisterNatives (JNIEnv* env, jclass clazz, const JNINativeMethod *methods, jint nMethods)
+/* Registering Native Methods *************************************************/
+
+/* RegisterNatives *************************************************************
+
+ Registers native methods with the class specified by the clazz
+ argument. The methods parameter specifies an array of
+ JNINativeMethod structures that contain the names, signatures, and
+ function pointers of the native methods. The nMethods parameter
+ specifies the number of native methods in the array.
+
+*******************************************************************************/
+
+jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
+ const JNINativeMethod *methods, jint nMethods)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: RegisterNatives");
+ STATISTICS(jniinvokation());
+
+ log_text("JNI-Call: RegisterNatives: IMPLEMENT ME!!!");
+ /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
+ if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr);
+ */
+
return 0;
}
-jint UnregisterNatives (JNIEnv* env, jclass clazz)
+/* UnregisterNatives ***********************************************************
+
+ Unregisters native methods of a class. The class goes back to the
+ state before it was linked or registered with its native method
+ functions.
+
+ This function should not be used in normal native code. Instead, it
+ provides special programs a way to reload and relink native
+ libraries.
+
+*******************************************************************************/
+
+jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: UnregisterNatives");
+ STATISTICS(jniinvokation());
+
+ /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */
+
+ log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!");
+
return 0;
}
*******************************************************************************/
-jint MonitorEnter(JNIEnv *env, jobject obj)
+jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj)
{
- STATS(jniinvokation();)
- if (!obj) {
- *exceptionptr = new_nullpointerexception();
+ STATISTICS(jniinvokation());
+
+ if (obj == NULL) {
+ exceptions_throw_nullpointerexception();
return JNI_ERR;
}
-#if defined(USE_THREADS)
- builtin_monitorenter(obj);
-#endif
+ LOCK_MONITOR_ENTER(obj);
return JNI_OK;
}
*******************************************************************************/
-jint MonitorExit(JNIEnv *env, jobject obj)
+jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj)
{
- STATS(jniinvokation();)
- if (!obj) {
- *exceptionptr = new_nullpointerexception();
+ STATISTICS(jniinvokation());
+
+ if (obj == NULL) {
+ exceptions_throw_nullpointerexception();
return JNI_ERR;
}
-#if defined(USE_THREADS)
- builtin_monitorexit(obj);
-#endif
+ LOCK_MONITOR_EXIT(obj);
return JNI_OK;
}
*******************************************************************************/
-jint GetJavaVM(JNIEnv *env, JavaVM **vm)
+jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **vm)
{
- STATS(jniinvokation();)
- *vm = &ptr_jvm;
+ STATISTICS(jniinvokation());
+
+ *vm = (JavaVM *) _Jv_jvm;
return 0;
}
-void GetStringRegion (JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf)
+/* GetStringRegion *************************************************************
+
+ Copies len number of Unicode characters beginning at offset start
+ to the given buffer buf.
+
+ Throws StringIndexOutOfBoundsException on index overflow.
+
+*******************************************************************************/
+
+void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len,
+ jchar *buf)
+{
+ java_lang_String *s;
+ java_chararray *ca;
+
+ STATISTICS(jniinvokation());
+
+ s = (java_lang_String *) str;
+ ca = s->value;
+
+ if ((start < 0) || (len < 0) || (start > s->count) ||
+ (start + len > s->count)) {
+ exceptions_throw_stringindexoutofboundsexception();
+ return;
+ }
+
+ MCOPY(buf, &ca->data[start], u2, len);
+}
+
+
+void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start,
+ jsize len, char *buf)
+{
+ STATISTICS(jniinvokation());
+
+ log_text("JNI-Call: GetStringUTFRegion: IMPLEMENT ME!");
+}
+
+
+/* GetPrimitiveArrayCritical ***************************************************
+
+ Obtain a direct pointer to array elements.
+
+*******************************************************************************/
+
+void *_Jv_JNI_GetPrimitiveArrayCritical(JNIEnv *env, jarray array,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: GetStringRegion");
+ java_bytearray *ba;
+ jbyte *bp;
+
+ ba = (java_bytearray *) array;
+
+ /* do the same as Kaffe does */
+
+ bp = _Jv_JNI_GetByteArrayElements(env, ba, isCopy);
+
+ return (void *) bp;
}
-void GetStringUTFRegion (JNIEnv* env, jstring str, jsize start, jsize len, char *buf)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: GetStringUTFRegion");
-}
+/* ReleasePrimitiveArrayCritical ***********************************************
+ No specific documentation.
-/************** obtain direct pointer to array elements ***********************/
+*******************************************************************************/
-void * GetPrimitiveArrayCritical (JNIEnv* env, jarray array, jboolean *isCopy)
+void _Jv_JNI_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array,
+ void *carray, jint mode)
{
- java_objectheader *s = (java_objectheader*) array;
- arraydescriptor *desc = s->vftbl->arraydesc;
-
- STATS(jniinvokation();)
+ STATISTICS(jniinvokation());
- if (!desc) return NULL;
+ /* do the same as Kaffe does */
- return ((u1*)s) + desc->dataoffset;
+ _Jv_JNI_ReleaseByteArrayElements(env, (jbyteArray) array, (jbyte *) carray,
+ mode);
}
-void ReleasePrimitiveArrayCritical (JNIEnv* env, jarray array, void *carray, jint mode)
-{
- STATS(jniinvokation();)
- log_text("JNI-Call: ReleasePrimitiveArrayCritical");
+/* GetStringCritical ***********************************************************
- /* empty */
-}
+ The semantics of these two functions are similar to the existing
+ Get/ReleaseStringChars functions.
-/**** returns a pointer to an array of Unicode characters of the string *******/
+*******************************************************************************/
-const jchar * GetStringCritical (JNIEnv* env, jstring string, jboolean *isCopy)
+const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string,
+ jboolean *isCopy)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: GetStringCritical");
+ STATISTICS(jniinvokation());
- return GetStringChars(env,string,isCopy);
+ return _Jv_JNI_GetStringChars(env, string, isCopy);
}
-/*********** native code no longer needs access to chars **********************/
-void ReleaseStringCritical (JNIEnv* env, jstring string, const jchar *cstring)
+void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string,
+ const jchar *cstring)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: ReleaseStringCritical");
+ STATISTICS(jniinvokation());
- ReleaseStringChars(env,string,cstring);
+ _Jv_JNI_ReleaseStringChars(env, string, cstring);
}
-jweak NewWeakGlobalRef (JNIEnv* env, jobject obj)
+jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: NewWeakGlobalRef");
+ STATISTICS(jniinvokation());
+
+ log_text("JNI-Call: NewWeakGlobalRef: IMPLEMENT ME!");
return obj;
}
-void DeleteWeakGlobalRef (JNIEnv* env, jweak ref)
+void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref)
{
- STATS(jniinvokation();)
- log_text("JNI-Call: DeleteWeakGlobalRef");
+ STATISTICS(jniinvokation());
- /* empty */
+ log_text("JNI-Call: DeleteWeakGlobalRef: IMPLEMENT ME");
}
-/** Creates a new global reference to the object referred to by the obj argument **/
+/* NewGlobalRef ****************************************************************
+
+ Creates a new global reference to the object referred to by the obj
+ argument.
+
+*******************************************************************************/
-jobject NewGlobalRef(JNIEnv* env, jobject lobj)
+jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
{
- jobject refcount;
- jint val;
- jobject newval;
- STATS(jniinvokation();)
+ hashtable_global_ref_entry *gre;
+ u4 key; /* hashkey */
+ u4 slot; /* slot in hashtable */
+
+ STATISTICS(jniinvokation());
- MonitorEnter(env, *global_ref_table);
+ LOCK_MONITOR_ENTER(hashtable_global_ref->header);
+
+ /* normally addresses are aligned to 4, 8 or 16 bytes */
+
+ key = ((u4) (ptrint) obj) >> 4; /* align to 16-byte boundaries */
+ slot = key & (hashtable_global_ref->size - 1);
+ gre = hashtable_global_ref->ptr[slot];
- refcount = CallObjectMethod(env, *global_ref_table, getmid, lobj);
- val = (refcount == NULL) ? 0 : CallIntMethod(env, refcount, intvalue);
- newval = NewObject(env, intclass, newint, val + 1);
+ /* search external hash chain for the entry */
- if (newval != NULL) {
- CallObjectMethod(env, *global_ref_table, putmid, lobj, newval);
- MonitorExit(env, *global_ref_table);
- return lobj;
+ while (gre) {
+ if (gre->o == obj) {
+ /* global object found, increment the reference */
- } else {
- log_text("JNI-NewGlobalRef: unable to create new java.lang.Integer");
- MonitorExit(env, *global_ref_table);
- return NULL;
+ gre->refs++;
+
+ LOCK_MONITOR_EXIT(hashtable_global_ref->header);
+
+ return obj;
+ }
+
+ gre = gre->hashlink; /* next element in external chain */
}
+
+ /* global ref not found, create a new one */
+
+ gre = NEW(hashtable_global_ref_entry);
+
+ gre->o = obj;
+ gre->refs = 1;
+
+ /* insert entry into hashtable */
+
+ gre->hashlink = hashtable_global_ref->ptr[slot];
+
+ hashtable_global_ref->ptr[slot] = gre;
+
+ /* update number of hashtable-entries */
+
+ hashtable_global_ref->entries++;
+
+ LOCK_MONITOR_EXIT(hashtable_global_ref->header);
+
+ return obj;
}
-/************* Deletes the global reference pointed to by globalRef **************/
-void DeleteGlobalRef(JNIEnv* env, jobject gref)
+/* DeleteGlobalRef *************************************************************
+
+ Deletes the global reference pointed to by globalRef.
+
+*******************************************************************************/
+
+void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
{
- jobject refcount;
- jint val;
- STATS(jniinvokation();)
+ hashtable_global_ref_entry *gre;
+ hashtable_global_ref_entry *prevgre;
+ u4 key; /* hashkey */
+ u4 slot; /* slot in hashtable */
- MonitorEnter(env, *global_ref_table);
- refcount = CallObjectMethod(env, *global_ref_table, getmid, gref);
+ STATISTICS(jniinvokation());
- if (refcount == NULL) {
- log_text("JNI-DeleteGlobalRef: unable to find global reference");
- return;
- }
+ LOCK_MONITOR_ENTER(hashtable_global_ref->header);
- val = CallIntMethod(env, refcount, intvalue);
- val--;
+ /* normally addresses are aligned to 4, 8 or 16 bytes */
- if (val == 0) {
- CallObjectMethod(env, *global_ref_table, removemid,refcount);
+ key = ((u4) (ptrint) globalRef) >> 4; /* align to 16-byte boundaries */
+ slot = key & (hashtable_global_ref->size - 1);
+ gre = hashtable_global_ref->ptr[slot];
- } else {
- jobject newval = NewObject(env, intclass, newint, val);
+ /* initialize prevgre */
+
+ prevgre = NULL;
+
+ /* search external hash chain for the entry */
- if (newval != NULL) {
- CallObjectMethod(env,*global_ref_table, putmid,newval);
+ while (gre) {
+ if (gre->o == globalRef) {
+ /* global object found, decrement the reference count */
- } else {
- log_text("JNI-DeleteGlobalRef: unable to create new java.lang.Integer");
+ gre->refs--;
+
+ /* if reference count is 0, remove the entry */
+
+ if (gre->refs == 0) {
+ /* special handling if it's the first in the chain */
+
+ if (prevgre == NULL)
+ hashtable_global_ref->ptr[slot] = gre->hashlink;
+ else
+ prevgre->hashlink = gre->hashlink;
+
+ FREE(gre, hashtable_global_ref_entry);
+ }
+
+ LOCK_MONITOR_EXIT(hashtable_global_ref->header);
+
+ return;
}
+
+ prevgre = gre; /* save current pointer for removal */
+ gre = gre->hashlink; /* next element in external chain */
}
- MonitorExit(env,*global_ref_table);
+ log_println("JNI-DeleteGlobalRef: global reference not found");
+
+ LOCK_MONITOR_EXIT(hashtable_global_ref->header);
}
*******************************************************************************/
-jboolean ExceptionCheck(JNIEnv *env)
+jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
{
- STATS(jniinvokation();)
- return *exceptionptr ? JNI_TRUE : JNI_FALSE;
+ java_objectheader *o;
+
+ STATISTICS(jniinvokation());
+
+ o = exceptions_get_exception();
+
+ return (o != NULL) ? JNI_TRUE : JNI_FALSE;
}
/* NewDirectByteBuffer *********************************************************
- Allocates and returns a direct java.nio.ByteBuffer referring to the block of
- memory starting at the memory address address and extending capacity bytes.
+ Allocates and returns a direct java.nio.ByteBuffer referring to the
+ block of memory starting at the memory address address and
+ extending capacity bytes.
*******************************************************************************/
-jobject NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
+jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
{
- STATS(jniinvokation();)
- log_text("NewDirectByteBuffer: IMPLEMENT ME!");
+#if defined(ENABLE_JAVASE)
+ java_objectheader *nbuf;
+# if SIZEOF_VOID_P == 8
+ gnu_classpath_Pointer64 *paddress;
+# else
+ gnu_classpath_Pointer32 *paddress;
+# endif
+
+ STATISTICS(jniinvokation());
+
+ /* alocate a gnu.classpath.Pointer{32,64} object */
+
+# if SIZEOF_VOID_P == 8
+ if (!(paddress = (gnu_classpath_Pointer64 *)
+ builtin_new(class_gnu_classpath_Pointer64)))
+# else
+ if (!(paddress = (gnu_classpath_Pointer32 *)
+ builtin_new(class_gnu_classpath_Pointer32)))
+# endif
+ return NULL;
+
+ /* fill gnu.classpath.Pointer{32,64} with address */
+
+ paddress->data = (ptrint) address;
+
+ /* create a java.nio.DirectByteBufferImpl$ReadWrite object */
+
+ nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite,
+ (jmethodID) dbbirw_init, NULL, paddress,
+ (jint) capacity, (jint) capacity, (jint) 0);
+
+ /* add local reference and return the value */
+
+ return _Jv_JNI_NewLocalRef(env, nbuf);
+#else
+ vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration");
+
+ /* keep compiler happy */
return NULL;
+#endif
}
/* GetDirectBufferAddress ******************************************************
- Fetches and returns the starting address of the memory region referenced by
- the given direct java.nio.Buffer.
+ Fetches and returns the starting address of the memory region
+ referenced by the given direct java.nio.Buffer.
*******************************************************************************/
-void *GetDirectBufferAddress(JNIEnv *env, jobject buf)
+void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
{
- STATS(jniinvokation();)
- log_text("GetDirectBufferAddress: IMPLEMENT ME!");
+#if defined(ENABLE_JAVASE)
+ java_nio_DirectByteBufferImpl *nbuf;
+# if SIZEOF_VOID_P == 8
+ gnu_classpath_Pointer64 *address;
+# else
+ gnu_classpath_Pointer32 *address;
+# endif
+
+ STATISTICS(jniinvokation());
+
+ if (!builtin_instanceof(buf, class_java_nio_Buffer))
+ return NULL;
+
+ nbuf = (java_nio_DirectByteBufferImpl *) buf;
+
+# if SIZEOF_VOID_P == 8
+ address = (gnu_classpath_Pointer64 *) nbuf->address;
+# else
+ address = (gnu_classpath_Pointer32 *) nbuf->address;
+# endif
+
+ if (address == NULL)
+ return NULL;
+
+ return (void *) address->data;
+#else
+ vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
+
+ /* keep compiler happy */
return NULL;
+#endif
}
/* GetDirectBufferCapacity *****************************************************
- Fetches and returns the capacity in bytes of the memory region referenced by
- the given direct java.nio.Buffer.
+ Fetches and returns the capacity in bytes of the memory region
+ referenced by the given direct java.nio.Buffer.
*******************************************************************************/
-jlong GetDirectBufferCapacity(JNIEnv* env, jobject buf)
+jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
{
- STATS(jniinvokation();)
- log_text("GetDirectBufferCapacity: IMPLEMENT ME!");
+#if defined(ENABLE_JAVASE)
+ java_nio_Buffer *nbuf;
- return 0;
-}
+ STATISTICS(jniinvokation());
+
+ if (!builtin_instanceof(buf, class_java_nio_DirectByteBufferImpl))
+ return -1;
+ nbuf = (java_nio_Buffer *) buf;
-jint DestroyJavaVM(JavaVM *vm)
-{
- STATS(jniinvokation();)
- log_text("DestroyJavaVM called");
+ return (jlong) nbuf->cap;
+#else
+ vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
+
+ /* keep compiler happy */
return 0;
+#endif
}
-jint AttachCurrentThread(JavaVM *vm, void **env, void *thr_args)
+/* DestroyJavaVM ***************************************************************
+
+ Unloads a Java VM and reclaims its resources. Only the main thread
+ can unload the VM. The system waits until the main thread is only
+ remaining user thread before it destroys the VM.
+
+*******************************************************************************/
+
+jint _Jv_JNI_DestroyJavaVM(JavaVM *vm)
{
- STATS(jniinvokation();)
- log_text("AttachCurrentThread called");
+ s4 status;
-#if !defined(HAVE___THREAD)
-/* cacao_thread_attach();*/
-#else
- #error "No idea how to implement that. Perhaps Stefan knows"
-#endif
+ STATISTICS(jniinvokation());
- *env = &ptr_env;
- return 0;
+ status = vm_destroy(vm);
+
+ return status;
}
-jint DetachCurrentThread(JavaVM *vm)
-{
- STATS(jniinvokation();)
- log_text("DetachCurrentThread called");
+/* AttachCurrentThread *********************************************************
- return 0;
-}
+ Attaches the current thread to a Java VM. Returns a JNI interface
+ pointer in the JNIEnv argument.
+ Trying to attach a thread that is already attached is a no-op.
-jint GetEnv(JavaVM *vm, void **env, jint version)
+ A native thread cannot be attached simultaneously to two Java VMs.
+
+ When a thread is attached to the VM, the context class loader is
+ the bootstrap loader.
+
+*******************************************************************************/
+
+static s4 jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon)
{
- STATS(jniinvokation();)
- if ((version != JNI_VERSION_1_1) && (version != JNI_VERSION_1_2) &&
- (version != JNI_VERSION_1_4)) {
- *env = NULL;
- return JNI_EVERSION;
- }
+ JavaVMAttachArgs *vm_aargs;
- /*
- TODO: If the current thread is not attached to the VM...
- if (0) {
- *env = NULL;
- return JNI_EDETACHED;
+#if defined(ENABLE_THREADS)
+ if (threads_get_current_threadobject() == NULL) {
+ vm_aargs = (JavaVMAttachArgs *) thr_args;
+
+ if (vm_aargs != NULL) {
+ if ((vm_aargs->version != JNI_VERSION_1_2) &&
+ (vm_aargs->version != JNI_VERSION_1_4))
+ return JNI_EVERSION;
+ }
+
+ if (!threads_attach_current_thread(vm_aargs, false))
+ return JNI_ERR;
+
+ if (!jni_init_localref_table())
+ return JNI_ERR;
}
- */
+#endif
- *env = &ptr_env;
+ *p_env = _Jv_env;
return JNI_OK;
}
-jint AttachCurrentThreadAsDaemon(JavaVM *vm, void **par1, void *par2)
+jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args)
{
- STATS(jniinvokation();)
- log_text("AttachCurrentThreadAsDaemon called");
+ STATISTICS(jniinvokation());
- return 0;
+ return jni_attach_current_thread(p_env, thr_args, false);
}
-/************* JNI Initialization ****************************************************/
-jobject jni_init1(JNIEnv* env, jobject lobj) {
-#if defined(USE_THREADS)
- while (initrunning) {yieldThread();} /* wait until init is done */
-#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);
- }
-#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 */
-#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);
- }
+/* DetachCurrentThread *********************************************************
+
+ Detaches the current thread from a Java VM. All Java monitors held
+ by this thread are released. All Java threads waiting for this
+ thread to die are notified.
+
+ In JDK 1.1, the main thread cannot be detached from the VM. It must
+ call DestroyJavaVM to unload the entire VM.
+
+ In the JDK, the main thread can be detached from the VM.
+
+ The main thread, which is the thread that created the Java VM,
+ cannot be detached from the VM. Instead, the main thread must call
+ JNI_DestroyJavaVM() to unload the entire VM.
+
+*******************************************************************************/
+
+jint _Jv_JNI_DetachCurrentThread(JavaVM *vm)
+{
+#if defined(ENABLE_THREADS)
+ threadobject *thread;
+
+ STATISTICS(jniinvokation());
+
+ thread = threads_get_current_threadobject();
+
+ if (thread == NULL)
+ return JNI_ERR;
+
+ if (!jni_free_localref_table())
+ return JNI_ERR;
+
+ if (!threads_detach_thread(thread))
+ return JNI_ERR;
#endif
- DeleteGlobalRef(env, gref);
+
+ return JNI_OK;
}
-void jni_init(){
- jmethodID mid;
- initrunning = true;
- log_text("JNI-Init: initialize global_ref_table");
- /* initalize global reference table */
- ihmclass = FindClass(NULL, "java/util/IdentityHashMap");
-
- if (ihmclass == NULL) {
- log_text("JNI-Init: unable to find java.util.IdentityHashMap");
- }
+/* GetEnv **********************************************************************
- mid = GetMethodID(NULL, ihmclass, "<init>","()V");
- if (mid == NULL) {
- log_text("JNI-Init: unable to find constructor in java.util.IdentityHashMap");
- }
-
- global_ref_table = (jobject*)heap_allocate(sizeof(jobject),true,NULL);
+ If the current thread is not attached to the VM, sets *env to NULL,
+ and returns JNI_EDETACHED. If the specified version is not
+ supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise,
+ sets *env to the appropriate interface, and returns JNI_OK.
- *global_ref_table = NewObject(NULL,ihmclass,mid);
+*******************************************************************************/
- if (*global_ref_table == NULL) {
- log_text("JNI-Init: unable to create new global_ref_table");
- }
+jint _Jv_JNI_GetEnv(JavaVM *vm, void **env, jint version)
+{
+ STATISTICS(jniinvokation());
- initrunning = false;
+#if defined(ENABLE_THREADS)
+ if (threads_get_current_threadobject() == NULL) {
+ *env = NULL;
- getmid = GetMethodID(NULL, ihmclass, "get","(Ljava/lang/Object;)Ljava/lang/Object;");
- if (mid == NULL) {
- log_text("JNI-Init: unable to find method \"get\" in java.util.IdentityHashMap");
+ return JNI_EDETACHED;
}
+#endif
- getmid = GetMethodID(NULL ,ihmclass, "get","(Ljava/lang/Object;)Ljava/lang/Object;");
- if (getmid == NULL) {
- log_text("JNI-Init: unable to find method \"get\" in java.util.IdentityHashMap");
- }
+ /* check the JNI version */
- putmid = GetMethodID(NULL, ihmclass, "put","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
- if (putmid == NULL) {
- log_text("JNI-Init: unable to find method \"put\" in java.util.IdentityHashMap");
- }
+ switch (version) {
+ case JNI_VERSION_1_1:
+ case JNI_VERSION_1_2:
+ case JNI_VERSION_1_4:
+ *env = _Jv_env;
+ return JNI_OK;
- intclass = FindClass(NULL, "java/lang/Integer");
- if (intclass == NULL) {
- log_text("JNI-Init: unable to find java.lang.Integer");
+ default:
+ ;
}
- newint = GetMethodID(NULL, intclass, "<init>","(I)V");
- if (newint == NULL) {
- log_text("JNI-Init: unable to find constructor in java.lang.Integer");
- }
+#if defined(ENABLE_JVMTI)
+ if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE)
+ == JVMTI_VERSION_INTERFACE_JVMTI) {
- intvalue = GetMethodID(NULL, intclass, "intValue","()I");
- if (intvalue == NULL) {
- log_text("JNI-Init: unable to find method \"intValue\" in java.lang.Integer");
- }
+ *env = (void *) jvmti_new_environment();
- removemid = GetMethodID(NULL, ihmclass, "remove","(Ljava/lang/Object;)Ljava/lang/Object;");
- if (removemid == NULL) {
- log_text("JNI-DeleteGlobalRef: unable to find method \"remove\" in java.lang.Object");
+ if (env != NULL)
+ return JNI_OK;
}
+#endif
- /* set NewGlobalRef, DeleteGlobalRef envTable entry to real implementation */
+ *env = NULL;
+
+ return JNI_EVERSION;
+}
+
+
+/* AttachCurrentThreadAsDaemon *************************************************
+
+ Same semantics as AttachCurrentThread, but the newly-created
+ java.lang.Thread instance is a daemon.
+
+ If the thread has already been attached via either
+ AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine
+ simply sets the value pointed to by penv to the JNIEnv of the
+ current thread. In this case neither AttachCurrentThread nor this
+ routine have any effect on the daemon status of the thread.
+
+*******************************************************************************/
+
+jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
+{
+ STATISTICS(jniinvokation());
- JNI_JNIEnvTable.NewGlobalRef = &NewGlobalRef;
- JNI_JNIEnvTable.DeleteGlobalRef = &DeleteGlobalRef;
+ return jni_attach_current_thread(penv, args, true);
}
/* JNI invocation table *******************************************************/
-const struct JNIInvokeInterface JNI_JavaVMTable = {
+const struct JNIInvokeInterface _Jv_JNIInvokeInterface = {
NULL,
NULL,
NULL,
- DestroyJavaVM,
- AttachCurrentThread,
- DetachCurrentThread,
- GetEnv,
- AttachCurrentThreadAsDaemon
+ _Jv_JNI_DestroyJavaVM,
+ _Jv_JNI_AttachCurrentThread,
+ _Jv_JNI_DetachCurrentThread,
+ _Jv_JNI_GetEnv,
+ _Jv_JNI_AttachCurrentThreadAsDaemon
};
/* JNI function table *********************************************************/
-struct JNINativeInterface JNI_JNIEnvTable = {
+struct JNINativeInterface _Jv_JNINativeInterface = {
NULL,
NULL,
NULL,
NULL,
- &GetVersion,
-
- &DefineClass,
- &FindClass,
- &FromReflectedMethod,
- &FromReflectedField,
- &ToReflectedMethod,
- &GetSuperclass,
- &IsAssignableFrom,
- &ToReflectedField,
-
- &Throw,
- &ThrowNew,
- &ExceptionOccurred,
- &ExceptionDescribe,
- &ExceptionClear,
- &FatalError,
- &PushLocalFrame,
- &PopLocalFrame,
-
- &jni_init1, /* &NewGlobalRef, initialize Global_Ref_Table*/
- &jni_init2, /* &DeleteGlobalRef,*/
- &DeleteLocalRef,
- &IsSameObject,
- &NewLocalRef,
- &EnsureLocalCapacity,
-
- &AllocObject,
- &NewObject,
- &NewObjectV,
- &NewObjectA,
-
- &GetObjectClass,
- &IsInstanceOf,
-
- &GetMethodID,
-
- &CallObjectMethod,
- &CallObjectMethodV,
- &CallObjectMethodA,
- &CallBooleanMethod,
- &CallBooleanMethodV,
- &CallBooleanMethodA,
- &CallByteMethod,
- &CallByteMethodV,
- &CallByteMethodA,
- &CallCharMethod,
- &CallCharMethodV,
- &CallCharMethodA,
- &CallShortMethod,
- &CallShortMethodV,
- &CallShortMethodA,
- &CallIntMethod,
- &CallIntMethodV,
- &CallIntMethodA,
- &CallLongMethod,
- &CallLongMethodV,
- &CallLongMethodA,
- &CallFloatMethod,
- &CallFloatMethodV,
- &CallFloatMethodA,
- &CallDoubleMethod,
- &CallDoubleMethodV,
- &CallDoubleMethodA,
- &CallVoidMethod,
- &CallVoidMethodV,
- &CallVoidMethodA,
-
- &CallNonvirtualObjectMethod,
- &CallNonvirtualObjectMethodV,
- &CallNonvirtualObjectMethodA,
- &CallNonvirtualBooleanMethod,
- &CallNonvirtualBooleanMethodV,
- &CallNonvirtualBooleanMethodA,
- &CallNonvirtualByteMethod,
- &CallNonvirtualByteMethodV,
- &CallNonvirtualByteMethodA,
- &CallNonvirtualCharMethod,
- &CallNonvirtualCharMethodV,
- &CallNonvirtualCharMethodA,
- &CallNonvirtualShortMethod,
- &CallNonvirtualShortMethodV,
- &CallNonvirtualShortMethodA,
- &CallNonvirtualIntMethod,
- &CallNonvirtualIntMethodV,
- &CallNonvirtualIntMethodA,
- &CallNonvirtualLongMethod,
- &CallNonvirtualLongMethodV,
- &CallNonvirtualLongMethodA,
- &CallNonvirtualFloatMethod,
- &CallNonvirtualFloatMethodV,
- &CallNonvirtualFloatMethodA,
- &CallNonvirtualDoubleMethod,
- &CallNonvirtualDoubleMethodV,
- &CallNonvirtualDoubleMethodA,
- &CallNonvirtualVoidMethod,
- &CallNonvirtualVoidMethodV,
- &CallNonvirtualVoidMethodA,
-
- &GetFieldID,
-
- &GetObjectField,
- &GetBooleanField,
- &GetByteField,
- &GetCharField,
- &GetShortField,
- &GetIntField,
- &GetLongField,
- &GetFloatField,
- &GetDoubleField,
- &SetObjectField,
- &SetBooleanField,
- &SetByteField,
- &SetCharField,
- &SetShortField,
- &SetIntField,
- &SetLongField,
- &SetFloatField,
- &SetDoubleField,
-
- &GetStaticMethodID,
-
- &CallStaticObjectMethod,
- &CallStaticObjectMethodV,
- &CallStaticObjectMethodA,
- &CallStaticBooleanMethod,
- &CallStaticBooleanMethodV,
- &CallStaticBooleanMethodA,
- &CallStaticByteMethod,
- &CallStaticByteMethodV,
- &CallStaticByteMethodA,
- &CallStaticCharMethod,
- &CallStaticCharMethodV,
- &CallStaticCharMethodA,
- &CallStaticShortMethod,
- &CallStaticShortMethodV,
- &CallStaticShortMethodA,
- &CallStaticIntMethod,
- &CallStaticIntMethodV,
- &CallStaticIntMethodA,
- &CallStaticLongMethod,
- &CallStaticLongMethodV,
- &CallStaticLongMethodA,
- &CallStaticFloatMethod,
- &CallStaticFloatMethodV,
- &CallStaticFloatMethodA,
- &CallStaticDoubleMethod,
- &CallStaticDoubleMethodV,
- &CallStaticDoubleMethodA,
- &CallStaticVoidMethod,
- &CallStaticVoidMethodV,
- &CallStaticVoidMethodA,
-
- &GetStaticFieldID,
-
- &GetStaticObjectField,
- &GetStaticBooleanField,
- &GetStaticByteField,
- &GetStaticCharField,
- &GetStaticShortField,
- &GetStaticIntField,
- &GetStaticLongField,
- &GetStaticFloatField,
- &GetStaticDoubleField,
- &SetStaticObjectField,
- &SetStaticBooleanField,
- &SetStaticByteField,
- &SetStaticCharField,
- &SetStaticShortField,
- &SetStaticIntField,
- &SetStaticLongField,
- &SetStaticFloatField,
- &SetStaticDoubleField,
-
- &NewString,
- &GetStringLength,
- &GetStringChars,
- &ReleaseStringChars,
-
- &NewStringUTF,
- &GetStringUTFLength,
- &GetStringUTFChars,
- &ReleaseStringUTFChars,
-
- &GetArrayLength,
-
- &NewObjectArray,
- &GetObjectArrayElement,
- &SetObjectArrayElement,
-
- &NewBooleanArray,
- &NewByteArray,
- &NewCharArray,
- &NewShortArray,
- &NewIntArray,
- &NewLongArray,
- &NewFloatArray,
- &NewDoubleArray,
-
- &GetBooleanArrayElements,
- &GetByteArrayElements,
- &GetCharArrayElements,
- &GetShortArrayElements,
- &GetIntArrayElements,
- &GetLongArrayElements,
- &GetFloatArrayElements,
- &GetDoubleArrayElements,
-
- &ReleaseBooleanArrayElements,
- &ReleaseByteArrayElements,
- &ReleaseCharArrayElements,
- &ReleaseShortArrayElements,
- &ReleaseIntArrayElements,
- &ReleaseLongArrayElements,
- &ReleaseFloatArrayElements,
- &ReleaseDoubleArrayElements,
-
- &GetBooleanArrayRegion,
- &GetByteArrayRegion,
- &GetCharArrayRegion,
- &GetShortArrayRegion,
- &GetIntArrayRegion,
- &GetLongArrayRegion,
- &GetFloatArrayRegion,
- &GetDoubleArrayRegion,
- &SetBooleanArrayRegion,
- &SetByteArrayRegion,
- &SetCharArrayRegion,
- &SetShortArrayRegion,
- &SetIntArrayRegion,
- &SetLongArrayRegion,
- &SetFloatArrayRegion,
- &SetDoubleArrayRegion,
-
- &RegisterNatives,
- &UnregisterNatives,
-
- &MonitorEnter,
- &MonitorExit,
-
- &GetJavaVM,
+ _Jv_JNI_GetVersion,
+
+ _Jv_JNI_DefineClass,
+ _Jv_JNI_FindClass,
+ _Jv_JNI_FromReflectedMethod,
+ _Jv_JNI_FromReflectedField,
+ _Jv_JNI_ToReflectedMethod,
+ _Jv_JNI_GetSuperclass,
+ _Jv_JNI_IsAssignableFrom,
+ _Jv_JNI_ToReflectedField,
+
+ _Jv_JNI_Throw,
+ _Jv_JNI_ThrowNew,
+ _Jv_JNI_ExceptionOccurred,
+ _Jv_JNI_ExceptionDescribe,
+ _Jv_JNI_ExceptionClear,
+ _Jv_JNI_FatalError,
+ _Jv_JNI_PushLocalFrame,
+ _Jv_JNI_PopLocalFrame,
+
+ _Jv_JNI_NewGlobalRef,
+ _Jv_JNI_DeleteGlobalRef,
+ _Jv_JNI_DeleteLocalRef,
+ _Jv_JNI_IsSameObject,
+ _Jv_JNI_NewLocalRef,
+ _Jv_JNI_EnsureLocalCapacity,
+
+ _Jv_JNI_AllocObject,
+ _Jv_JNI_NewObject,
+ _Jv_JNI_NewObjectV,
+ _Jv_JNI_NewObjectA,
+
+ _Jv_JNI_GetObjectClass,
+ _Jv_JNI_IsInstanceOf,
+
+ _Jv_JNI_GetMethodID,
+
+ _Jv_JNI_CallObjectMethod,
+ _Jv_JNI_CallObjectMethodV,
+ _Jv_JNI_CallObjectMethodA,
+ _Jv_JNI_CallBooleanMethod,
+ _Jv_JNI_CallBooleanMethodV,
+ _Jv_JNI_CallBooleanMethodA,
+ _Jv_JNI_CallByteMethod,
+ _Jv_JNI_CallByteMethodV,
+ _Jv_JNI_CallByteMethodA,
+ _Jv_JNI_CallCharMethod,
+ _Jv_JNI_CallCharMethodV,
+ _Jv_JNI_CallCharMethodA,
+ _Jv_JNI_CallShortMethod,
+ _Jv_JNI_CallShortMethodV,
+ _Jv_JNI_CallShortMethodA,
+ _Jv_JNI_CallIntMethod,
+ _Jv_JNI_CallIntMethodV,
+ _Jv_JNI_CallIntMethodA,
+ _Jv_JNI_CallLongMethod,
+ _Jv_JNI_CallLongMethodV,
+ _Jv_JNI_CallLongMethodA,
+ _Jv_JNI_CallFloatMethod,
+ _Jv_JNI_CallFloatMethodV,
+ _Jv_JNI_CallFloatMethodA,
+ _Jv_JNI_CallDoubleMethod,
+ _Jv_JNI_CallDoubleMethodV,
+ _Jv_JNI_CallDoubleMethodA,
+ _Jv_JNI_CallVoidMethod,
+ _Jv_JNI_CallVoidMethodV,
+ _Jv_JNI_CallVoidMethodA,
+
+ _Jv_JNI_CallNonvirtualObjectMethod,
+ _Jv_JNI_CallNonvirtualObjectMethodV,
+ _Jv_JNI_CallNonvirtualObjectMethodA,
+ _Jv_JNI_CallNonvirtualBooleanMethod,
+ _Jv_JNI_CallNonvirtualBooleanMethodV,
+ _Jv_JNI_CallNonvirtualBooleanMethodA,
+ _Jv_JNI_CallNonvirtualByteMethod,
+ _Jv_JNI_CallNonvirtualByteMethodV,
+ _Jv_JNI_CallNonvirtualByteMethodA,
+ _Jv_JNI_CallNonvirtualCharMethod,
+ _Jv_JNI_CallNonvirtualCharMethodV,
+ _Jv_JNI_CallNonvirtualCharMethodA,
+ _Jv_JNI_CallNonvirtualShortMethod,
+ _Jv_JNI_CallNonvirtualShortMethodV,
+ _Jv_JNI_CallNonvirtualShortMethodA,
+ _Jv_JNI_CallNonvirtualIntMethod,
+ _Jv_JNI_CallNonvirtualIntMethodV,
+ _Jv_JNI_CallNonvirtualIntMethodA,
+ _Jv_JNI_CallNonvirtualLongMethod,
+ _Jv_JNI_CallNonvirtualLongMethodV,
+ _Jv_JNI_CallNonvirtualLongMethodA,
+ _Jv_JNI_CallNonvirtualFloatMethod,
+ _Jv_JNI_CallNonvirtualFloatMethodV,
+ _Jv_JNI_CallNonvirtualFloatMethodA,
+ _Jv_JNI_CallNonvirtualDoubleMethod,
+ _Jv_JNI_CallNonvirtualDoubleMethodV,
+ _Jv_JNI_CallNonvirtualDoubleMethodA,
+ _Jv_JNI_CallNonvirtualVoidMethod,
+ _Jv_JNI_CallNonvirtualVoidMethodV,
+ _Jv_JNI_CallNonvirtualVoidMethodA,
+
+ _Jv_JNI_GetFieldID,
+
+ _Jv_JNI_GetObjectField,
+ _Jv_JNI_GetBooleanField,
+ _Jv_JNI_GetByteField,
+ _Jv_JNI_GetCharField,
+ _Jv_JNI_GetShortField,
+ _Jv_JNI_GetIntField,
+ _Jv_JNI_GetLongField,
+ _Jv_JNI_GetFloatField,
+ _Jv_JNI_GetDoubleField,
+ _Jv_JNI_SetObjectField,
+ _Jv_JNI_SetBooleanField,
+ _Jv_JNI_SetByteField,
+ _Jv_JNI_SetCharField,
+ _Jv_JNI_SetShortField,
+ _Jv_JNI_SetIntField,
+ _Jv_JNI_SetLongField,
+ _Jv_JNI_SetFloatField,
+ _Jv_JNI_SetDoubleField,
+
+ _Jv_JNI_GetStaticMethodID,
+
+ _Jv_JNI_CallStaticObjectMethod,
+ _Jv_JNI_CallStaticObjectMethodV,
+ _Jv_JNI_CallStaticObjectMethodA,
+ _Jv_JNI_CallStaticBooleanMethod,
+ _Jv_JNI_CallStaticBooleanMethodV,
+ _Jv_JNI_CallStaticBooleanMethodA,
+ _Jv_JNI_CallStaticByteMethod,
+ _Jv_JNI_CallStaticByteMethodV,
+ _Jv_JNI_CallStaticByteMethodA,
+ _Jv_JNI_CallStaticCharMethod,
+ _Jv_JNI_CallStaticCharMethodV,
+ _Jv_JNI_CallStaticCharMethodA,
+ _Jv_JNI_CallStaticShortMethod,
+ _Jv_JNI_CallStaticShortMethodV,
+ _Jv_JNI_CallStaticShortMethodA,
+ _Jv_JNI_CallStaticIntMethod,
+ _Jv_JNI_CallStaticIntMethodV,
+ _Jv_JNI_CallStaticIntMethodA,
+ _Jv_JNI_CallStaticLongMethod,
+ _Jv_JNI_CallStaticLongMethodV,
+ _Jv_JNI_CallStaticLongMethodA,
+ _Jv_JNI_CallStaticFloatMethod,
+ _Jv_JNI_CallStaticFloatMethodV,
+ _Jv_JNI_CallStaticFloatMethodA,
+ _Jv_JNI_CallStaticDoubleMethod,
+ _Jv_JNI_CallStaticDoubleMethodV,
+ _Jv_JNI_CallStaticDoubleMethodA,
+ _Jv_JNI_CallStaticVoidMethod,
+ _Jv_JNI_CallStaticVoidMethodV,
+ _Jv_JNI_CallStaticVoidMethodA,
+
+ _Jv_JNI_GetStaticFieldID,
+
+ _Jv_JNI_GetStaticObjectField,
+ _Jv_JNI_GetStaticBooleanField,
+ _Jv_JNI_GetStaticByteField,
+ _Jv_JNI_GetStaticCharField,
+ _Jv_JNI_GetStaticShortField,
+ _Jv_JNI_GetStaticIntField,
+ _Jv_JNI_GetStaticLongField,
+ _Jv_JNI_GetStaticFloatField,
+ _Jv_JNI_GetStaticDoubleField,
+ _Jv_JNI_SetStaticObjectField,
+ _Jv_JNI_SetStaticBooleanField,
+ _Jv_JNI_SetStaticByteField,
+ _Jv_JNI_SetStaticCharField,
+ _Jv_JNI_SetStaticShortField,
+ _Jv_JNI_SetStaticIntField,
+ _Jv_JNI_SetStaticLongField,
+ _Jv_JNI_SetStaticFloatField,
+ _Jv_JNI_SetStaticDoubleField,
+
+ _Jv_JNI_NewString,
+ _Jv_JNI_GetStringLength,
+ _Jv_JNI_GetStringChars,
+ _Jv_JNI_ReleaseStringChars,
+
+ _Jv_JNI_NewStringUTF,
+ _Jv_JNI_GetStringUTFLength,
+ _Jv_JNI_GetStringUTFChars,
+ _Jv_JNI_ReleaseStringUTFChars,
+
+ _Jv_JNI_GetArrayLength,
+
+ _Jv_JNI_NewObjectArray,
+ _Jv_JNI_GetObjectArrayElement,
+ _Jv_JNI_SetObjectArrayElement,
+
+ _Jv_JNI_NewBooleanArray,
+ _Jv_JNI_NewByteArray,
+ _Jv_JNI_NewCharArray,
+ _Jv_JNI_NewShortArray,
+ _Jv_JNI_NewIntArray,
+ _Jv_JNI_NewLongArray,
+ _Jv_JNI_NewFloatArray,
+ _Jv_JNI_NewDoubleArray,
+
+ _Jv_JNI_GetBooleanArrayElements,
+ _Jv_JNI_GetByteArrayElements,
+ _Jv_JNI_GetCharArrayElements,
+ _Jv_JNI_GetShortArrayElements,
+ _Jv_JNI_GetIntArrayElements,
+ _Jv_JNI_GetLongArrayElements,
+ _Jv_JNI_GetFloatArrayElements,
+ _Jv_JNI_GetDoubleArrayElements,
+
+ _Jv_JNI_ReleaseBooleanArrayElements,
+ _Jv_JNI_ReleaseByteArrayElements,
+ _Jv_JNI_ReleaseCharArrayElements,
+ _Jv_JNI_ReleaseShortArrayElements,
+ _Jv_JNI_ReleaseIntArrayElements,
+ _Jv_JNI_ReleaseLongArrayElements,
+ _Jv_JNI_ReleaseFloatArrayElements,
+ _Jv_JNI_ReleaseDoubleArrayElements,
+
+ _Jv_JNI_GetBooleanArrayRegion,
+ _Jv_JNI_GetByteArrayRegion,
+ _Jv_JNI_GetCharArrayRegion,
+ _Jv_JNI_GetShortArrayRegion,
+ _Jv_JNI_GetIntArrayRegion,
+ _Jv_JNI_GetLongArrayRegion,
+ _Jv_JNI_GetFloatArrayRegion,
+ _Jv_JNI_GetDoubleArrayRegion,
+ _Jv_JNI_SetBooleanArrayRegion,
+ _Jv_JNI_SetByteArrayRegion,
+ _Jv_JNI_SetCharArrayRegion,
+ _Jv_JNI_SetShortArrayRegion,
+ _Jv_JNI_SetIntArrayRegion,
+ _Jv_JNI_SetLongArrayRegion,
+ _Jv_JNI_SetFloatArrayRegion,
+ _Jv_JNI_SetDoubleArrayRegion,
+
+ _Jv_JNI_RegisterNatives,
+ _Jv_JNI_UnregisterNatives,
+
+ _Jv_JNI_MonitorEnter,
+ _Jv_JNI_MonitorExit,
+
+ _Jv_JNI_GetJavaVM,
/* new JNI 1.2 functions */
- &GetStringRegion,
- &GetStringUTFRegion,
+ _Jv_JNI_GetStringRegion,
+ _Jv_JNI_GetStringUTFRegion,
- &GetPrimitiveArrayCritical,
- &ReleasePrimitiveArrayCritical,
+ _Jv_JNI_GetPrimitiveArrayCritical,
+ _Jv_JNI_ReleasePrimitiveArrayCritical,
- &GetStringCritical,
- &ReleaseStringCritical,
+ _Jv_JNI_GetStringCritical,
+ _Jv_JNI_ReleaseStringCritical,
- &NewWeakGlobalRef,
- &DeleteWeakGlobalRef,
+ _Jv_JNI_NewWeakGlobalRef,
+ _Jv_JNI_DeleteWeakGlobalRef,
- &ExceptionCheck,
+ _Jv_JNI_ExceptionCheck,
/* new JNI 1.4 functions */
- &NewDirectByteBuffer,
- &GetDirectBufferAddress,
- &GetDirectBufferCapacity
+ _Jv_JNI_NewDirectByteBuffer,
+ _Jv_JNI_GetDirectBufferAddress,
+ _Jv_JNI_GetDirectBufferCapacity
};
jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
{
- JDK1_1InitArgs *_vm_args = (JDK1_1InitArgs *) vm_args;
+ JavaVMInitArgs *_vm_args;
+
+ _vm_args = (JavaVMInitArgs *) vm_args;
/* GNU classpath currently supports JNI 1.2 */
- _vm_args->version = JNI_VERSION_1_2;
+ switch (_vm_args->version) {
+ case JNI_VERSION_1_1:
+ _vm_args->version = JNI_VERSION_1_1;
+ break;
+
+ case JNI_VERSION_1_2:
+ case JNI_VERSION_1_4:
+ _vm_args->ignoreUnrecognized = JNI_FALSE;
+ _vm_args->options = NULL;
+ _vm_args->nOptions = 0;
+ break;
+ default:
+ return -1;
+ }
+
return 0;
}
*******************************************************************************/
-jint JNI_CreateJavaVM(JavaVM **p_vm, JNIEnv **p_env, void *vm_args)
-{
- *p_vm = (JavaVM *) &JNI_JavaVMTable;
- *p_env = (JNIEnv *) &JNI_JNIEnvTable;
-
- return 0;
-}
-
-
-jobject *jni_method_invokeNativeHelper(JNIEnv *env, struct methodinfo *methodID, jobject obj, java_objectarray *params)
+jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
{
- int argcount;
- jni_callblock *blk;
- int retT;
- jobject retVal;
-
- if (methodID == 0) {
- *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
- return NULL;
- }
-
- argcount = methodID->parseddesc->paramcount;
-
- /* the method is an instance method the obj has to be an instance of the
- class the method belongs to. For static methods the obj parameter
- is ignored. */
- if (!(methodID->flags & ACC_STATIC) && obj &&
- (!builtin_instanceof((java_objectheader *) obj, methodID->class))) {
- *exceptionptr = new_exception_message(string_java_lang_IllegalArgumentException,
- "Object parameter of wrong type in Java_java_lang_reflect_Method_invokeNative");
- return 0;
- }
-
+ /* actually create the JVM */
-#ifdef arglimit
- if (argcount > 3) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- log_text("Too many arguments. invokeNativeHelper does not support that");
- return 0;
- }
-#endif
- if (((params==0) && (argcount != 0)) || (params && (params->header.size != argcount))) {
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
- return 0;
- }
-
-
- if (((methodID->flags & ACC_STATIC)==0) && (0==obj)) {
- *exceptionptr =
- new_exception_message(string_java_lang_NullPointerException,
- "Static mismatch in Java_java_lang_reflect_Method_invokeNative");
- return 0;
- }
-
- if ((methodID->flags & ACC_STATIC) && (obj)) obj = 0;
-
- if (obj) {
- if ( (methodID->flags & ACC_ABSTRACT) || (methodID->class->flags & ACC_INTERFACE) ) {
- methodID=get_virtual(obj,methodID);
- }
- }
-
- blk = MNEW(jni_callblock, /*4 */argcount+2);
-
- if (!fill_callblock_objA(obj, methodID->parseddesc, blk, params,&retT))
- return 0; /* exception */
-
- switch (retT) {
- case TYPE_VOID:
- (void) asm_calljavafunction2(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = NULL; /*native_new_and_init(loader_load(utf_new_char("java/lang/Void")));*/
- break;
-
- case PRIMITIVETYPE_INT: {
- s4 intVal;
- intVal = asm_calljavafunction2int(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Integer);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_int__void),
- intVal);
- }
- break;
-
- case PRIMITIVETYPE_BYTE: {
- s4 intVal;
- intVal = asm_calljavafunction2int(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Byte);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_byte__void),
- intVal);
- }
- break;
-
- case PRIMITIVETYPE_CHAR: {
- s4 intVal;
- intVal = asm_calljavafunction2int(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Character);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_char__void),
- intVal);
- }
- break;
-
- case PRIMITIVETYPE_SHORT: {
- s4 intVal;
- intVal = asm_calljavafunction2int(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Short);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_short__void),
- intVal);
- }
- break;
-
- case PRIMITIVETYPE_BOOLEAN: {
- s4 intVal;
- intVal = asm_calljavafunction2int(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Boolean);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_boolean__void),
- intVal);
- }
- break;
-
- case 'J': {
- jlong longVal;
- longVal = asm_calljavafunction2long(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Long);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_long__void),
- longVal);
- }
- break;
-
- case PRIMITIVETYPE_FLOAT: {
- jdouble floatVal;
- floatVal = asm_calljavafunction2float(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Float);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_float__void),
- floatVal);
- }
- break;
-
- case PRIMITIVETYPE_DOUBLE: {
- jdouble doubleVal;
- doubleVal = asm_calljavafunction2double(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- retVal = builtin_new(class_java_lang_Double);
- CallVoidMethod(env,
- retVal,
- class_resolvemethod(retVal->vftbl->class,
- utf_init,
- utf_double__void),
- doubleVal);
- }
- break;
-
- case TYPE_ADR:
- retVal = asm_calljavafunction2(methodID,
- argcount + 1,
- (argcount + 1) * sizeof(jni_callblock),
- blk);
- break;
-
- default:
- /* if this happens the acception has already been set by fill_callblock_objA*/
- MFREE(blk, jni_callblock, /*4 */ argcount+2);
- return (jobject *) 0;
- }
-
- MFREE(blk, jni_callblock, /* 4 */ argcount+2);
-
- if (*exceptionptr) {
- java_objectheader *exceptionToWrap = *exceptionptr;
- classinfo *ivtec;
- java_objectheader *ivte;
-
- *exceptionptr = NULL;
- if (load_class_bootstrap(utf_new_char("java/lang/reflect/InvocationTargetException"),
- &ivtec))
- {
- ivte = builtin_new(ivtec);
- asm_calljavafunction(class_resolvemethod(ivtec,
- utf_new_char("<init>"),
- utf_new_char("(Ljava/lang/Throwable;)V")),
- ivte,
- exceptionToWrap,
- 0,
- 0);
- }
-
- if (*exceptionptr != NULL)
- panic("jni.c: error while creating InvocationTargetException wrapper");
-
- *exceptionptr = ivte;
- }
+ if (!vm_createjvm(p_vm, p_env, vm_args))
+ return JNI_ERR;
- return (jobject *) retVal;
+ return JNI_OK;
}
-
-
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/