From 218829e0a2a3ae5599b81733df53557966392033 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Thu, 31 Aug 2023 02:33:38 +0000 Subject: [PATCH] 8315421: [BACKOUT] 8314834 serviceability/jdwp/AllModulesCommandTest.java ignores VM flags Reviewed-by: dholmes --- .../serviceability/jdwp/DebuggeeLauncher.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java b/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java index 8c939833edb..5c3d01ec2dc 100644 --- a/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java +++ b/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, 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,7 +25,6 @@ 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 @@ -55,9 +54,8 @@ 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; @@ -78,7 +76,7 @@ public class DebuggeeLauncher implements StreamHandler.Listener { */ public void launchDebuggee() throws Throwable { - ProcessBuilder pb = ProcessTools.createTestJvm(JDWP_OPT, DEBUGGEE); + ProcessBuilder pb = new ProcessBuilder(getCommand()); p = pb.start(); inputHandler = new StreamHandler(p.getInputStream(), this); errorHandler = new StreamHandler(p.getErrorStream(), this); @@ -86,6 +84,22 @@ 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 */ @@ -95,6 +109,15 @@ 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. *