< prev index next >

src/java.base/share/classes/java/lang/LiveStackFrame.java

Print this page
@@ -25,10 +25,12 @@
  package java.lang;
  
  import java.lang.StackWalker.StackFrame;
  import java.util.EnumSet;
  import java.util.Set;
+ import jdk.internal.vm.Continuation;
+ import jdk.internal.vm.ContinuationScope;
  
  import static java.lang.StackWalker.ExtendedOption.LOCALS_AND_OPERANDS;
  
  /**
   * <em>UNSUPPORTED</em> This interface is intended to be package-private

@@ -175,13 +177,76 @@
       * or if the given {@code options} contains
       * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
       * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
       */
      public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
+         return getStackWalker(options, null);
+     }
+ 
+     /**
+      * Gets a {@code StackWalker} instance with the given options specifying
+      * the stack frame information it can access, and which will traverse at most
+      * the given {@code maxDepth} number of stack frames.  If no option is
+      * specified, this {@code StackWalker} obtains the method name and
+      * the class name with all
+      * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
+      * The returned {@code StackWalker} can get locals and operands.
+      *
+      * @param options stack walk {@link StackWalker.Option options}
+      * @param contScope the continuation scope up to which (inclusive) to walk the stack
+      *
+      * @throws SecurityException if the security manager is present and
+      * it denies access to {@code RuntimePermission("liveStackFrames")}; or
+      * or if the given {@code options} contains
+      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
+      * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
+      */
+     public static StackWalker getStackWalker(Set<StackWalker.Option> options, ContinuationScope contScope) {
+         @SuppressWarnings("removal")
+         SecurityManager sm = System.getSecurityManager();
+         if (sm != null) {
+             sm.checkPermission(new RuntimePermission("liveStackFrames"));
+         }
+         return StackWalker.newInstance(options, LOCALS_AND_OPERANDS, contScope);
+     }
+ 
+     /**
+      * Gets {@code StackWalker} of the given unmounted continuation, that can get locals and operands.
+      *
+      * @param continuation the continuation to walk
+      * 
+      * @throws SecurityException if the security manager is present and
+      * denies access to {@code RuntimePermission("liveStackFrames")}
+      */
+     public static StackWalker getStackWalker(Continuation continuation) {
+         return getStackWalker(EnumSet.noneOf(StackWalker.Option.class), continuation.getScope(), continuation);
+     }
+ 
+     /**
+      * Gets a {@code StackWalker} instance with the given options specifying
+      * the stack frame information it can access, and which will traverse at most
+      * the given {@code maxDepth} number of stack frames.  If no option is
+      * specified, this {@code StackWalker} obtains the method name and
+      * the class name with all
+      * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
+      * The returned {@code StackWalker} can get locals and operands.
+      *
+      * @param options stack walk {@link StackWalker.Option options}
+      * @param continuation the continuation to walk
+      *
+      * @throws SecurityException if the security manager is present and
+      * it denies access to {@code RuntimePermission("liveStackFrames")}; or
+      * or if the given {@code options} contains
+      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
+      * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
+      */
+     public static StackWalker getStackWalker(Set<StackWalker.Option> options,
+                                              ContinuationScope contScope,
+                                              Continuation continuation) {
          @SuppressWarnings("removal")
          SecurityManager sm = System.getSecurityManager();
          if (sm != null) {
              sm.checkPermission(new RuntimePermission("liveStackFrames"));
          }
-         return StackWalker.newInstance(options, LOCALS_AND_OPERANDS);
+         return StackWalker.newInstance(options, LOCALS_AND_OPERANDS, contScope, continuation);
      }
  }
< prev index next >