changeset 50194:2ae4cd9d809d

8198337: -XX:StartFlightRecording=dumponexit=true,disk=false doesn't work Reviewed-by: mgronlun
author egahlin
date Mon, 21 May 2018 14:46:12 +0200
parents 49c3e91c424f
children ec881a19d294
files src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java
diffstat 3 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java	Mon May 21 11:33:59 2018 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java	Mon May 21 14:46:12 2018 +0200
@@ -245,7 +245,7 @@
         RequestEngine.doChunkBegin();
     }
 
-    synchronized void stop(PlatformRecording recording) {
+    synchronized void stop(PlatformRecording recording, WriteableUserPath alternativePath) {
         RecordingState state = recording.getState();
 
         if (Utils.isAfter(state, RecordingState.RUNNING)) {
@@ -278,7 +278,7 @@
                 }
             } else {
                 // last memory
-                dumpMemoryToDestination(recording);
+                dumpMemoryToDestination(recording, alternativePath);
             }
             jvm.endRecording_();
             disableEvents();
@@ -314,8 +314,8 @@
         }
     }
 
-    private void dumpMemoryToDestination(PlatformRecording recording) {
-        WriteableUserPath dest = recording.getDestination();
+    private void dumpMemoryToDestination(PlatformRecording recording, WriteableUserPath alternativePath) {
+        WriteableUserPath dest = alternativePath != null ? alternativePath : recording.getDestination();
         if (dest != null) {
             MetadataRepository.getInstance().setOutput(dest.getText());
             recording.clearDestination();
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java	Mon May 21 11:33:59 2018 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java	Mon May 21 14:46:12 2018 +0200
@@ -161,7 +161,7 @@
                 stopTask.cancel();
                 stopTask = null;
             }
-            recorder.stop(this);
+            recorder.stop(this, alternativePath);
             String endTExt = reason == null ? "" : ". Reason \"" + reason + "\".";
             Logger.log(LogTag.JFR, LogLevel.INFO, "Stopped recording \"" + recording.getName() + "\" (" + recording.getId()+ ")" + endTExt);
             this.stopTime = Instant.now();
--- a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java	Mon May 21 11:33:59 2018 +0200
+++ b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java	Mon May 21 14:46:12 2018 +0200
@@ -56,6 +56,13 @@
                 "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=profile",
                 "jdk.jfr.startupargs.TestDumpOnExit$TestMain"
         );
+        // Test a memory recording without a security manager
+        testDumponExit(() -> findJFRFileInCurrentDirectory(),
+                "-Xlog:jfr=trace",
+                "-XX:StartFlightRecording=dumponexit=true,disk=false",
+                "jdk.jfr.startupargs.TestDumpOnExit$TestMain"
+        );
+
         // Test with security manager and a file name relative to current directory
         testDumponExit(() -> dumpPath,
                 "-Xlog:jfr=trace",