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 $
*/
#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"
/* 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 ******************************************************/
hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE);
+#if defined(ENABLE_JAVASE)
/* direct buffer stuff */
if (!(class_java_nio_Buffer =
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;
}
}
-/* _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.
}
+/* _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.
}
+/* _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.
}
+/* _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.
*******************************************************************************/
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__)
java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
java_objectarray *params)
{
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:
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 ******************************************************************
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;
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
}
jclass _Jv_JNI_FindClass(JNIEnv *env, const char *name)
{
+#if defined(ENABLE_JAVASE)
utf *u;
classinfo *cc;
classinfo *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
}
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);
}
STATISTICS(jniinvokation());
- o = excetpions_get_exception();
+ o = exceptions_get_exception();
if (o == NULL) {
/* clear exception, because we are calling jit code again */
/* this seems to be the best way */
- vm_abort(msg);
+ vm_abort("JNI Fatal error: %s", msg);
}
{
localref_table *lrt;
- log_text("JNI-Call: EnsureLocalCapacity");
-
STATISTICS(jniinvokation());
/* get local reference table (thread specific) */
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);
}
jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
{
+#if defined(ENABLE_JAVASE)
methodinfo *mi;
classinfo *c;
s4 slot;
mi = &(c->methods[slot]);
return (jmethodID) mi;
+#else
+ vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
+
+ /* keep compiler happy */
+
+ return NULL;
+#endif
}
jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
{
+#if defined(ENABLE_JAVASE)
java_lang_reflect_Field *rf;
classinfo *c;
fieldinfo *f;
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
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
/* 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.
*******************************************************************************/
/* 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.
*******************************************************************************/
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);
}
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;
/* 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;
}
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 */
/* 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
}
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());
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
}
jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
{
+#if defined(ENABLE_JAVASE)
java_nio_Buffer *nbuf;
STATISTICS(jniinvokation());
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
}