* src/vm/vm.c (vm_call_float_array): New function.
[cacao.git] / src / native / jni.c
index 6cbeff3874a567889e48be27cfe2dbd309a23677..33944fe479891f40d99a633cc03d0350cec62b70 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.c 7280 2007-02-03 19:34:10Z twisti $
+   $Id: jni.c 8106 2007-06-19 22:50:17Z twisti $
 
 */
 
@@ -30,6 +30,7 @@
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 #include <string.h>
 
 #include "vm/types.h"
 #include "native/jni.h"
 #include "native/native.h"
 
-#include "native/include/gnu_classpath_Pointer.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"
+#  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_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_ClassLoader.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"
-#include "native/include/java_nio_Buffer.h"
-#include "native/include/java_nio_DirectByteBufferImpl.h"
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_ClassLoader.h"
+
+# 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
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-# include "threads/native/threads.h"
-#else
-# include "threads/none/lock.h"
+#include "native/vm/java_lang_Class.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/vm/java_lang_ClassLoader.h"
 #endif
 
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
+
 #include "toolbox/logging.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/initialize.h"
+#include "vm/resolve.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/jit.h"
+#include "vm/jit/stacktrace.h"
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
-#include "vmcore/resolve.h"
+#include "vmcore/primitive.h"
 #include "vmcore/statistics.h"
 
 
@@ -111,16 +121,21 @@ static 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 SIZEOF_VOID_P == 8
+
+# if defined(WITH_CLASSPATH_GNU)
+#  if SIZEOF_VOID_P == 8
 static classinfo *class_gnu_classpath_Pointer64;
-#else
+#  else
 static classinfo *class_gnu_classpath_Pointer32;
-#endif
+#  endif
+# endif
 
 static methodinfo *dbbirw_init;
+#endif
 
 
 /* local reference table ******************************************************/
@@ -160,6 +175,7 @@ bool jni_init(void)
        hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
 
 
+#if defined(ENABLE_JAVASE)
        /* direct buffer stuff */
 
        if (!(class_java_nio_Buffer =
@@ -183,17 +199,20 @@ bool jni_init(void)
                                                        utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
                return false;
 
-#if SIZEOF_VOID_P == 8
+# 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
+#  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
+#endif /* defined(ENABLE_JAVASE) */
 
        return true;
 }
@@ -229,184 +248,6 @@ bool jni_init_localref_table(void)
 }
 
 
-/* _Jv_jni_vmargs_from_objectarray *********************************************
-
-   XXX
-
-*******************************************************************************/
-
-static bool _Jv_jni_vmargs_from_objectarray(java_objectheader *o,
-                                                                                       methoddesc *descr,
-                                                                                       vm_arg *vmargs,
-                                                                                       java_objectarray *params)
-{
-       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 */
-
-       i = 0;
-
-       if (o != NULL) {
-               /* this pointer */
-               vmargs[0].type   = TYPE_ADR;
-               vmargs[0].data.l = (u8) (ptrint) o;
-
-               paramtypes++;
-               paramcount--;
-               i++;
-       }
-
-       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;
-
-                               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_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;
-                                       }
-                               }
-
-                               vmargs[i].type   = TYPE_ADR;
-                               vmargs[i].data.l = (u8) (ptrint) params->data[j];
-                               break;
-
-                       default:
-                               goto illegal_arg;
-               }
-       }
-
-/*     if (rettype) */
-/*             *rettype = descr->returntype.decltype; */
-
-       return true;
-
-illegal_arg:
-       exceptions_throw_illegalargumentexception();
-       return false;
-}
-
-
 /* _Jv_jni_CallObjectMethod ****************************************************
 
    Internal function to call Java Object methods.
@@ -641,6 +482,52 @@ static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
 }
 
 
+/* _Jv_jni_CallLongMethodA *****************************************************
+
+   Internal function to call Java long methods.
+
+*******************************************************************************/
+
+static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl,
+                                                                        methodinfo *m, jvalue *args)
+{
+       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_jvalue(resm, o, args);
+
+       return l;
+}
+
+
 /* _Jv_jni_CallFloatMethod *****************************************************
 
    Internal function to call Java float methods.
@@ -680,6 +567,45 @@ static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
 }
 
 
+/* _Jv_jni_CallFloatMethodA ****************************************************
+
+   Internal function to call Java float methods.
+
+*******************************************************************************/
+
+static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl,
+                                                                          methodinfo *m, jvalue *args)
+{
+       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_jvalue(resm, o, args);
+
+       return f;
+}
+
+
 /* _Jv_jni_CallDoubleMethod ****************************************************
 
    Internal function to call Java double methods.
@@ -717,6 +643,43 @@ static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
 }
 
 
+/* _Jv_jni_CallDoubleMethodA ***************************************************
+
+   Internal function to call Java double methods.
+
+*******************************************************************************/
+
+static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl,
+                                                                                methodinfo *m, jvalue *args)
+{
+       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_jvalue(resm, o, args);
+
+       return d;
+}
+
+
 /* _Jv_jni_CallVoidMethod ******************************************************
 
    Internal function to call Java void methods.
@@ -810,6 +773,7 @@ static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
 
 *******************************************************************************/
 
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__)
 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
                                                                                java_objectarray *params)
 {
@@ -874,8 +838,10 @@ java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
 
        vmargs = MNEW(vm_arg, argcount);
 
-       if (!_Jv_jni_vmargs_from_objectarray(o, resm->parseddesc, vmargs, params))
+       if (!vm_vmargs_from_objectarray(resm, o, vmargs, params)) {
+               MFREE(vmargs, vm_arg, argcount);
                return NULL;
+       }
 
        switch (resm->parseddesc->returntype.decltype) {
        case TYPE_VOID:
@@ -1031,6 +997,245 @@ java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
 
        return ro;
 }
+#else
+java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
+                                                                               java_objectarray *params)
+{
+       methodinfo        *resm;
+       java_objectheader *ro;
+       s4                 argcount;
+       s4                 paramcount;
+       java_objectheader *xptr;
+       int32_t            dumpsize;
+       uint64_t          *array;
+
+       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;
+       }
+
+       /* mark start of dump memory area */
+
+       dumpsize = dump_size();
+
+       /* fill the argument array from a object-array */
+
+       array = vm_array_from_objectarray(resm, o, params);
+
+       if (array == NULL) {
+               /* release dump area */
+
+               dump_release(dumpsize);
+
+               return NULL;
+       }
+
+       switch (resm->parseddesc->returntype.decltype) {
+       case TYPE_VOID:
+               (void) vm_call_array(resm, array);
+
+               ro = NULL;
+               break;
+
+       case PRIMITIVETYPE_BOOLEAN: {
+               s4 i;
+               java_lang_Boolean *bo;
+
+               i = vm_call_int_array(resm, array);
+
+               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_int_array(resm, array);
+
+               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_int_array(resm, array);
+
+               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_int_array(resm, array);
+
+               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_int_array(resm, array);
+
+               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_long_array(resm, array);
+
+               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_float_array(resm, array);
+
+               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_double_array(resm, array);
+
+               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_array(resm, array);
+               break;
+
+       default:
+               /* if this happens the exception has already been set by
+                  fill_callblock_from_objectarray */
+
+               /* release dump area */
+
+               dump_release(dumpsize);
+
+               return NULL;
+       }
+
+       xptr = exceptions_get_exception();
+
+       if (xptr != NULL) {
+               /* clear exception pointer, we are calling JIT code again */
+
+               exceptions_clear_exception();
+
+               exceptions_throw_invocationtargetexception(xptr);
+       }
+
+       /* release dump area */
+
+       dump_release(dumpsize);
+
+       return ro;
+}
+#endif
 
 
 /* GetVersion ******************************************************************
@@ -1063,6 +1268,7 @@ jint _Jv_JNI_GetVersion(JNIEnv *env)
 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;
@@ -1071,13 +1277,20 @@ jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
        STATISTICS(jniinvokation());
 
        cl = (java_lang_ClassLoader *) loader;
-       s  = javastring_new_from_utf_string(name);
+       s  = (java_lang_String *) javastring_new_from_utf_string(name);
        ba = (java_bytearray *) buf;
 
-       c = (jclass) Java_java_lang_VMClassLoader_defineClass(env, NULL, cl, s, ba,
-                                                                                                                 0, bufLen, NULL);
+       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
 }
 
 
@@ -1091,6 +1304,7 @@ jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
 
 jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
 {
+#if defined(ENABLE_JAVASE)
        utf       *u;
        classinfo *cc;
        classinfo *c;
@@ -1127,6 +1341,13 @@ jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
                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
 }
   
 
@@ -1161,12 +1382,15 @@ jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
 
 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 Java_java_lang_VMClass_isAssignableFrom(env,
-                                                                                                  NULL,
-                                                                                                  (java_lang_Class *) sup,
-                                                                                                  (java_lang_Class *) sub);
+       return _Jv_java_lang_Class_isAssignableFrom(csup, csub);
 }
 
 
@@ -1257,7 +1481,7 @@ void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
 
        STATISTICS(jniinvokation());
 
-       o = excetpions_get_exception();
+       o = exceptions_get_exception();
 
        if (o == NULL) {
                /* clear exception, because we are calling jit code again */
@@ -1311,7 +1535,7 @@ void _Jv_JNI_FatalError(JNIEnv *env, const char *msg)
 
        /* this seems to be the best way */
 
-       vm_abort(msg);
+       vm_abort("JNI Fatal error: %s", msg);
 }
 
 
@@ -1549,8 +1773,6 @@ jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
 {
        localref_table *lrt;
 
-       log_text("JNI-Call: EnsureLocalCapacity");
-
        STATISTICS(jniinvokation());
 
        /* get local reference table (thread specific) */
@@ -1731,12 +1953,15 @@ jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
 
 jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
 {
+       java_lang_Class  *c;
+       java_lang_Object *o;
+
        STATISTICS(jniinvokation());
 
-       return Java_java_lang_VMClass_isInstance(env,
-                                                                                        NULL,
-                                                                                        (java_lang_Class *) clazz,
-                                                                                        (java_lang_Object *) obj);
+       c = (java_lang_Class *) clazz;
+       o = (java_lang_Object *) obj;
+
+       return _Jv_java_lang_Class_isInstance(c, o);
 }
 
 
@@ -1751,6 +1976,7 @@ jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
   
 jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
 {
+#if defined(ENABLE_JAVASE)
        methodinfo *mi;
        classinfo  *c;
        s4          slot;
@@ -1780,6 +2006,13 @@ jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
        mi = &(c->methods[slot]);
 
        return (jmethodID) mi;
+#else
+       vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
+
+       /* keep compiler happy */
+
+       return NULL;
+#endif
 }
 
 
@@ -1791,6 +2024,7 @@ jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
  
 jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
 {
+#if defined(ENABLE_JAVASE)
        java_lang_reflect_Field *rf;
        classinfo               *c;
        fieldinfo               *f;
@@ -1807,6 +2041,13 @@ jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
        f = &(c->fields[rf->slot]);
 
        return (jfieldID) f;
+#else
+       vm_abort("_Jv_JNI_FromReflectedField: not implemented in this configuration");
+
+       /* keep compiler happy */
+
+       return NULL;
+#endif
 }
 
 
@@ -3224,9 +3465,14 @@ jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz,
 jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz,
                                                                                  jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticBooleanMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jboolean    b;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
+
+       return b;
 }
 
 
@@ -3264,9 +3510,14 @@ jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz,
 jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz,
                                                                        jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticByteMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jbyte       b;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
+
+       return b;
 }
 
 
@@ -3304,9 +3555,14 @@ jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz,
 jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz,
                                                                        jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticCharMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jchar       c;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       c = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
+
+       return c;
 }
 
 
@@ -3344,9 +3600,14 @@ jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz,
 jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz,
                                                                          jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticShortMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jshort      s;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       s = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
+
+       return s;
 }
 
 
@@ -3384,9 +3645,14 @@ jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz,
 jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz,
                                                                  jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticIntMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jint        i;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       i = _Jv_jni_CallIntMethodA(NULL, NULL, m, args);
+
+       return i;
 }
 
 
@@ -3424,9 +3690,14 @@ jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz,
 jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz,
                                                                        jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticLongMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jlong       l;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       l = _Jv_jni_CallLongMethodA(NULL, NULL, m, args);
+
+       return l;
 }
 
 
@@ -3465,9 +3736,14 @@ jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz,
 jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz,
                                                                          jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticFloatMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jfloat      f;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       f = _Jv_jni_CallFloatMethodA(NULL, NULL, m, args);
+
+       return f;
 }
 
 
@@ -3505,9 +3781,14 @@ jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz,
 jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz,
                                                                                jmethodID methodID, jvalue *args)
 {
-       log_text("JNI-Call: CallStaticDoubleMethodA: IMPLEMENT ME!");
+       methodinfo *m;
+       jdouble     d;
 
-       return 0;
+       m = (methodinfo *) methodID;
+
+       d = _Jv_jni_CallDoubleMethodA(NULL, NULL, m, args);
+
+       return d;
 }
 
 
@@ -4024,7 +4305,7 @@ u2 *javastring_tou2(jstring so)
 /* GetStringChars **************************************************************
 
    Returns a pointer to the array of Unicode characters of the
-   string. This pointer is valid until ReleaseStringchars() is called.
+   string. This pointer is valid until ReleaseStringChars() is called.
 
 *******************************************************************************/
 
@@ -4071,7 +4352,8 @@ void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
 
 /* 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.
 
 *******************************************************************************/
 
@@ -4081,7 +4363,7 @@ jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
 
        STATISTICS(jniinvokation());
 
-       s = javastring_safe_new_from_utf8(bytes);
+       s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
 
     return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s);
 }
@@ -4120,7 +4402,7 @@ const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string,
        if (isCopy)
                *isCopy = JNI_TRUE;
        
-       u = javastring_toutf((java_lang_String *) string, false);
+       u = javastring_toutf((java_objectheader *) string, false);
 
        if (u != NULL)
                return u->text;
@@ -4241,10 +4523,8 @@ void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
        /* check if the class of value is a subclass of the element class
           of the array */
 
-       if (!builtin_canstore(oa, o)) {
-               exceptions_throw_arraystoreexception();
+       if (!builtin_canstore(oa, o))
                return;
-       }
 
        oa->data[index] = val;
 }
@@ -5412,24 +5692,25 @@ jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
 
 jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
 {
+#if defined(ENABLE_JAVASE)
        java_objectheader       *nbuf;
-#if SIZEOF_VOID_P == 8
+# if SIZEOF_VOID_P == 8
        gnu_classpath_Pointer64 *paddress;
-#else
+# else
        gnu_classpath_Pointer32 *paddress;
-#endif
+# endif
 
        STATISTICS(jniinvokation());
 
        /* alocate a gnu.classpath.Pointer{32,64} object */
 
-#if SIZEOF_VOID_P == 8
+# if SIZEOF_VOID_P == 8
        if (!(paddress = (gnu_classpath_Pointer64 *)
                  builtin_new(class_gnu_classpath_Pointer64)))
-#else
+# else
        if (!(paddress = (gnu_classpath_Pointer32 *)
                  builtin_new(class_gnu_classpath_Pointer32)))
-#endif
+# endif
                return NULL;
 
        /* fill gnu.classpath.Pointer{32,64} with address */
@@ -5445,6 +5726,13 @@ jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
        /* 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
 }
 
 
@@ -5457,12 +5745,13 @@ jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
 
 void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 {
+#if defined(ENABLE_JAVASE)
        java_nio_DirectByteBufferImpl *nbuf;
-#if SIZEOF_VOID_P == 8
+# if SIZEOF_VOID_P == 8
        gnu_classpath_Pointer64       *address;
-#else
+# else
        gnu_classpath_Pointer32       *address;
-#endif
+# endif
 
        STATISTICS(jniinvokation());
 
@@ -5471,16 +5760,23 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
        nbuf = (java_nio_DirectByteBufferImpl *) buf;
 
-#if SIZEOF_VOID_P == 8
+# if SIZEOF_VOID_P == 8
        address = (gnu_classpath_Pointer64 *) nbuf->address;
-#else
+# else
        address = (gnu_classpath_Pointer32 *) nbuf->address;
-#endif
+# 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
 }
 
 
@@ -5493,6 +5789,7 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
 jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
 {
+#if defined(ENABLE_JAVASE)
        java_nio_Buffer *nbuf;
 
        STATISTICS(jniinvokation());
@@ -5503,6 +5800,13 @@ jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
        nbuf = (java_nio_Buffer *) buf;
 
        return (jlong) nbuf->cap;
+#else
+       vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
+
+       /* keep compiler happy */
+
+       return 0;
+#endif
 }