Skip to content

Commit

Permalink
8315486: vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEa…
Browse files Browse the repository at this point in the history
…rlyReturn002/forceEarlyReturn002.java timed out

Reviewed-by: cjplummer, lmesnik
  • Loading branch information
Alex Menkov committed Sep 21, 2023
1 parent ef49e6c commit 041510d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,34 @@ private void sendCommand(long threadID, Value value, boolean expectError, int er
}
}

// get thread ID for "startNewThread" command
private long getNewThreadId() throws Exception {
final String debugeeClassSig = "L" + getDebugeeClassName().replace('.', '/') + ";";
log.display(" getting classID for " + debugeeClassSig);
long classID = debuggee.getReferenceTypeID(debugeeClassSig);
log.display(" got classID: " + classID);

log.display(" getting testNewThread field value");
JDWP.Value value = debuggee.getStaticFieldValue(classID, "testNewThread", JDWP.Tag.THREAD);

long threadID = ((Long)value.getValue()).longValue();
log.display(" got threadID: " + threadID);
return threadID;
}

private int createThreadStartEventRequest() {
try {
long newThreadId = getNewThreadId();
// create command packet and fill requred out data
CommandPacket command = new CommandPacket(JDWP.Command.EventRequest.Set);
command.addByte(JDWP.EventKind.THREAD_START);
command.addByte(JDWP.SuspendPolicy.ALL);
command.addInt(0);
// we want the THREAD_START event only for the test thread
// and not any others that might be started by debuggee VM,
// so add THREAD_ONLY modifier
command.addInt(1);
command.addByte(JDWP.EventModifierKind.THREAD_ONLY);
command.addObjectID(newThreadId);
command.setLength();

transport.write(command);
Expand Down Expand Up @@ -175,7 +196,7 @@ public void doTest() {
Value value;

value = new Value(JDWP.Tag.INT, 0);
// create command with invalid trheadID, expect INVALID_OBJECT error
// create command with invalid threadID, expect INVALID_OBJECT error
sendCommand(-1, value, true, JDWP.Error.INVALID_OBJECT);

// create StateTestThread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,29 @@ public boolean parseCommand(String command) {

return true;
} else if (command.equals(COMMAND_START_NEW_THREAD)) {
Thread thread = new Thread(new Runnable() {
public void run() {
log.display("Thread exit");
}
});

thread.setName("forceEarlyReturn002a_NewThread");
thread.start();
testNewThread.start();

return true;
}

return false;
}

@Override
protected void init(String args[]) {
super.init(args);

// create thread for "NewThread" command in advance
testNewThread = new Thread(new Runnable() {
public void run() {
log.display("Thread exit");
}
});
testNewThread.setName("forceEarlyReturn002a_NewThread");
}

private static Thread testNewThread;

private Thread testThreadInNative;

private void stopThreadInNative() {
Expand Down

1 comment on commit 041510d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.