8303773: Replace "main.wrapper" with "test.thread.factory" property in test code
Reviewed-by: cjplummer, amenkov
This commit is contained in:
parent
0e501f66df
commit
89987dbf87
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -152,7 +152,7 @@ public class monitor001 extends JdbTest {
|
|||||||
|
|
||||||
// check 'threads', searching for "java.lang.Thread" followed by the main thread name.
|
// check 'threads', searching for "java.lang.Thread" followed by the main thread name.
|
||||||
v.add("java.lang.Thread");
|
v.add("java.lang.Thread");
|
||||||
if (System.getProperty("main.wrapper") != null) {
|
if (System.getProperty("test.thread.factory") != null) {
|
||||||
v.add(nsk.share.MainWrapper.OLD_MAIN_THREAD_NAME);
|
v.add(nsk.share.MainWrapper.OLD_MAIN_THREAD_NAME);
|
||||||
} else {
|
} else {
|
||||||
v.add("main");
|
v.add("main");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -90,7 +90,7 @@ public class threads003 extends JdbTest {
|
|||||||
int count;
|
int count;
|
||||||
Vector v;
|
Vector v;
|
||||||
String[] threads;
|
String[] threads;
|
||||||
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
|
|
||||||
if (!vthreadMode) {
|
if (!vthreadMode) {
|
||||||
// This test is only meant to be run in vthread mode.
|
// This test is only meant to be run in vthread mode.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -186,7 +186,7 @@ public class unmonitor001 extends JdbTest {
|
|||||||
|
|
||||||
// check 'threads', searching for "java.lang.Thread" followed by the main thread name.
|
// check 'threads', searching for "java.lang.Thread" followed by the main thread name.
|
||||||
v.add("java.lang.Thread");
|
v.add("java.lang.Thread");
|
||||||
if (System.getProperty("main.wrapper") != null) {
|
if (System.getProperty("test.thread.factory") != null) {
|
||||||
v.add(nsk.share.MainWrapper.OLD_MAIN_THREAD_NAME);
|
v.add(nsk.share.MainWrapper.OLD_MAIN_THREAD_NAME);
|
||||||
} else {
|
} else {
|
||||||
v.add("main");
|
v.add("main");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -191,7 +191,7 @@ public class bounds002 {
|
|||||||
complain("Unexpected " + e);
|
complain("Unexpected " + e);
|
||||||
exitStatus = Consts.TEST_FAILED;
|
exitStatus = Consts.TEST_FAILED;
|
||||||
}
|
}
|
||||||
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
display("vthreadMode: " + vthreadMode + ", isTopmostFrame: " + isTopmostFrame);
|
display("vthreadMode: " + vthreadMode + ", isTopmostFrame: " + isTopmostFrame);
|
||||||
try {
|
try {
|
||||||
stackFrame.setValue(var, null);
|
stackFrame.setValue(var, null);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -134,8 +134,8 @@ public class threads001 {
|
|||||||
private int runThis (String argv[], PrintStream out) {
|
private int runThis (String argv[], PrintStream out) {
|
||||||
|
|
||||||
Debugee debuggee;
|
Debugee debuggee;
|
||||||
boolean usingWrapper = System.getProperty("main.wrapper") != null;
|
boolean usingTTF = System.getProperty("test.thread.factory") != null;
|
||||||
boolean usingVThreadWrapper = "Virtual".equals(System.getProperty("main.wrapper"));
|
boolean usingVirtualTTF = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
|
|
||||||
argsHandler = new ArgumentHandler(argv);
|
argsHandler = new ArgumentHandler(argv);
|
||||||
logHandler = new Log(out, argsHandler);
|
logHandler = new Log(out, argsHandler);
|
||||||
@ -253,10 +253,10 @@ public class threads001 {
|
|||||||
* the "VirtualThreads" ThreadGroup, and threfore do not show up in group1.
|
* the "VirtualThreads" ThreadGroup, and threfore do not show up in group1.
|
||||||
*/
|
*/
|
||||||
int expectedNumThreads;
|
int expectedNumThreads;
|
||||||
if (usingVThreadWrapper) {
|
if (usingVirtualTTF) {
|
||||||
expectedNumThreads = 1;
|
expectedNumThreads = 1;
|
||||||
} else {
|
} else {
|
||||||
expectedNumThreads = usingWrapper ? 3 : 2;
|
expectedNumThreads = usingTTF ? 3 : 2;
|
||||||
}
|
}
|
||||||
if (threads.size() < expectedNumThreads) {
|
if (threads.size() < expectedNumThreads) {
|
||||||
log3("ERROR: threads.size() < 2 for group1 : " + threads.size() );
|
log3("ERROR: threads.size() < 2 for group1 : " + threads.size() );
|
||||||
@ -277,7 +277,7 @@ public class threads001 {
|
|||||||
if (s1.equals("Thread2"))
|
if (s1.equals("Thread2"))
|
||||||
nThread2 += 1;
|
nThread2 += 1;
|
||||||
}
|
}
|
||||||
if (nMain != 1 && !usingVThreadWrapper) {
|
if (nMain != 1 && !usingVirtualTTF) {
|
||||||
log3("ERROR: # of 'main' threads != 1 : " + nMain);
|
log3("ERROR: # of 'main' threads != 1 : " + nMain);
|
||||||
expresult = 1;
|
expresult = 1;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class stop001 {
|
|||||||
static final int PASSED = 0;
|
static final int PASSED = 0;
|
||||||
static final int FAILED = 2;
|
static final int FAILED = 2;
|
||||||
static final int PASS_BASE = 95;
|
static final int PASS_BASE = 95;
|
||||||
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
|
|
||||||
//----------------------------------------------------- templete parameters
|
//----------------------------------------------------- templete parameters
|
||||||
static final String
|
static final String
|
||||||
|
@ -189,7 +189,7 @@ class Threadstop001a extends NamedTask {
|
|||||||
|
|
||||||
public static Object lockingObject2 = new Object();
|
public static Object lockingObject2 = new Object();
|
||||||
|
|
||||||
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
|
|
||||||
private int i1 = 0, i2 = 10;
|
private int i1 = 0, i2 = 10;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class stop002 {
|
|||||||
static final String COMMAND_GO = "go";
|
static final String COMMAND_GO = "go";
|
||||||
static final String COMMAND_QUIT = "quit";
|
static final String COMMAND_QUIT = "quit";
|
||||||
|
|
||||||
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
|
|
||||||
private ArgumentHandler argHandler;
|
private ArgumentHandler argHandler;
|
||||||
private Log log;
|
private Log log;
|
||||||
|
@ -38,7 +38,7 @@ public class stop002t {
|
|||||||
volatile boolean stopLooping1 = false;
|
volatile boolean stopLooping1 = false;
|
||||||
volatile boolean stopLooping2 = false;
|
volatile boolean stopLooping2 = false;
|
||||||
volatile static int testNumReady = 0;
|
volatile static int testNumReady = 0;
|
||||||
static final boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
static final boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.exit(run(args) + Consts.JCK_STATUS_BASE);
|
System.exit(run(args) + Consts.JCK_STATUS_BASE);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -251,7 +251,7 @@ public class thread001 {
|
|||||||
// debug agent has already generated the THREAD_START event for the
|
// debug agent has already generated the THREAD_START event for the
|
||||||
// original "main", so we end up with two THREAD_START events for "main".
|
// original "main", so we end up with two THREAD_START events for "main".
|
||||||
// We need to allow for this.
|
// We need to allow for this.
|
||||||
if ((System.getProperty("main.wrapper") != null) &&
|
if ((System.getProperty("test.thread.factory") != null) &&
|
||||||
checkedThreads[i][0].equals("main") &&
|
checkedThreads[i][0].equals("main") &&
|
||||||
checkedThreads[i][1].equals("1")) {
|
checkedThreads[i][1].equals("1")) {
|
||||||
checkedThreads[i][1] = "2";
|
checkedThreads[i][1] = "2";
|
||||||
|
@ -47,7 +47,7 @@ public final class MainWrapper {
|
|||||||
finalizableObject.registerCleanup();
|
finalizableObject.registerCleanup();
|
||||||
|
|
||||||
// Some tests use this property to understand if virtual threads are used
|
// Some tests use this property to understand if virtual threads are used
|
||||||
System.setProperty("main.wrapper", wrapperName);
|
System.setProperty("test.thread.factory", wrapperName);
|
||||||
|
|
||||||
Runnable task = () -> {
|
Runnable task = () -> {
|
||||||
try {
|
try {
|
||||||
|
@ -163,7 +163,7 @@ public class Launcher extends DebugeeBinder {
|
|||||||
args.add(jdbExecPath.trim());
|
args.add(jdbExecPath.trim());
|
||||||
|
|
||||||
if (argumentHandler.isLaunchingConnector()) {
|
if (argumentHandler.isLaunchingConnector()) {
|
||||||
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
if (vthreadMode) {
|
if (vthreadMode) {
|
||||||
/* Some tests need more carrier threads than the default provided. */
|
/* Some tests need more carrier threads than the default provided. */
|
||||||
args.add("-R-Djdk.virtualThreadScheduler.parallelism=15");
|
args.add("-R-Djdk.virtualThreadScheduler.parallelism=15");
|
||||||
@ -230,8 +230,8 @@ public class Launcher extends DebugeeBinder {
|
|||||||
if (argumentHandler.verbose()) {
|
if (argumentHandler.verbose()) {
|
||||||
cmdline += " -verbose";
|
cmdline += " -verbose";
|
||||||
}
|
}
|
||||||
if (System.getProperty("main.wrapper") != null) {
|
if (System.getProperty("test.thread.factory") != null) {
|
||||||
cmdline = MainWrapper.class.getName() + " " + System.getProperty("main.wrapper") + " " + cmdline;
|
cmdline = MainWrapper.class.getName() + " " + System.getProperty("test.thread.factory") + " " + cmdline;
|
||||||
}
|
}
|
||||||
connect.append(",main=" + cmdline.trim());
|
connect.append(",main=" + cmdline.trim());
|
||||||
|
|
||||||
|
@ -708,8 +708,8 @@ public class Binder extends DebugeeBinder {
|
|||||||
|
|
||||||
String cmdline = classToExecute + " " + ArgumentHandler.joinArguments(rawArgs, quote);
|
String cmdline = classToExecute + " " + ArgumentHandler.joinArguments(rawArgs, quote);
|
||||||
|
|
||||||
if(System.getProperty("main.wrapper") != null) {
|
if (System.getProperty("test.thread.factory") != null) {
|
||||||
cmdline = MainWrapper.class.getName() + " " + System.getProperty("main.wrapper") + " " + cmdline;
|
cmdline = MainWrapper.class.getName() + " " + System.getProperty("test.thread.factory") + " " + cmdline;
|
||||||
}
|
}
|
||||||
|
|
||||||
arg = (Connector.StringArgument) arguments.get("main");
|
arg = (Connector.StringArgument) arguments.get("main");
|
||||||
@ -749,7 +749,7 @@ public class Binder extends DebugeeBinder {
|
|||||||
vmArgs = vmUserArgs;
|
vmArgs = vmUserArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean vthreadMode = "Virtual".equals(System.getProperty("main.wrapper"));
|
boolean vthreadMode = "Virtual".equals(System.getProperty("test.thread.factory"));
|
||||||
if (vthreadMode) {
|
if (vthreadMode) {
|
||||||
/* Some tests need more carrier threads than the default provided. */
|
/* Some tests need more carrier threads than the default provided. */
|
||||||
vmArgs += " -Djdk.virtualThreadScheduler.parallelism=15";
|
vmArgs += " -Djdk.virtualThreadScheduler.parallelism=15";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -251,7 +251,7 @@ abstract public class Debugee extends DebugeeProcess {
|
|||||||
if (thread.name().equals(name))
|
if (thread.name().equals(name))
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
if ("Virtual".equals(System.getProperty("main.wrapper"))) {
|
if ("Virtual".equals(System.getProperty("test.thread.factory"))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new JDITestRuntimeException("** Thread IS NOT found ** : " + name);
|
throw new JDITestRuntimeException("** Thread IS NOT found ** : " + name);
|
||||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.ThreadFactory;
|
|||||||
|
|
||||||
public class JDIThreadFactory {
|
public class JDIThreadFactory {
|
||||||
|
|
||||||
private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("main.wrapper"))
|
private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("test.thread.factory"))
|
||||||
? virtualThreadFactory() : platformThreadFactory();
|
? virtualThreadFactory() : platformThreadFactory();
|
||||||
|
|
||||||
public static Thread newThread(NamedTask task) {
|
public static Thread newThread(NamedTask task) {
|
||||||
|
@ -350,9 +350,9 @@ public class DebugeeBinder extends Log.Logger implements Finalizable {
|
|||||||
|
|
||||||
args.add(jdwpArgs);
|
args.add(jdwpArgs);
|
||||||
|
|
||||||
if(System.getProperty("main.wrapper") != null) {
|
if (System.getProperty("test.thread.factory") != null) {
|
||||||
args.add(MainWrapper.class.getName());
|
args.add(MainWrapper.class.getName());
|
||||||
args.add(System.getProperty("main.wrapper"));
|
args.add(System.getProperty("test.thread.factory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classToExecute != null) {
|
if (classToExecute != null) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -225,7 +225,7 @@ public class RunParams {
|
|||||||
iterations = Integer.parseInt(args[++i]);
|
iterations = Integer.parseInt(args[++i]);
|
||||||
}
|
}
|
||||||
// Allow to force using vthreads using wrapper property
|
// Allow to force using vthreads using wrapper property
|
||||||
if(System.getProperty("main.wrapper") != null && System.getProperty("main.wrapper").equals("Virtual")) {
|
if ("Virtual".equals(System.getProperty("test.thread.factory"))) {
|
||||||
useVirtualThreads = true;
|
useVirtualThreads = true;
|
||||||
}
|
}
|
||||||
printConfig(System.out);
|
printConfig(System.out);
|
||||||
|
@ -26,20 +26,20 @@ import java.util.concurrent.ThreadFactory;
|
|||||||
|
|
||||||
public class DebuggeeWrapper {
|
public class DebuggeeWrapper {
|
||||||
|
|
||||||
public static String PROPERTY_NAME = "main.wrapper";
|
public static String PROPERTY_NAME = "test.thread.factory";
|
||||||
|
|
||||||
private static final String OLD_MAIN_THREAD_NAME = "old-m-a-i-n";
|
private static final String OLD_MAIN_THREAD_NAME = "old-m-a-i-n";
|
||||||
|
|
||||||
private static ThreadFactory threadFactory = r -> new Thread(r);
|
private static ThreadFactory threadFactory = r -> new Thread(r);
|
||||||
|
|
||||||
private static final String wrapperName = System.getProperty(PROPERTY_NAME);
|
private static final String testThreadFactoryName = System.getProperty(PROPERTY_NAME);
|
||||||
|
|
||||||
public static String getWrapperName() {
|
public static String getTestThreadFactoryName() {
|
||||||
return wrapperName;
|
return testThreadFactoryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVirtual() {
|
public static boolean isVirtual() {
|
||||||
return "Virtual".equals(wrapperName);
|
return "Virtual".equals(testThreadFactoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread newThread(Runnable task) {
|
public static Thread newThread(Runnable task) {
|
||||||
@ -85,7 +85,7 @@ public class DebuggeeWrapper {
|
|||||||
tg.uncaughtThrowable.printStackTrace(System.out);
|
tg.uncaughtThrowable.printStackTrace(System.out);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
} else if (getWrapperName().equals("Kernel")) {
|
} else if (getTestThreadFactoryName().equals("Kernel")) {
|
||||||
MainThreadGroup tg = new MainThreadGroup();
|
MainThreadGroup tg = new MainThreadGroup();
|
||||||
Thread t = new Thread(tg, () -> {
|
Thread t = new Thread(tg, () -> {
|
||||||
try {
|
try {
|
||||||
|
@ -512,7 +512,7 @@ abstract public class TestScaffold extends TargetAdapter {
|
|||||||
// argInfo.targetVMArgs : -Xss4M
|
// argInfo.targetVMArgs : -Xss4M
|
||||||
// The result with wrapper enabled:
|
// The result with wrapper enabled:
|
||||||
// argInfo.targetAppCommandLine : DebuggeeWrapper Frames2Targ
|
// argInfo.targetAppCommandLine : DebuggeeWrapper Frames2Targ
|
||||||
// argInfo.targetVMArgs : -Xss4M -Dmain.wrapper=Virtual
|
// argInfo.targetVMArgs : -Xss4M -Dtest.thread.factory=Virtual
|
||||||
boolean classNameParsed = false;
|
boolean classNameParsed = false;
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
String arg = args[i].trim();
|
String arg = args[i].trim();
|
||||||
@ -548,10 +548,10 @@ abstract public class TestScaffold extends TargetAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Need to change args to run wrapper using command like 'DebuggeeWrapper <app-name>'
|
// Need to change args to run wrapper using command like 'DebuggeeWrapper <app-name>'
|
||||||
// and set property 'main.wrapper' so test could use DebuggeeWrapper.isVirtual() method
|
// and set property 'test.thread.factory' so test could use DebuggeeWrapper.isVirtual() method
|
||||||
String mainWrapper = DebuggeeWrapper.getWrapperName();
|
String testThreadFactoryName = DebuggeeWrapper.getTestThreadFactoryName();
|
||||||
if (mainWrapper != null && !argInfo.targetAppCommandLine.isEmpty()) {
|
if (testThreadFactoryName != null && !argInfo.targetAppCommandLine.isEmpty()) {
|
||||||
argInfo.targetVMArgs += "-D" + DebuggeeWrapper.PROPERTY_NAME + "=" + mainWrapper;
|
argInfo.targetVMArgs += "-D" + DebuggeeWrapper.PROPERTY_NAME + "=" + testThreadFactoryName;
|
||||||
argInfo.targetAppCommandLine = DebuggeeWrapper.class.getName() + ' ' + argInfo.targetAppCommandLine;
|
argInfo.targetAppCommandLine = DebuggeeWrapper.class.getName() + ' ' + argInfo.targetAppCommandLine;
|
||||||
} else if ("true".equals(System.getProperty("test.enable.preview"))) {
|
} else if ("true".equals(System.getProperty("test.enable.preview"))) {
|
||||||
// the test specified @enablePreview.
|
// the test specified @enablePreview.
|
||||||
|
@ -28,7 +28,7 @@ public class Virtual implements ThreadFactory {
|
|||||||
static {
|
static {
|
||||||
// This property is used by ProcessTools and some tests
|
// This property is used by ProcessTools and some tests
|
||||||
try {
|
try {
|
||||||
System.setProperty("main.wrapper", "Virtual");
|
System.setProperty("test.thread.factory", "Virtual");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// might be thrown by security manager
|
// might be thrown by security manager
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.Thread.State;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -388,14 +387,14 @@ public final class ProcessTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Convert arguments for tests running with virtual threads main wrapper
|
Convert arguments for tests running with virtual threads test thread factory.
|
||||||
When test is executed with process wrapper the line is changed from
|
When test is executed with test thread factory the line is changed from
|
||||||
java <jvm-args> <test-class> <test-args>
|
java <jvm-args> <test-class> <test-args>
|
||||||
to
|
to
|
||||||
java <jvm-args> -Dmain.wrapper=<wrapper-name> jdk.test.lib.process.ProcessTools <wrapper-name> <test-class> <test-args>
|
java <jvm-args> -Dtest.thread.factory=<test-thread-factory-name> jdk.test.lib.process.ProcessTools <test-thread-factory-name> <test-class> <test-args>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static List<String> addMainWrapperArgs(String mainWrapper, List<String> command) {
|
private static List<String> addTestThreadFactoryArgs(String testThreadFactoryName, List<String> command) {
|
||||||
|
|
||||||
final List<String> unsupportedArgs = List.of(
|
final List<String> unsupportedArgs = List.of(
|
||||||
"-jar", "-cp", "-classpath", "--class-path", "--describe-module", "-d",
|
"-jar", "-cp", "-classpath", "--class-path", "--describe-module", "-d",
|
||||||
@ -408,9 +407,9 @@ public final class ProcessTools {
|
|||||||
ArrayList<String> args = new ArrayList<>();
|
ArrayList<String> args = new ArrayList<>();
|
||||||
|
|
||||||
boolean expectSecondArg = false;
|
boolean expectSecondArg = false;
|
||||||
boolean isWrapperClassAdded = false;
|
boolean isTestThreadFactoryAdded = false;
|
||||||
for (String cmd : command) {
|
for (String cmd : command) {
|
||||||
if (isWrapperClassAdded) {
|
if (isTestThreadFactoryAdded) {
|
||||||
args.add(cmd);
|
args.add(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -443,10 +442,10 @@ public final class ProcessTools {
|
|||||||
}
|
}
|
||||||
// Some tests might check property to understand
|
// Some tests might check property to understand
|
||||||
// if virtual threads are tested
|
// if virtual threads are tested
|
||||||
args.add("-Dmain.wrapper=" + mainWrapper);
|
args.add("-Dtest.thread.factory=" + testThreadFactoryName);
|
||||||
args.add("jdk.test.lib.process.ProcessTools");
|
args.add("jdk.test.lib.process.ProcessTools");
|
||||||
args.add(mainWrapper);
|
args.add(testThreadFactoryName);
|
||||||
isWrapperClassAdded = true;
|
isTestThreadFactoryAdded = true;
|
||||||
args.add(cmd);
|
args.add(cmd);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
@ -471,9 +470,9 @@ public final class ProcessTools {
|
|||||||
args.add(System.getProperty("java.class.path"));
|
args.add(System.getProperty("java.class.path"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String mainWrapper = System.getProperty("main.wrapper");
|
String testThreadFactoryName = System.getProperty("test.thread.factory");
|
||||||
if (mainWrapper != null) {
|
if (testThreadFactoryName != null) {
|
||||||
args.addAll(addMainWrapperArgs(mainWrapper, Arrays.asList(command)));
|
args.addAll(addTestThreadFactoryArgs(testThreadFactoryName, Arrays.asList(command)));
|
||||||
} else {
|
} else {
|
||||||
Collections.addAll(args, command);
|
Collections.addAll(args, command);
|
||||||
}
|
}
|
||||||
@ -881,10 +880,10 @@ public final class ProcessTools {
|
|||||||
|
|
||||||
public static final String OLD_MAIN_THREAD_NAME = "old-m-a-i-n";
|
public static final String OLD_MAIN_THREAD_NAME = "old-m-a-i-n";
|
||||||
|
|
||||||
// ProcessTools as a wrapper
|
// ProcessTools as a wrapper for test execution
|
||||||
// It executes method main in a separate virtual or platform thread
|
// It executes method main in a separate virtual or platform thread
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
String wrapper = args[0];
|
String testThreadFactoryName = args[0];
|
||||||
String className = args[1];
|
String className = args[1];
|
||||||
String[] classArgs = new String[args.length - 2];
|
String[] classArgs = new String[args.length - 2];
|
||||||
System.arraycopy(args, 2, classArgs, 0, args.length - 2);
|
System.arraycopy(args, 2, classArgs, 0, args.length - 2);
|
||||||
@ -892,7 +891,7 @@ public final class ProcessTools {
|
|||||||
Method mainMethod = c.getMethod("main", new Class[] { String[].class });
|
Method mainMethod = c.getMethod("main", new Class[] { String[].class });
|
||||||
mainMethod.setAccessible(true);
|
mainMethod.setAccessible(true);
|
||||||
|
|
||||||
if (wrapper.equals("Virtual")) {
|
if (testThreadFactoryName.equals("Virtual")) {
|
||||||
// MainThreadGroup used just as a container for exceptions
|
// MainThreadGroup used just as a container for exceptions
|
||||||
// when main is executed in virtual thread
|
// when main is executed in virtual thread
|
||||||
MainThreadGroup tg = new MainThreadGroup();
|
MainThreadGroup tg = new MainThreadGroup();
|
||||||
@ -912,7 +911,7 @@ public final class ProcessTools {
|
|||||||
if (tg.uncaughtThrowable != null) {
|
if (tg.uncaughtThrowable != null) {
|
||||||
throw tg.uncaughtThrowable;
|
throw tg.uncaughtThrowable;
|
||||||
}
|
}
|
||||||
} else if (wrapper.equals("Kernel")) {
|
} else if (testThreadFactoryName.equals("Kernel")) {
|
||||||
MainThreadGroup tg = new MainThreadGroup();
|
MainThreadGroup tg = new MainThreadGroup();
|
||||||
Thread t = new Thread(tg, () -> {
|
Thread t = new Thread(tg, () -> {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user