X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fnative%2Fjni.cpp;h=bf1401a65938524be30623e3d156548fbdf9a221;hb=f5287d069d5089f7100420be5fdcc25755ce3011;hp=f6eb7082a502a5a70239897fd48a54549b198e89;hpb=9b8649260e47d6d771078221a1f54d9dc024b28b;p=cacao.git diff --git a/src/native/jni.cpp b/src/native/jni.cpp index f6eb7082a..bf1401a65 100644 --- a/src/native/jni.cpp +++ b/src/native/jni.cpp @@ -1,6 +1,6 @@ /* src/native/jni.cpp - implementation of the Java Native Interface functions - Copyright (C) 1996-2005, 2006, 2007, 2008, 2009 + Copyright (C) 1996-2012 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -881,8 +881,31 @@ jclass jni_FindClass(JNIEnv *env, const char *name) if (cc == NULL) c = load_class_from_sysloader(u); - else - c = load_class_from_classloader(u, cc->classloader); + else { + classloader_t *cl = cc->classloader; +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + /* See jni_FindClass in Hotspot's src/share/vm/prims/jni.cpp */ + if (!cl && cc->name == utf_java_lang_ClassLoader_NativeLibrary) + { + methodinfo *m = class_resolveclassmethod( + cc, + utf_new_char("getFromClass"), + utf_new_char("()Ljava/lang/Class;"), + NULL, + true); + + java_handle_t *h; + if (m) + h = vm_call_method(m, NULL); + + if (m && exceptions_get_exception() == NULL) + cl = ((classinfo *) LLNI_UNWRAP(h))->classloader; + else + return NULL; + } +#endif + c = load_class_from_classloader(u, cl); + } if (c == NULL) { resolve_handle_pending_exception(true); @@ -1402,9 +1425,6 @@ jclass jni_GetObjectClass(JNIEnv *env, jobject obj) o = (java_handle_t *) obj; - if ((o == NULL) || (LLNI_vftbl_direct(o) == NULL)) - return NULL; - LLNI_class_get(o, c); java_handle_t* h = LLNI_classinfo_wrap(c); @@ -2890,7 +2910,7 @@ void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array, \ } JNI_RELEASE_ARRAY_ELEMENTS(Boolean, jboolean, boolean, u1) -JNI_RELEASE_ARRAY_ELEMENTS(Byte, jbyte, byte, int8_t) +JNI_RELEASE_ARRAY_ELEMENTS(Byte, jbyte, byte, s1) JNI_RELEASE_ARRAY_ELEMENTS(Char, jchar, char, u2) JNI_RELEASE_ARRAY_ELEMENTS(Short, jshort, short, s2) JNI_RELEASE_ARRAY_ELEMENTS(Int, jint, int, s4) @@ -2921,7 +2941,7 @@ void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array, \ } JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1) -JNI_GET_ARRAY_REGION(Byte, jbyte, byte, int8_t) +JNI_GET_ARRAY_REGION(Byte, jbyte, byte, s1) JNI_GET_ARRAY_REGION(Char, jchar, char, u2) JNI_GET_ARRAY_REGION(Short, jshort, short, s2) JNI_GET_ARRAY_REGION(Int, jint, int, s4) @@ -2952,7 +2972,7 @@ void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array, \ } JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1) -JNI_SET_ARRAY_REGION(Byte, jbyte, byte, int8_t) +JNI_SET_ARRAY_REGION(Byte, jbyte, byte, s1) JNI_SET_ARRAY_REGION(Char, jchar, char, u2) JNI_SET_ARRAY_REGION(Short, jshort, short, s2) JNI_SET_ARRAY_REGION(Int, jint, int, s4) @@ -2979,14 +2999,10 @@ jint jni_RegisterNatives(JNIEnv* env, jclass clazz, const JNINativeMethod* metho classinfo* c = LLNI_classinfo_unwrap(clazz); - /* XXX: if implemented this needs a call to jvmti_NativeMethodBind - if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr); - */ - NativeMethods& nm = VM::get_current()->get_nativemethods(); nm.register_methods(c->name, methods, nMethods); - return 0; + return 0; } @@ -3569,7 +3585,8 @@ void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf) { -#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf)); java_handle_t* h = (java_handle_t *) buf; @@ -3581,6 +3598,23 @@ jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf) jlong capacity = b.get_cap(); return capacity; +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf)); + + java_nio_Buffer jnb(buf); + + if (!builtin_instanceof(jnb.get_handle(), class_sun_nio_ch_DirectBuffer)) + return -1; + + jlong capacity = jnb.get_capacity(); + + return capacity; + +# else +# error unknown classpath configuration +# endif + #else vm_abort("jni_GetDirectBufferCapacity: not implemented in this configuration");