Skip to content

Commit 87fb2fa

Browse files
committed
8315486: vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java timed out
Backport-of: 041510dc21df36d9860f4f0048241c2cabb55ee7
1 parent 4cf4fb1 commit 87fb2fa

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,34 @@ private void sendCommand(long threadID, Value value, boolean expectError, int er
139139
}
140140
}
141141

142+
// get thread ID for "startNewThread" command
143+
private long getNewThreadId() throws Exception {
144+
final String debugeeClassSig = "L" + getDebugeeClassName().replace('.', '/') + ";";
145+
log.display(" getting classID for " + debugeeClassSig);
146+
long classID = debuggee.getReferenceTypeID(debugeeClassSig);
147+
log.display(" got classID: " + classID);
148+
149+
log.display(" getting testNewThread field value");
150+
JDWP.Value value = debuggee.getStaticFieldValue(classID, "testNewThread", JDWP.Tag.THREAD);
151+
152+
long threadID = ((Long)value.getValue()).longValue();
153+
log.display(" got threadID: " + threadID);
154+
return threadID;
155+
}
156+
142157
private int createThreadStartEventRequest() {
143158
try {
159+
long newThreadId = getNewThreadId();
144160
// create command packet and fill requred out data
145161
CommandPacket command = new CommandPacket(JDWP.Command.EventRequest.Set);
146162
command.addByte(JDWP.EventKind.THREAD_START);
147163
command.addByte(JDWP.SuspendPolicy.ALL);
148-
command.addInt(0);
164+
// we want the THREAD_START event only for the test thread
165+
// and not any others that might be started by debuggee VM,
166+
// so add THREAD_ONLY modifier
167+
command.addInt(1);
168+
command.addByte(JDWP.EventModifierKind.THREAD_ONLY);
169+
command.addObjectID(newThreadId);
149170
command.setLength();
150171

151172
transport.write(command);
@@ -175,7 +196,7 @@ public void doTest() {
175196
Value value;
176197

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

181202
// create StateTestThread

test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002a.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,29 @@ public boolean parseCommand(String command) {
5151

5252
return true;
5353
} else if (command.equals(COMMAND_START_NEW_THREAD)) {
54-
Thread thread = new Thread(new Runnable() {
55-
public void run() {
56-
log.display("Thread exit");
57-
}
58-
});
59-
60-
thread.setName("forceEarlyReturn002a_NewThread");
61-
thread.start();
54+
testNewThread.start();
6255

6356
return true;
6457
}
6558

6659
return false;
6760
}
6861

62+
@Override
63+
protected void init(String args[]) {
64+
super.init(args);
65+
66+
// create thread for "NewThread" command in advance
67+
testNewThread = new Thread(new Runnable() {
68+
public void run() {
69+
log.display("Thread exit");
70+
}
71+
});
72+
testNewThread.setName("forceEarlyReturn002a_NewThread");
73+
}
74+
75+
private static Thread testNewThread;
76+
6977
private Thread testThreadInNative;
7078

7179
private void stopThreadInNative() {

0 commit comments

Comments
 (0)