diff --git a/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java b/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java index 5c3d01ec2dc..8c939833edb 100644 --- a/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java +++ b/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java @@ -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. * * 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.JDWP; 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 @@ -54,8 +55,9 @@ public class DebuggeeLauncher implements StreamHandler.Listener { } 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 JDWP_OPT = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0"; + private Process p; private final Listener listener; private StreamHandler inputHandler; @@ -76,7 +78,7 @@ public class DebuggeeLauncher implements StreamHandler.Listener { */ public void launchDebuggee() throws Throwable { - ProcessBuilder pb = new ProcessBuilder(getCommand()); + ProcessBuilder pb = ProcessTools.createTestJvm(JDWP_OPT, DEBUGGEE); p = pb.start(); inputHandler = new StreamHandler(p.getInputStream(), this); errorHandler = new StreamHandler(p.getErrorStream(), this); @@ -84,22 +86,6 @@ public class DebuggeeLauncher implements StreamHandler.Listener { 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 */ @@ -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. *