Skip to content

Commit a390d9b

Browse files
committed
8303773: Replace "main.wrapper" with "test.thread.factory" property in test code
Reviewed-by: cjplummer, amenkov
1 parent b14cd8c commit a390d9b

File tree

21 files changed

+62
-63
lines changed

21 files changed

+62
-63
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jdb/monitor/monitor001/monitor001.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -152,7 +152,7 @@ private boolean checkCommands(String[] reply) {
152152

153153
// check 'threads', searching for "java.lang.Thread" followed by the main thread name.
154154
v.add("java.lang.Thread");
155-
if (System.getProperty("main.wrapper") != null) {
155+
if (System.getProperty("test.thread.factory") != null) {
156156
v.add(nsk.share.MainWrapper.OLD_MAIN_THREAD_NAME);
157157
} else {
158158
v.add("main");

test/hotspot/jtreg/vmTestbase/nsk/jdb/threads/threads003/threads003.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -90,7 +90,7 @@ protected void runCases() {
9090
int count;
9191
Vector v;
9292
String[] threads;
93-
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
93+
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
9494

9595
if (!vthreadMode) {
9696
// This test is only meant to be run in vthread mode.

test/hotspot/jtreg/vmTestbase/nsk/jdb/unmonitor/unmonitor001/unmonitor001.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -186,7 +186,7 @@ private boolean checkCommands(String[] reply) {
186186

187187
// check 'threads', searching for "java.lang.Thread" followed by the main thread name.
188188
v.add("java.lang.Thread");
189-
if (System.getProperty("main.wrapper") != null) {
189+
if (System.getProperty("test.thread.factory") != null) {
190190
v.add(nsk.share.MainWrapper.OLD_MAIN_THREAD_NAME);
191191
} else {
192192
v.add("main");

test/hotspot/jtreg/vmTestbase/nsk/jdi/StackFrame/_bounds_/bounds002.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -191,7 +191,7 @@ private void execTest() {
191191
complain("Unexpected " + e);
192192
exitStatus = Consts.TEST_FAILED;
193193
}
194-
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
194+
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
195195
display("vthreadMode: " + vthreadMode + ", isTopmostFrame: " + isTopmostFrame);
196196
try {
197197
stackFrame.setValue(var, null);

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadGroupReference/threads/threads001.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -134,8 +134,8 @@ private static void log3(String message) {
134134
private int runThis (String argv[], PrintStream out) {
135135

136136
Debugee debuggee;
137-
boolean usingWrapper = System.getProperty("main.wrapper") != null;
138-
boolean usingVThreadWrapper = "Virtual".equals(System.getProperty("main.wrapper"));
137+
boolean usingTTF = System.getProperty("test.thread.factory") != null;
138+
boolean usingVirtualTTF = "Virtual".equals(System.getProperty("test.thread.factory"));
139139

140140
argsHandler = new ArgumentHandler(argv);
141141
logHandler = new Log(out, argsHandler);
@@ -253,10 +253,10 @@ private int runThis (String argv[], PrintStream out) {
253253
* the "VirtualThreads" ThreadGroup, and threfore do not show up in group1.
254254
*/
255255
int expectedNumThreads;
256-
if (usingVThreadWrapper) {
256+
if (usingVirtualTTF) {
257257
expectedNumThreads = 1;
258258
} else {
259-
expectedNumThreads = usingWrapper ? 3 : 2;
259+
expectedNumThreads = usingTTF ? 3 : 2;
260260
}
261261
if (threads.size() < expectedNumThreads) {
262262
log3("ERROR: threads.size() < 2 for group1 : " + threads.size() );
@@ -277,7 +277,7 @@ private int runThis (String argv[], PrintStream out) {
277277
if (s1.equals("Thread2"))
278278
nThread2 += 1;
279279
}
280-
if (nMain != 1 && !usingVThreadWrapper) {
280+
if (nMain != 1 && !usingVirtualTTF) {
281281
log3("ERROR: # of 'main' threads != 1 : " + nMain);
282282
expresult = 1;
283283
}

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop001.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class stop001 {
6969
static final int PASSED = 0;
7070
static final int FAILED = 2;
7171
static final int PASS_BASE = 95;
72-
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
72+
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
7373

7474
//----------------------------------------------------- templete parameters
7575
static final String

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop001a.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public Threadstop001a(String threadName) {
189189

190190
public static Object lockingObject2 = new Object();
191191

192-
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
192+
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
193193

194194
private int i1 = 0, i2 = 10;
195195

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class stop002 {
7575
static final String COMMAND_GO = "go";
7676
static final String COMMAND_QUIT = "quit";
7777

78-
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
78+
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
7979

8080
private ArgumentHandler argHandler;
8181
private Log log;

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class stop002t {
3838
volatile boolean stopLooping1 = false;
3939
volatile boolean stopLooping2 = false;
4040
volatile static int testNumReady = 0;
41-
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
41+
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
4242

4343
public static void main(String args[]) {
4444
System.exit(run(args) + Consts.JCK_STATUS_BASE);

test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -251,7 +251,7 @@ public void run() {
251251
// debug agent has already generated the THREAD_START event for the
252252
// original "main", so we end up with two THREAD_START events for "main".
253253
// We need to allow for this.
254-
if ((System.getProperty("main.wrapper") != null) &&
254+
if ((System.getProperty("test.thread.factory") != null) &&
255255
checkedThreads[i][0].equals("main") &&
256256
checkedThreads[i][1].equals("1")) {
257257
checkedThreads[i][1] = "2";

test/hotspot/jtreg/vmTestbase/nsk/share/MainWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void main(String[] args) throws Throwable {
4747
finalizableObject.registerCleanup();
4848

4949
// Some tests use this property to understand if virtual threads are used
50-
System.setProperty("main.wrapper", wrapperName);
50+
System.setProperty("test.thread.factory", wrapperName);
5151

5252
Runnable task = () -> {
5353
try {

test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private String[] makeJdbCmdLine (String classToExecute) {
163163
args.add(jdbExecPath.trim());
164164

165165
if (argumentHandler.isLaunchingConnector()) {
166-
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
166+
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
167167
if (vthreadMode) {
168168
/* Some tests need more carrier threads than the default provided. */
169169
args.add("-R-Djdk.virtualThreadScheduler.parallelism=15");
@@ -230,8 +230,8 @@ private String[] makeJdbCmdLine (String classToExecute) {
230230
if (argumentHandler.verbose()) {
231231
cmdline += " -verbose";
232232
}
233-
if (System.getProperty("main.wrapper") != null) {
234-
cmdline = MainWrapper.class.getName() + " " + System.getProperty("main.wrapper") + " " + cmdline;
233+
if (System.getProperty("test.thread.factory") != null) {
234+
cmdline = MainWrapper.class.getName() + " " + System.getProperty("test.thread.factory") + " " + cmdline;
235235
}
236236
connect.append(",main=" + cmdline.trim());
237237

test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Binder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,8 @@ private Map<String,? extends Argument> setupLaunchingConnector(LaunchingConnecto
708708

709709
String cmdline = classToExecute + " " + ArgumentHandler.joinArguments(rawArgs, quote);
710710

711-
if(System.getProperty("main.wrapper") != null) {
712-
cmdline = MainWrapper.class.getName() + " " + System.getProperty("main.wrapper") + " " + cmdline;
711+
if (System.getProperty("test.thread.factory") != null) {
712+
cmdline = MainWrapper.class.getName() + " " + System.getProperty("test.thread.factory") + " " + cmdline;
713713
}
714714

715715
arg = (Connector.StringArgument) arguments.get("main");
@@ -749,7 +749,7 @@ private Map<String,? extends Argument> setupLaunchingConnector(LaunchingConnecto
749749
vmArgs = vmUserArgs;
750750
}
751751

752-
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
752+
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
753753
if (vthreadMode) {
754754
/* Some tests need more carrier threads than the default provided. */
755755
vmArgs += " -Djdk.virtualThreadScheduler.parallelism=15";

test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -251,7 +251,7 @@ public ThreadReference threadByNameOrThrow(String name) throws JDITestRuntimeExc
251251
if (thread.name().equals(name))
252252
return thread;
253253
}
254-
if ("Virtual".equals(System.getProperty("main.wrapper"))) {
254+
if ("Virtual".equals(System.getProperty("test.thread.factory"))) {
255255
return null;
256256
}
257257
throw new JDITestRuntimeException("** Thread IS NOT found ** : " + name);

test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIThreadFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public class JDIThreadFactory {
3333

34-
private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("main.wrapper"))
34+
private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("test.thread.factory"))
3535
? virtualThreadFactory() : platformThreadFactory();
3636

3737
public static Thread newThread(NamedTask task) {

test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ public String[] makeCommandLineArgs(String classToExecute, String transportAddre
350350

351351
args.add(jdwpArgs);
352352

353-
if(System.getProperty("main.wrapper") != null) {
353+
if (System.getProperty("test.thread.factory") != null) {
354354
args.add(MainWrapper.class.getName());
355-
args.add(System.getProperty("main.wrapper"));
355+
args.add(System.getProperty("test.thread.factory"));
356356
}
357357

358358
if (classToExecute != null) {

test/hotspot/jtreg/vmTestbase/nsk/share/runner/RunParams.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -225,7 +225,7 @@ else if (args[i].equals("-iterations"))
225225
iterations = Integer.parseInt(args[++i]);
226226
}
227227
// Allow to force using vthreads using wrapper property
228-
if(System.getProperty("main.wrapper") != null && System.getProperty("main.wrapper").equals("Virtual")) {
228+
if ("Virtual".equals(System.getProperty("test.thread.factory"))) {
229229
useVirtualThreads = true;
230230
}
231231
printConfig(System.out);

test/jdk/com/sun/jdi/DebuggeeWrapper.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626

2727
public class DebuggeeWrapper {
2828

29-
public static String PROPERTY_NAME = "main.wrapper";
29+
public static String PROPERTY_NAME = "test.thread.factory";
3030

3131
private static final String OLD_MAIN_THREAD_NAME = "old-m-a-i-n";
3232

3333
private static ThreadFactory threadFactory = r -> new Thread(r);
3434

35-
private static final String wrapperName = System.getProperty(PROPERTY_NAME);
35+
private static final String testThreadFactoryName = System.getProperty(PROPERTY_NAME);
3636

37-
public static String getWrapperName() {
38-
return wrapperName;
37+
public static String getTestThreadFactoryName() {
38+
return testThreadFactoryName;
3939
}
4040

4141
public static boolean isVirtual() {
42-
return "Virtual".equals(wrapperName);
42+
return "Virtual".equals(testThreadFactoryName);
4343
}
4444

4545
public static Thread newThread(Runnable task) {
@@ -85,7 +85,7 @@ public static void main(String[] args) throws Throwable {
8585
tg.uncaughtThrowable.printStackTrace(System.out);
8686
System.exit(1);
8787
}
88-
} else if (getWrapperName().equals("Kernel")) {
88+
} else if (getTestThreadFactoryName().equals("Kernel")) {
8989
MainThreadGroup tg = new MainThreadGroup();
9090
Thread t = new Thread(tg, () -> {
9191
try {

test/jdk/com/sun/jdi/TestScaffold.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ private ArgInfo parseArgs(String args[]) {
512512
// argInfo.targetVMArgs : -Xss4M
513513
// The result with wrapper enabled:
514514
// argInfo.targetAppCommandLine : DebuggeeWrapper Frames2Targ
515-
// argInfo.targetVMArgs : -Xss4M -Dmain.wrapper=Virtual
515+
// argInfo.targetVMArgs : -Xss4M -Dtest.thread.factory=Virtual
516516
boolean classNameParsed = false;
517517
for (int i = 0; i < args.length; i++) {
518518
String arg = args[i].trim();
@@ -548,10 +548,10 @@ private ArgInfo parseArgs(String args[]) {
548548
}
549549

550550
// Need to change args to run wrapper using command like 'DebuggeeWrapper <app-name>'
551-
// and set property 'main.wrapper' so test could use DebuggeeWrapper.isVirtual() method
552-
String mainWrapper = DebuggeeWrapper.getWrapperName();
553-
if (mainWrapper != null && !argInfo.targetAppCommandLine.isEmpty()) {
554-
argInfo.targetVMArgs += "-D" + DebuggeeWrapper.PROPERTY_NAME + "=" + mainWrapper;
551+
// and set property 'test.thread.factory' so test could use DebuggeeWrapper.isVirtual() method
552+
String testThreadFactoryName = DebuggeeWrapper.getTestThreadFactoryName();
553+
if (testThreadFactoryName != null && !argInfo.targetAppCommandLine.isEmpty()) {
554+
argInfo.targetVMArgs += "-D" + DebuggeeWrapper.PROPERTY_NAME + "=" + testThreadFactoryName;
555555
argInfo.targetAppCommandLine = DebuggeeWrapper.class.getName() + ' ' + argInfo.targetAppCommandLine;
556556
} else if ("true".equals(System.getProperty("test.enable.preview"))) {
557557
// the test specified @enablePreview.

test/jtreg_test_thread_factory/src/share/classes/Virtual.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Virtual implements ThreadFactory {
2828
static {
2929
// This property is used by ProcessTools and some tests
3030
try {
31-
System.setProperty("main.wrapper", "Virtual");
31+
System.setProperty("test.thread.factory", "Virtual");
3232
} catch (Throwable t) {
3333
// might be thrown by security manager
3434
}

0 commit comments

Comments
 (0)