--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java Thu Jun 28 10:46:05 2018 -0400
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java Thu Jun 28 15:17:44 2018 +0200
@@ -39,6 +39,7 @@
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
+import jdk.jfr.internal.JVM;
import jdk.jfr.internal.SecuritySupport;
import jdk.jfr.internal.SecuritySupport.SafePath;
import jdk.jfr.internal.Utils;
@@ -65,9 +66,17 @@
return result.toString();
}
+ public String getPid() {
+ // Invoking ProcessHandle.current().pid() would require loading more
+ // classes during startup so instead JVM.getJVM().getPid() is used.
+ // The pid will not be exposed to running Java application, only when starting
+ // JFR from command line (-XX:StartFlightRecordin) or jcmd (JFR.start and JFR.check)
+ return JVM.getJVM().getPid();
+ }
+
protected final SafePath resolvePath(Recording recording, String filename) throws InvalidPathException {
if (filename == null) {
- return makeGenerated(recording, Paths.get("."));
+ return makeGenerated(recording, Paths.get("."));
}
Path path = Paths.get(filename);
if (Files.isDirectory(path)) {