Skip to content

Commit 5b8e1a2

Browse files
committed
8266595: jdk/jfr/jcmd/TestJcmdDump.java with slowdebug bits fails with AttachNotSupportedException
Reviewed-by: mseledtsov, dholmes
1 parent e14801c commit 5b8e1a2

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/jdk/jdk/jfr/jcmd/TestJcmdDump.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
import jdk.jfr.Recording;
3434
import jdk.jfr.consumer.RecordedEvent;
3535
import jdk.jfr.consumer.RecordingFile;
36+
import jdk.test.lib.JDKToolFinder;
3637
import jdk.test.lib.jfr.EventNames;
3738
import jdk.test.lib.process.OutputAnalyzer;
39+
import jdk.test.lib.process.ProcessTools;
3840

3941
/**
4042
* @test
@@ -53,9 +55,9 @@ static class RunningEvent extends Event {
5355

5456
private static final String[] names = { null, "r1" };
5557
private static final boolean booleanValues[] = { true, false };
58+
private static final long timeoutMillis = 50000;
5659

5760
public static void main(String[] args) throws Exception {
58-
5961
// Create a stopped recording in the repository to complicate things
6062
Recording r = new Recording();
6163
r.start();
@@ -105,8 +107,10 @@ private static void jfrDump(Boolean pathToGCRoots, String name, boolean disk, Pr
105107
leakList.add(new Object[1000_0000]);
106108
System.gc(); // This will shorten time for object to be emitted.
107109
File recording = new File("TestJCMdDump.jfr");
108-
String[] params = buildParameters(pathToGCRoots, name, recording);
109-
OutputAnalyzer output = JcmdHelper.jcmd(params);
110+
List<String> params = buildParameters(pathToGCRoots, name, recording);
111+
System.out.println(params);
112+
OutputAnalyzer output = ProcessTools.executeProcess(new ProcessBuilder(params));
113+
output.reportDiagnosticSummary();
110114
JcmdAsserts.assertRecordingDumpedToFile(output, recording);
111115
int rootCount = 0;
112116
int oldObjectCount = 0;
@@ -155,8 +159,11 @@ private static void jfrDump(Boolean pathToGCRoots, String name, boolean disk, Pr
155159
}
156160
}
157161

158-
private static String[] buildParameters(Boolean pathToGCRoots, String name, File recording) {
162+
private static List<String> buildParameters(Boolean pathToGCRoots, String name, File recording) {
159163
List<String> params = new ArrayList<>();
164+
params.add(JDKToolFinder.getJDKTool("jcmd"));
165+
params.add("-J-Dsun.tools.attach.attachTimeout=" + timeoutMillis);
166+
params.add(String.valueOf(ProcessHandle.current().pid()));
160167
params.add("JFR.dump");
161168
params.add("filename=" + recording.getAbsolutePath());
162169
if (pathToGCRoots != null) { // if path-to-gc-roots is omitted, default is used (disabled).
@@ -165,6 +172,6 @@ private static String[] buildParameters(Boolean pathToGCRoots, String name, File
165172
if (name != null) { // if name is omitted, all recordings will be dumped
166173
params.add("name=" + name);
167174
}
168-
return params.toArray(new String[0]);
175+
return params;
169176
}
170177
}

0 commit comments

Comments
 (0)