8314834: serviceability/jdwp/AllModulesCommandTest.java ignores VM flags

Reviewed-by: sspitsyn
This commit is contained in:
Leonid Mesnik 2023-08-30 16:14:07 +00:00
parent 1ea6463fbb
commit 8e4cda063c

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 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
@ -25,6 +25,7 @@ import java.util.StringTokenizer;
import jdk.test.lib.JDKToolFinder; import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.JDWP; import jdk.test.lib.JDWP;
import static jdk.test.lib.Asserts.assertFalse; import static jdk.test.lib.Asserts.assertFalse;
import jdk.test.lib.process.ProcessTools;
/** /**
* Launches the debuggee with the necessary JDWP options and handles the output * Launches the debuggee with the necessary JDWP options and handles the output
@ -54,8 +55,9 @@ public class DebuggeeLauncher implements StreamHandler.Listener {
} }
private int jdwpPort = -1; private int jdwpPort = -1;
private static final String CLS_DIR = System.getProperty("test.classes", "").trim();
private static final String DEBUGGEE = "AllModulesCommandTestDebuggee"; private static final String DEBUGGEE = "AllModulesCommandTestDebuggee";
private static final String JDWP_OPT = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0";
private Process p; private Process p;
private final Listener listener; private final Listener listener;
private StreamHandler inputHandler; private StreamHandler inputHandler;
@ -76,7 +78,7 @@ public class DebuggeeLauncher implements StreamHandler.Listener {
*/ */
public void launchDebuggee() throws Throwable { public void launchDebuggee() throws Throwable {
ProcessBuilder pb = new ProcessBuilder(getCommand()); ProcessBuilder pb = ProcessTools.createTestJvm(JDWP_OPT, DEBUGGEE);
p = pb.start(); p = pb.start();
inputHandler = new StreamHandler(p.getInputStream(), this); inputHandler = new StreamHandler(p.getInputStream(), this);
errorHandler = new StreamHandler(p.getErrorStream(), this); errorHandler = new StreamHandler(p.getErrorStream(), this);
@ -84,22 +86,6 @@ public class DebuggeeLauncher implements StreamHandler.Listener {
errorHandler.start(); errorHandler.start();
} }
/**
* Command to start the debuggee with the JDWP options and using the JDK
* under test
*
* @return the command
*/
private String[] getCommand() {
return new String[]{
JDKToolFinder.getTestJDKTool("java"),
getJdwpOptions(),
"-cp",
CLS_DIR,
DEBUGGEE
};
}
/** /**
* Terminates the debuggee * Terminates the debuggee
*/ */
@ -109,15 +95,6 @@ public class DebuggeeLauncher implements StreamHandler.Listener {
} }
} }
/**
* Debuggee JDWP options
*
* @return the JDWP options to start the debuggee with
*/
private static String getJdwpOptions() {
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0";
}
/** /**
* Gets JDWP port debuggee is listening on. * Gets JDWP port debuggee is listening on.
* *