JDK-6893483 : DTrace probe return values for a couple JNI methods are wrong
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs18
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-10-20
  • Updated: 2012-10-08
  • Resolved: 2009-11-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u21Fixed 7Fixed hs17Fixed
Description
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.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/08780c8a9f04
22-10-2009