United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-8003690 Example code in JVMTI GetStackTrace documentation is broken
JDK-8003690 : Example code in JVMTI GetStackTrace documentation is broken

Details
Type:
Bug
Submit Date:
2012-11-20
Status:
Resolved
Updated Date:
2013-04-30
Project Name:
JDK
Resolved Date:
2012-11-22
Component:
hotspot
OS:
Sub-Component:
svc
CPU:
Priority:
P4
Resolution:
Fixed
Affected Versions:
Fixed Versions:
hs25 (b11)

Related Reports
Backport:

Sub Tasks

Description
In the JVMTI documentation for GetStackTrace there is a code snippet outlining how to use the functionality:

jvmtiFrameInfo frames[5];
jint count;
jvmtiError err;

err = (*jvmti)->GetStackTrace(jvmti, aThread, 0, 5, 
                               &frames, &count);
if (err == JVMTI_ERROR_NONE && count >= 1) {
   char *methodName;
   err = (*jvmti)->GetMethodName(jvmti, frames[0].method, 
                       &methodName, NULL);
   if (err == JVMTI_ERROR_NONE) {
      printf("Executing method: %s", methodName);
   }
}

There are two errors in the code:

1. The 5th argument to GetStackTrace (frames) should not have an ampersand
2. GetMethodName takes 5 parameters, but the example only passes four parameters to it
                                    

Comments
URL:   http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/73e64867adb7
User:  dholmes
Date:  2012-11-22 02:23:54 +0000

                                     
2012-11-22
URL:   http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/73e64867adb7
User:  amurillo
Date:  2012-12-01 02:59:09 +0000

                                     
2012-12-01



Hardware and Software, Engineered to Work Together