JDK-8003690 : Example code in JVMTI GetStackTrace documentation is broken
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-11-20
  • Updated: 2013-04-30
  • Resolved: 2012-11-22
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 8 Other
8Fixed hs25Fixed
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