mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8284161: Implementation of Virtual Threads (Preview)
Co-authored-by: Ron Pressler <rpressler@openjdk.org> Co-authored-by: Alan Bateman <alanb@openjdk.org> Co-authored-by: Erik Österlund <eosterlund@openjdk.org> Co-authored-by: Andrew Haley <aph@openjdk.org> Co-authored-by: Rickard Bäckman <rbackman@openjdk.org> Co-authored-by: Markus Grönlund <mgronlun@openjdk.org> Co-authored-by: Leonid Mesnik <lmesnik@openjdk.org> Co-authored-by: Serguei Spitsyn <sspitsyn@openjdk.org> Co-authored-by: Chris Plummer <cjplummer@openjdk.org> Co-authored-by: Coleen Phillimore <coleenp@openjdk.org> Co-authored-by: Robbin Ehn <rehn@openjdk.org> Co-authored-by: Stefan Karlsson <stefank@openjdk.org> Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org> Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org> Reviewed-by: lancea, eosterlund, rehn, sspitsyn, stefank, tschatzl, dfuchs, lmesnik, dcubed, kevinw, amenkov, dlong, mchung, psandoz, bpb, coleenp, smarks, egahlin, mseledtsov, coffeys, darcy
This commit is contained in:
parent
5212535a27
commit
9583e3657e
1133 changed files with 95935 additions and 8335 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,6 +27,8 @@ 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;
|
||||
|
||||
|
@ -177,11 +179,74 @@ interface LiveStackFrame extends StackFrame {
|
|||
* 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);
|
||||
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, contScope, continuation);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue