X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libjava%2Fjni.cc;h=86a4dc5b2610738b6f5cc65124240564ef7df1c2;hb=7ab483efddd3684078a9353c747b5c5e56464d20;hp=8660753ee9b31f7f631121b4b8eaea9c3fbcd734;hpb=6e29f747fdc59495bec2506c276951c1ea7e02e0;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libjava/jni.cc b/libjava/jni.cc index 8660753ee9b..86a4dc5b261 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -1,6 +1,6 @@ // jni.cc - JNI implementation, including the jump table. -/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 +/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation This file is part of libgcj. @@ -70,8 +70,8 @@ enum invocation_type }; // Forward declarations. -extern struct JNINativeInterface _Jv_JNIFunctions; -extern struct JNIInvokeInterface _Jv_JNI_InvokeFunctions; +extern struct JNINativeInterface_ _Jv_JNIFunctions; +extern struct JNIInvokeInterface_ _Jv_JNI_InvokeFunctions; // Number of slots in the default frame. The VM must allow at least // 16. @@ -873,7 +873,7 @@ _Jv_JNI_CallAnyMethod (JNIEnv *env, jobject obj, jclass klass, template static T JNICALL _Jv_JNI_CallAnyMethodA (JNIEnv *env, jobject obj, jclass klass, - jmethodID id, jvalue *args) + jmethodID id, const jvalue *args) { obj = unwrap (obj); klass = unwrap (klass); @@ -970,7 +970,7 @@ _Jv_JNI_CallAnyVoidMethod (JNIEnv *env, jobject obj, jclass klass, template static void JNICALL _Jv_JNI_CallAnyVoidMethodA (JNIEnv *env, jobject obj, jclass klass, - jmethodID id, jvalue *args) + jmethodID id, const jvalue *args) { jclass decl_class = klass ? klass : obj->getClass (); JvAssert (decl_class != NULL); @@ -1035,7 +1035,7 @@ _Jv_JNI_CallMethod (JNIEnv *env, jobject obj, jmethodID id, ...) template static T JNICALL _Jv_JNI_CallMethodA (JNIEnv *env, jobject obj, - jmethodID id, jvalue *args) + jmethodID id, const jvalue *args) { return _Jv_JNI_CallAnyMethodA (env, obj, NULL, id, args); } @@ -1059,7 +1059,7 @@ _Jv_JNI_CallVoidMethod (JNIEnv *env, jobject obj, jmethodID id, ...) static void JNICALL _Jv_JNI_CallVoidMethodA (JNIEnv *env, jobject obj, - jmethodID id, jvalue *args) + jmethodID id, const jvalue *args) { _Jv_JNI_CallAnyVoidMethodA (env, obj, NULL, id, args); } @@ -1103,7 +1103,7 @@ _Jv_JNI_CallStaticMethod (JNIEnv *env, jclass klass, template static T JNICALL _Jv_JNI_CallStaticMethodA (JNIEnv *env, jclass klass, jmethodID id, - jvalue *args) + const jvalue *args) { JvAssert (((id->accflags) & java::lang::reflect::Modifier::STATIC)); JvAssert (java::lang::Class::class$.isInstance (unwrap (klass))); @@ -1131,7 +1131,7 @@ _Jv_JNI_CallStaticVoidMethod (JNIEnv *env, jclass klass, static void JNICALL _Jv_JNI_CallStaticVoidMethodA (JNIEnv *env, jclass klass, - jmethodID id, jvalue *args) + jmethodID id, const jvalue *args) { _Jv_JNI_CallAnyVoidMethodA (env, NULL, klass, id, args); } @@ -1174,7 +1174,7 @@ _Jv_JNI_NewObject (JNIEnv *env, jclass klass, jmethodID id, ...) static jobject JNICALL _Jv_JNI_NewObjectA (JNIEnv *env, jclass klass, jmethodID id, - jvalue *args) + const jvalue *args) { JvAssert (klass && ! klass->isArray ()); JvAssert (! strcmp (id->name->chars(), "") @@ -1332,6 +1332,9 @@ _Jv_JNI_NewStringUTF (JNIEnv *env, const char *bytes) { try { + // For compatibility with the JDK. + if (!bytes) + return NULL; jstring result = JvNewStringUTF (bytes); return (jstring) wrap_value (env, result); } @@ -1577,7 +1580,7 @@ _Jv_JNI_GetPrimitiveArrayRegion (JNIEnv *env, JArray *array, template static void JNICALL _Jv_JNI_SetPrimitiveArrayRegion (JNIEnv *env, JArray *array, - jsize start, jsize len, T *buf) + jsize start, jsize len, const T *buf) { array = unwrap (array); if (! _Jv_JNI_check_types (env, array, K)) @@ -1802,6 +1805,13 @@ _Jv_JNI_GetDirectBufferCapacity (JNIEnv *, jobject buffer) return tmp->capacity(); } +static jobjectRefType JNICALL +_Jv_JNI_GetObjectRefType (JNIEnv *, MAYBE_UNUSED jobject object) +{ + JvFail("GetObjectRefType not implemented"); + return JNIInvalidRefType; +} + struct NativeMethodCacheEntry : public JNINativeMethod @@ -2108,7 +2118,7 @@ _Jv_GetJNIEnvNewFrameWithLoader (::java::lang::ClassLoader *loader) if (__builtin_expect (env == NULL, false)) { env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv)); - env->p = &_Jv_JNIFunctions; + env->functions = &_Jv_JNIFunctions; env->locals = NULL; // We set env->ex below. @@ -2293,7 +2303,8 @@ _Jv_LookupJNIMethod (jclass klass, _Jv_Utf8Const *name, // This function is the stub which is used to turn an ordinary (CNI) // method call into a JNI call. void -_Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this) +_Jv_JNIMethod::call (ffi_cif *, void *ret, INTERP_FFI_RAW_TYPE *args, + void *__this) { _Jv_JNIMethod* _this = (_Jv_JNIMethod *) __this; @@ -2325,8 +2336,9 @@ _Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this) } } - JvAssert (_this->args_raw_size % sizeof (ffi_raw) == 0); - ffi_raw real_args[2 + _this->args_raw_size / sizeof (ffi_raw)]; + JvAssert (_this->args_raw_size % sizeof (INTERP_FFI_RAW_TYPE) == 0); + INTERP_FFI_RAW_TYPE + real_args[2 + _this->args_raw_size / sizeof (INTERP_FFI_RAW_TYPE)]; int offset = 0; // First argument is always the environment pointer. @@ -2416,7 +2428,7 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv)); if (env == NULL) return JNI_ERR; - env->p = &_Jv_JNIFunctions; + env->functions = &_Jv_JNIFunctions; env->ex = NULL; env->bottom_locals = (_Jv_JNI_LocalFrame *) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame) @@ -2593,7 +2605,7 @@ _Jv_JNI_GetJavaVM (JNIEnv *, JavaVM **vm) #define RESERVED NULL -struct JNINativeInterface _Jv_JNIFunctions = +struct JNINativeInterface_ _Jv_JNIFunctions = { RESERVED, RESERVED, @@ -2873,10 +2885,12 @@ struct JNINativeInterface _Jv_JNIFunctions = _Jv_JNI_NewDirectByteBuffer, // NewDirectByteBuffer _Jv_JNI_GetDirectBufferAddress, // GetDirectBufferAddress - _Jv_JNI_GetDirectBufferCapacity // GetDirectBufferCapacity + _Jv_JNI_GetDirectBufferCapacity, // GetDirectBufferCapacity + + _Jv_JNI_GetObjectRefType // GetObjectRefType }; -struct JNIInvokeInterface _Jv_JNI_InvokeFunctions = +struct JNIInvokeInterface_ _Jv_JNI_InvokeFunctions = { RESERVED, RESERVED,