Skip to content
Open
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
23 changes: 16 additions & 7 deletions test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill003/kill003.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class kill003 extends JdbTest {
public static void main (String argv[]) {
debuggeeClass = DEBUGGEE_CLASS;
firstBreak = FIRST_BREAK;
compoundPromptIdent = COMPOUND_PROMPT_IDENT;
new kill003().runTest(argv);
}

Expand All @@ -65,6 +66,7 @@ public static void main (String argv[]) {
static final String MYTHREAD = "MyThread";
static final String DEBUGGEE_THREAD = PACKAGE_NAME + "." + MYTHREAD;
static final String DEBUGGEE_EXCEPTION = DEBUGGEE_CLASS + ".exception";
static final String COMPOUND_PROMPT_IDENT = "main";

protected void runCases() {
String[] reply;
Expand All @@ -74,7 +76,10 @@ protected void runCases() {
// after creating all the threads. Get the list of debuggee threads.
threads = jdb.getThreadIdsByName("main");

// Stopped at kill.main, so step into synchronized block
// Make sure we stop in jdb when the NPE is thrown or rethrown.
reply = jdb.receiveReplyFor(JdbCommand._catch + "all java.lang.NullPointerException");

// Stopped at kill003a.main(), so step into synchronized block
reply = jdb.receiveReplyFor(JdbCommand.next);

if (threads.length != 1) {
Expand All @@ -83,24 +88,28 @@ protected void runCases() {
success = false;
}

// Execution is at a bytecode that is not expected to handle an async exception. Throw one here
// to make sure it gets handled without crashing. The exception will be delivered at the next
// bytecode that can handle the async exception.
// Execution is at a bytecode that is not expected to handle an async exception.
// Throw one here to make sure it gets handled without crashing. The exception
// will be delivered at the next bytecode that can handle the async exception.
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.kill + threads[0] + " " + DEBUGGEE_EXCEPTION,
"killed");

// Continue the debuggee - the async exception will be delivered to the debuggee.
reply = jdb.receiveReplyFor(JdbCommand.cont);

// Ask the debuggee for its local variables at the bytecode where the async exception was delivered, which
// should be reachable.
// jdb got notified of the NPE for the kill command. continue and jdb will get
// notified again when it is rethrown from the synchronized block's implicit
// exception handler, which is where we want to execute the locals command from.
reply = jdb.receiveReplyFor(JdbCommand.cont);

// Ask the debuggee for its local variables at the bytecode where the async
// exception was rethrown, which should be reachable.
reply = jdb.receiveReplyForWithMessageWait(JdbCommand.locals, "Local variables");

if (jdb.terminated()) {
throw new Failure("Debuggee exited");
}

// The lack of exception handler in the debuggee should cause it to exit when continued.
jdb.contToExit(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public class kill003a {
static NullPointerException exception = new NullPointerException();

public static void main(String args[]) {
synchronized (args) {
try {
synchronized (args) {
}
} catch (NullPointerException npe) {
}
System.out.println("done");
System.exit(JdbTest.JCK_STATUS_BASE);
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Jdb.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2026, 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
Expand Down Expand Up @@ -530,7 +530,7 @@ public int waitForMessage(int startPos, String message) {
return found;
}

// spleep for awhile
// sleep for awhile
synchronized(dummy) {
try {
dummy.wait(delta);
Expand Down Expand Up @@ -614,7 +614,7 @@ int findPrompt(StringBuffer lines, boolean compoundPromptOnly, int startPos) {
searching:
for (int pos = startPos; pos < length; ) {

// skip each simbol not suitable for prompt begin
// skip each symbol not suitable for prompt begin
if (!Character.isLetterOrDigit(lines.charAt(pos))) {
pos++;
continue searching;
Expand Down