From Mark Wielaard (###@###.###): In jni.cpp the DT_RETURN_MARK for GetObjectArrayElement tries to capture the jobject ret value. But the actual ret value returned is a newly defined jobject ret in the local scope of the if (is_within_bounds) branch. This means when probing the return of GetObjectArrayElement the return value always comes as as NULL. The following trivial patch fixes the issue and makes the actual return value available to the return probe. diff -r 6ddec5389232 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Fri Oct 02 11:26:25 2009 -0700 +++ b/src/share/vm/prims/jni.cpp Mon Oct 19 21:10:11 2009 +0200 @@ -2116,7 +2116,7 @@ DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); if (a->is_within_bounds(index)) { - jobject ret = JNIHandles::make_local(env, a->obj_at(index)); + ret = JNIHandles::make_local(env, a->obj_at(index)); return ret; } else { char buf[jintAsStringSize]; ... and ... In jni.cpp the DEFINE_NEWSCALARARRAY macro uses DT_RETURN_MARK_DECL_FOR instead of the normal DT_RETURN_MARK_DECL. The DT_RETURN_MARK_DECL_FOR macro should only be used for mark probes that could return a primitive jfloat or jdouble. But DEFINE_NEWSCALARARRAY creates the functions for New<Type>Array which return primitiveTypeArrays. This means that for NewFloatArray and NewDoubleArray you cannot get the return value in the return mark probe. According to hotspot_jni.d the intention is to return these values in those cases: probe NewDoubleArray__entry(void*, uintptr_t); probe NewDoubleArray__return(void*); probe NewFloatArray__entry(void*, uintptr_t); probe NewFloatArray__return(void*); The attached trivial patch fixes it and makes the actual return value in those cases available.
|