Skip to content

Commit

Permalink
8307307: Improve ProcessTools.java to don't try to run Virtual wrappe…
Browse files Browse the repository at this point in the history
…r for incompatible processes

Reviewed-by: alanb
  • Loading branch information
lmesnik committed May 9, 2023
1 parent dde557e commit 7f05f6f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
3 changes: 3 additions & 0 deletions test/jdk/ProblemList-Virtual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 28 additions & 19 deletions test/lib/jdk/test/lib/process/ProcessTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,21 @@ public static ProcessBuilder createJavaProcessBuilder(List<String> command) {
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) {

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"};
final List<String> unsupportedArgs = List.of(
"-jar", "-cp", "-classpath", "--class-path", "--describe-module", "-d",
"--dry-run", "--list-modules","--validate-modules", "-version");

if (mainWrapper.equalsIgnoreCase("virtual")) {
args.add("--enable-preview");
}
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<>();

boolean expectSecondArg = false;
boolean isWrapperClassAdded = false;
Expand All @@ -422,20 +421,30 @@ private static List<String> addMainWrapperArgs(String mainWrapper, List<String>
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;
Expand Down

1 comment on commit 7f05f6f

@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.