Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackWalker updates for Java 22 #18145

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,20 @@
import java.lang.StackWalker.StackFrame;
import java.lang.StackWalker.StackFrameImpl;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static java.lang.StackWalker.Option.*;

/**
* Prints the stack trace of Pinned Thread that is attempting to yield.
* Prints the stack trace of a pinned thread that is attempting to yield.
*/
final class PinnedThreadPrinter {
private static final StackWalker STACKWALKER;

static {
STACKWALKER = StackWalker.getInstance(Set.of(SHOW_REFLECT_FRAMES, RETAIN_CLASS_REFERENCE));
STACKWALKER.setGetMonitorsFlag();
}
private static final StackWalker STACKWALKER = StackWalker.newInstanceWithMonitors();

static void printStackTrace(PrintStream out, boolean printAll) {
out.println(Thread.currentThread());
List<StackFrame> stackFrames = STACKWALKER.walk(s -> s.collect(Collectors.toList()));
for (int i = 0; i < stackFrames.size(); i++) {
StackFrameImpl sti = (StackFrameImpl)stackFrames.get(i);
StackFrameImpl sti = (StackFrameImpl) stackFrames.get(i);
Object[] monitors = sti.getMonitors();

if (monitors != null) {
Expand Down
Loading