152 */
153 public static StackWalker getStackWalker() {
154 return getStackWalker(EnumSet.noneOf(StackWalker.Option.class));
155 }
156
157 /**
158 * Gets a {@code StackWalker} instance with the given options specifying
159 * the stack frame information it can access, and which will traverse at most
160 * the given {@code maxDepth} number of stack frames. If no option is
161 * specified, this {@code StackWalker} obtains the method name and
162 * the class name with all
163 * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
164 * The returned {@code StackWalker} can get locals and operands.
165 *
166 * @param options stack walk {@link StackWalker.Option options}
167 *
168 * @throws SecurityException if the security manager is present and
169 * it denies access to {@code RuntimePermission("liveStackFrames")}; or
170 * or if the given {@code options} contains
171 * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
172 * and it denies access to {@code StackFramePermission("retainClassReference")}.
173 */
174 public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
175 SecurityManager sm = System.getSecurityManager();
176 if (sm != null) {
177 sm.checkPermission(new RuntimePermission("liveStackFrames"));
178 }
179 return StackWalker.newInstance(options, LOCALS_AND_OPERANDS);
180 }
181 }
|
152 */
153 public static StackWalker getStackWalker() {
154 return getStackWalker(EnumSet.noneOf(StackWalker.Option.class));
155 }
156
157 /**
158 * Gets a {@code StackWalker} instance with the given options specifying
159 * the stack frame information it can access, and which will traverse at most
160 * the given {@code maxDepth} number of stack frames. If no option is
161 * specified, this {@code StackWalker} obtains the method name and
162 * the class name with all
163 * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
164 * The returned {@code StackWalker} can get locals and operands.
165 *
166 * @param options stack walk {@link StackWalker.Option options}
167 *
168 * @throws SecurityException if the security manager is present and
169 * it denies access to {@code RuntimePermission("liveStackFrames")}; or
170 * or if the given {@code options} contains
171 * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
172 * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
173 */
174 public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
175 SecurityManager sm = System.getSecurityManager();
176 if (sm != null) {
177 sm.checkPermission(new RuntimePermission("liveStackFrames"));
178 }
179 return StackWalker.newInstance(options, LOCALS_AND_OPERANDS);
180 }
181 }
|