< prev index next >

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

Print this page

 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package java.lang;
 26 
 27 import java.lang.StackWalker.StackFrame;
 28 import java.util.EnumSet;
 29 import java.util.Set;


 30 
 31 import static java.lang.StackWalker.ExtendedOption.LOCALS_AND_OPERANDS;
 32 
 33 /**
 34  * <em>UNSUPPORTED</em> This interface is intended to be package-private
 35  * or move to an internal package.<p>
 36  *
 37  * {@code LiveStackFrame} represents a frame storing data and partial results.
 38  * Each frame has its own array of local variables (JVMS section 2.6.1),
 39  * its own operand stack (JVMS section 2.6.2) for a method invocation.
 40  *
 41  * @jvms 2.6 Frames
 42  */
 43 /* package-private */
 44 interface LiveStackFrame extends StackFrame {
 45     /**
 46      * Return the monitors held by this stack frame. This method returns
 47      * an empty array if no monitor is held by this stack frame.
 48      *
 49      * @return the monitors held by this stack frames

160     }
161 
162     /**
163      * Gets a {@code StackWalker} instance with the given options specifying
164      * the stack frame information it can access, and which will traverse at most
165      * the given {@code maxDepth} number of stack frames.  If no option is
166      * specified, this {@code StackWalker} obtains the method name and
167      * the class name with all
168      * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
169      * The returned {@code StackWalker} can get locals and operands.
170      *
171      * @param options stack walk {@link StackWalker.Option options}
172      *
173      * @throws SecurityException if the security manager is present and
174      * it denies access to {@code RuntimePermission("liveStackFrames")};
175      * or if the given {@code options} contains
176      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
177      * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
178      */
179     public static StackWalker getStackWalker(Set<StackWalker.Option> options) {































































180         @SuppressWarnings("removal")
181         SecurityManager sm = System.getSecurityManager();
182         if (sm != null) {
183             sm.checkPermission(new RuntimePermission("liveStackFrames"));
184         }
185         return StackWalker.newInstance(options, LOCALS_AND_OPERANDS);
186     }
187 }

 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package java.lang;
 26 
 27 import java.lang.StackWalker.StackFrame;
 28 import java.util.EnumSet;
 29 import java.util.Set;
 30 import jdk.internal.vm.Continuation;
 31 import jdk.internal.vm.ContinuationScope;
 32 
 33 import static java.lang.StackWalker.ExtendedOption.LOCALS_AND_OPERANDS;
 34 
 35 /**
 36  * <em>UNSUPPORTED</em> This interface is intended to be package-private
 37  * or move to an internal package.<p>
 38  *
 39  * {@code LiveStackFrame} represents a frame storing data and partial results.
 40  * Each frame has its own array of local variables (JVMS section 2.6.1),
 41  * its own operand stack (JVMS section 2.6.2) for a method invocation.
 42  *
 43  * @jvms 2.6 Frames
 44  */
 45 /* package-private */
 46 interface LiveStackFrame extends StackFrame {
 47     /**
 48      * Return the monitors held by this stack frame. This method returns
 49      * an empty array if no monitor is held by this stack frame.
 50      *
 51      * @return the monitors held by this stack frames

162     }
163 
164     /**
165      * Gets a {@code StackWalker} instance with the given options specifying
166      * the stack frame information it can access, and which will traverse at most
167      * the given {@code maxDepth} number of stack frames.  If no option is
168      * specified, this {@code StackWalker} obtains the method name and
169      * the class name with all
170      * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
171      * The returned {@code StackWalker} can get locals and operands.
172      *
173      * @param options stack walk {@link StackWalker.Option options}
174      *
175      * @throws SecurityException if the security manager is present and
176      * it denies access to {@code RuntimePermission("liveStackFrames")};
177      * or if the given {@code options} contains
178      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
179      * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
180      */
181     public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
182         return getStackWalker(options, null);
183     }
184 
185     /**
186      * Gets a {@code StackWalker} instance with the given options specifying
187      * the stack frame information it can access, and which will traverse at most
188      * the given {@code maxDepth} number of stack frames.  If no option is
189      * specified, this {@code StackWalker} obtains the method name and
190      * the class name with all
191      * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
192      * The returned {@code StackWalker} can get locals and operands.
193      *
194      * @param options stack walk {@link StackWalker.Option options}
195      * @param contScope the continuation scope up to which (inclusive) to walk the stack
196      *
197      * @throws SecurityException if the security manager is present and
198      * it denies access to {@code RuntimePermission("liveStackFrames")}; or
199      * or if the given {@code options} contains
200      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
201      * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
202      */
203     public static StackWalker getStackWalker(Set<StackWalker.Option> options, ContinuationScope contScope) {
204         @SuppressWarnings("removal")
205         SecurityManager sm = System.getSecurityManager();
206         if (sm != null) {
207             sm.checkPermission(new RuntimePermission("liveStackFrames"));
208         }
209         return StackWalker.newInstance(options, LOCALS_AND_OPERANDS, contScope);
210     }
211 
212     /**
213      * Gets {@code StackWalker} of the given unmounted continuation, that can get locals and operands.
214      *
215      * @param continuation the continuation to walk
216      * 
217      * @throws SecurityException if the security manager is present and
218      * denies access to {@code RuntimePermission("liveStackFrames")}
219      */
220     public static StackWalker getStackWalker(Continuation continuation) {
221         return getStackWalker(EnumSet.noneOf(StackWalker.Option.class), continuation.getScope(), continuation);
222     }
223 
224     /**
225      * Gets a {@code StackWalker} instance with the given options specifying
226      * the stack frame information it can access, and which will traverse at most
227      * the given {@code maxDepth} number of stack frames.  If no option is
228      * specified, this {@code StackWalker} obtains the method name and
229      * the class name with all
230      * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
231      * The returned {@code StackWalker} can get locals and operands.
232      *
233      * @param options stack walk {@link StackWalker.Option options}
234      * @param continuation the continuation to walk
235      *
236      * @throws SecurityException if the security manager is present and
237      * it denies access to {@code RuntimePermission("liveStackFrames")}; or
238      * or if the given {@code options} contains
239      * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
240      * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
241      */
242     public static StackWalker getStackWalker(Set<StackWalker.Option> options,
243                                              ContinuationScope contScope,
244                                              Continuation continuation) {
245         @SuppressWarnings("removal")
246         SecurityManager sm = System.getSecurityManager();
247         if (sm != null) {
248             sm.checkPermission(new RuntimePermission("liveStackFrames"));
249         }
250         return StackWalker.newInstance(options, LOCALS_AND_OPERANDS, contScope, continuation);
251     }
252 }
< prev index next >