8307307: Improve ProcessTools.java to don't try to run Virtual wrapper for incompatible processes
Reviewed-by: alanb
This commit is contained in:
parent
dde557e312
commit
7f05f6f7c7
@ -47,3 +47,6 @@ com/sun/jdi/ReferrersTest.java 8285422 generic-all
|
||||
com/sun/jdi/SetLocalWhileThreadInNative.java 8285422 generic-all
|
||||
com/sun/jdi/StepTest.java 8285422 generic-all
|
||||
com/sun/jdi/PopAndInvokeTest.java 8305632 generic-all
|
||||
com/sun/jdi/cds/CDSBreakpointTest.java 8307778 generic-all
|
||||
com/sun/jdi/cds/CDSDeleteAllBkptsTest.java 8307778 generic-all
|
||||
com/sun/jdi/cds/CDSFieldWatchpoints.java 8307778 generic-all
|
||||
|
@ -392,22 +392,21 @@ public final class ProcessTools {
|
||||
When test is executed with process wrapper the line is changed from
|
||||
java <jvm-args> <test-class> <test-args>
|
||||
to
|
||||
java --enable-preview <jvm-args> jdk.test.lib.process.ProcessTools <wrapper-name> <test-class> <test-args>
|
||||
java <jvm-args> -Dmain.wrapper=<wrapper-name> jdk.test.lib.process.ProcessTools <wrapper-name> <test-class> <test-args>
|
||||
*/
|
||||
private static List<String> addMainWrapperArgs(String mainWrapper, List<String> command) {
|
||||
|
||||
boolean useModules = command.contains("-m");
|
||||
if (useModules) {
|
||||
return command;
|
||||
}
|
||||
private static List<String> addMainWrapperArgs(String mainWrapper, List<String> command) {
|
||||
|
||||
final List<String> unsupportedArgs = List.of(
|
||||
"-jar", "-cp", "-classpath", "--class-path", "--describe-module", "-d",
|
||||
"--dry-run", "--list-modules","--validate-modules", "-version");
|
||||
|
||||
final List<String> doubleWordArgs = List.of(
|
||||
"-jar", "-cp", "-classpath", "--class-path", "--add-opens", "--upgrade-module-path",
|
||||
"--describe-module", "--add-modules", "-d", "--add-exports", "--limit-modules",
|
||||
"--add-reads", "--patch-module", "--module-path", "--module", "-m", "-p");
|
||||
|
||||
ArrayList<String> args = new ArrayList<>();
|
||||
final String[] doubleWordArgs = {"-cp", "-classpath", "--add-opens", "--class-path", "--upgrade-module-path",
|
||||
"--add-modules", "-d", "--add-exports", "--patch-module", "--module-path"};
|
||||
|
||||
if (mainWrapper.equalsIgnoreCase("virtual")) {
|
||||
args.add("--enable-preview");
|
||||
}
|
||||
|
||||
boolean expectSecondArg = false;
|
||||
boolean isWrapperClassAdded = false;
|
||||
@ -422,20 +421,30 @@ public final class ProcessTools {
|
||||
args.add(cmd);
|
||||
continue;
|
||||
}
|
||||
for (String dWArg : doubleWordArgs) {
|
||||
if (cmd.equals(dWArg)) {
|
||||
expectSecondArg = true;
|
||||
args.add(cmd);
|
||||
break;
|
||||
}
|
||||
if (unsupportedArgs.contains(cmd)) {
|
||||
return command;
|
||||
}
|
||||
if (doubleWordArgs.contains(cmd)) {
|
||||
expectSecondArg = true;
|
||||
args.add(cmd);
|
||||
continue;
|
||||
}
|
||||
if (expectSecondArg) {
|
||||
continue;
|
||||
}
|
||||
if (cmd.startsWith("-")) {
|
||||
// command-line or name command-line file
|
||||
if (cmd.startsWith("-") || cmd.startsWith("@")) {
|
||||
args.add(cmd);
|
||||
continue;
|
||||
}
|
||||
|
||||
// if command is like 'java source.java' then return
|
||||
if (cmd.endsWith(".java")) {
|
||||
return command;
|
||||
}
|
||||
// Some tests might check property to understand
|
||||
// if virtual threads are tested
|
||||
args.add("-Dmain.wrapper=" + mainWrapper);
|
||||
args.add("jdk.test.lib.process.ProcessTools");
|
||||
args.add(mainWrapper);
|
||||
isWrapperClassAdded = true;
|
||||
|
Loading…
Reference in New Issue
Block a user