< prev index next >

hotspot/src/share/vm/prims/stackwalk.cpp

Print this page

        

@@ -111,11 +111,14 @@
   for (; !stream.at_end(); stream.next()) {
     Method* method = stream.method();
     int bci = stream.bci();
 
     if (method == NULL) continue;
-    if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) {
+
+    // skip hidden frames for default StackWalker option (i.e. SHOW_HIDDEN_FRAMES
+    // not set) and when StackWalker::getCallerClass is called
+    if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) {
       if (method->is_hidden()) {
         if (TraceStackWalk) {
           tty->print("  hidden method: "); method->print_short_name();
           tty->print("\n");
         }

@@ -137,11 +140,17 @@
     } else if (need_method_info(mode)) {
       assert (use_frames_array(mode), "Bad mode for get stack frame");
       Handle stackFrame(frames_array->obj_at(index));
       fill_stackframe(stackFrame, method, bci);
     } else {
-      assert (use_frames_array(mode) == false, "Bad mode for get caller class");
+      assert (get_caller_class(mode) == true, "Bad mode for get caller class");
+      if (index == start_index && method->caller_sensitive()) {
+        THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), 
+          err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
+                  method->name_and_sig_as_C_string()));
+      }
+
       frames_array->obj_at_put(index, method->method_holder()->java_mirror());
     }
     if (++frames_decoded >= max_nframes)  break;
   }
   return frames_decoded;
< prev index next >