United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6893483 DTrace probe return values for a couple JNI methods are wrong
JDK-6893483 : DTrace probe return values for a couple JNI methods are wrong

Details
Type:
Bug
Submit Date:
2009-10-20
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2009-11-11
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
hs18
Fixed Versions:
hs17 (b05)

Related Reports
Backport:
Backport:

Sub Tasks

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
                                     
2009-10-22



Hardware and Software, Engineered to Work Together