src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java
changeset 50887 fa91003ec489
parent 50886 1b346a59b5da
child 53013 c8b2a408628b
equal deleted inserted replaced
50886:1b346a59b5da 50887:fa91003ec489
    37 import java.util.Comparator;
    37 import java.util.Comparator;
    38 import java.util.List;
    38 import java.util.List;
    39 
    39 
    40 import jdk.jfr.FlightRecorder;
    40 import jdk.jfr.FlightRecorder;
    41 import jdk.jfr.Recording;
    41 import jdk.jfr.Recording;
       
    42 import jdk.jfr.internal.JVM;
    42 import jdk.jfr.internal.SecuritySupport;
    43 import jdk.jfr.internal.SecuritySupport;
    43 import jdk.jfr.internal.SecuritySupport.SafePath;
    44 import jdk.jfr.internal.SecuritySupport.SafePath;
    44 import jdk.jfr.internal.Utils;
    45 import jdk.jfr.internal.Utils;
    45 
    46 
    46 /**
    47 /**
    63 
    64 
    64     public final String getResult() {
    65     public final String getResult() {
    65         return result.toString();
    66         return result.toString();
    66     }
    67     }
    67 
    68 
       
    69     public String getPid() {
       
    70         // Invoking ProcessHandle.current().pid() would require loading more
       
    71         // classes during startup so instead JVM.getJVM().getPid() is used.
       
    72         // The pid will not be exposed to running Java application, only when starting
       
    73         // JFR from command line (-XX:StartFlightRecordin) or jcmd (JFR.start and JFR.check)
       
    74         return JVM.getJVM().getPid();
       
    75     }
       
    76 
    68     protected final SafePath resolvePath(Recording recording, String filename) throws InvalidPathException {
    77     protected final SafePath resolvePath(Recording recording, String filename) throws InvalidPathException {
    69         if (filename == null) {
    78         if (filename == null) {
    70              return makeGenerated(recording, Paths.get("."));
    79             return makeGenerated(recording, Paths.get("."));
    71         }
    80         }
    72         Path path = Paths.get(filename);
    81         Path path = Paths.get(filename);
    73         if (Files.isDirectory(path)) {
    82         if (Files.isDirectory(path)) {
    74             return makeGenerated(recording, path);
    83             return makeGenerated(recording, path);
    75         }
    84         }