changeset 59218:dd1034e6350f

8244508: JFR: FlightRecorderOptions reset date format Reviewed-by: mgronlun
author egahlin
date Fri, 08 May 2020 15:34:14 +0200
parents 730eb308516a
children 4c6190f99f3a
files src/hotspot/share/jfr/dcmd/jfrDcmds.cpp src/hotspot/share/jfr/dcmd/jfrDcmds.hpp src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java
diffstat 5 files changed, 80 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp	Fri May 08 08:13:15 2020 -0400
+++ b/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp	Fri May 08 15:34:14 2020 +0200
@@ -563,7 +563,8 @@
   _thread_buffer_size("thread_buffer_size", "Size of a thread buffer", "MEMORY SIZE", false, "8k"),
   _memory_size("memorysize", "Overall memory size, ", "MEMORY SIZE", false, "10m"),
   _max_chunk_size("maxchunksize", "Size of an individual disk chunk", "MEMORY SIZE", false, "12m"),
-  _sample_threads("samplethreads", "Activate Thread sampling", "BOOLEAN", false, "true") {
+  _sample_threads("samplethreads", "Activate Thread sampling", "BOOLEAN", false, "true"),
+  _verbose(true) {
   _dcmdparser.add_dcmd_option(&_repository_path);
   _dcmdparser.add_dcmd_option(&_dump_path);
   _dcmdparser.add_dcmd_option(&_stack_depth);
@@ -650,7 +651,7 @@
 
   static const char klass[] = "jdk/jfr/internal/dcmd/DCmdConfigure";
   static const char method[] = "execute";
-  static const char signature[] = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;"
+  static const char signature[] = "(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/Integer;"
     "Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;"
     "Ljava/lang/Long;Ljava/lang/Boolean;)Ljava/lang/String;";
 
@@ -658,6 +659,7 @@
   execute_args.set_receiver(h_dcmd_instance);
 
   // params
+  execute_args.push_int(_verbose ? 1 : 0);
   execute_args.push_jobject(repository_path);
   execute_args.push_jobject(dump_path);
   execute_args.push_jobject(stack_depth);
--- a/src/hotspot/share/jfr/dcmd/jfrDcmds.hpp	Fri May 08 08:13:15 2020 -0400
+++ b/src/hotspot/share/jfr/dcmd/jfrDcmds.hpp	Fri May 08 15:34:14 2020 +0200
@@ -151,9 +151,13 @@
   DCmdArgument<MemorySizeArgument> _memory_size;
   DCmdArgument<MemorySizeArgument> _max_chunk_size;
   DCmdArgument<bool>  _sample_threads;
+  bool _verbose;
 
  public:
   JfrConfigureFlightRecorderDCmd(outputStream* output, bool heap);
+  void set_verbose(bool verbose) {
+    _verbose = verbose;
+  }
   static const char* name() {
     return "JFR.configure";
   }
--- a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp	Fri May 08 08:13:15 2020 -0400
+++ b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp	Fri May 08 15:34:14 2020 +0200
@@ -366,6 +366,7 @@
   configure._sample_threads.set_is_set(_dcmd_sample_threads.is_set());
   configure._sample_threads.set_value(_dcmd_sample_threads.value());
 
+  configure.set_verbose(false);
   configure.execute(DCmd_Source_Internal, THREAD);
 
   if (HAS_PENDING_EXCEPTION) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java	Fri May 08 08:13:15 2020 -0400
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java	Fri May 08 15:34:14 2020 +0200
@@ -32,7 +32,6 @@
 import jdk.jfr.internal.LogTag;
 import jdk.jfr.internal.Logger;
 import jdk.jfr.internal.Options;
-import jdk.jfr.internal.PlatformRecorder;
 import jdk.jfr.internal.PrivateAccess;
 import jdk.jfr.internal.Repository;
 import jdk.jfr.internal.SecuritySupport.SafePath;
@@ -62,6 +61,7 @@
      */
     public String execute
     (
+            boolean verbose,
             String repositoryPath,
             String dumpPath,
             Integer stackDepth,
@@ -99,66 +99,86 @@
             } catch (Exception e) {
                 throw new DCmdException("Could not use " + repositoryPath + " as repository. " + e.getMessage(), e);
             }
-            printRepositoryPath();
+            if (verbose) {
+                printRepositoryPath();
+            }
             updated = true;
         }
 
         if (dumpPath != null)  {
             Options.setDumpPath(new SafePath(dumpPath));
             Logger.log(LogTag.JFR, LogLevel.INFO, "Emergency dump path set to " + dumpPath);
-            printDumpPath();
+           if (verbose) {
+               printDumpPath();
+           }
             updated = true;
         }
 
         if (stackDepth != null)  {
             Options.setStackDepth(stackDepth);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Stack depth set to " + stackDepth);
-            printStackDepth();
+            if (verbose) {
+                printStackDepth();
+            }
             updated = true;
         }
 
         if (globalBufferCount != null)  {
             Options.setGlobalBufferCount(globalBufferCount);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Global buffer count set to " + globalBufferCount);
-            printGlobalBufferCount();
+            if (verbose) {
+                printGlobalBufferCount();
+            }
             updated = true;
         }
 
         if (globalBufferSize != null)  {
             Options.setGlobalBufferSize(globalBufferSize);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Global buffer size set to " + globalBufferSize);
-            printGlobalBufferSize();
+            if (verbose) {
+                printGlobalBufferSize();
+            }
             updated = true;
         }
 
         if (threadBufferSize != null)  {
             Options.setThreadBufferSize(threadBufferSize);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Thread buffer size set to " + threadBufferSize);
-            printThreadBufferSize();
+            if (verbose) {
+                printThreadBufferSize();
+            }
             updated = true;
         }
 
         if (memorySize != null) {
             Options.setMemorySize(memorySize);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Memory size set to " + memorySize);
-            printMemorySize();
+            if (verbose) {
+                printMemorySize();
+            }
             updated = true;
         }
 
         if (maxChunkSize != null)  {
             Options.setMaxChunkSize(maxChunkSize);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Max chunk size set to " + maxChunkSize);
-            printMaxChunkSize();
+            if (verbose) {
+                printMaxChunkSize();
+            }
             updated = true;
         }
 
         if (sampleThreads != null)  {
             Options.setSampleThreads(sampleThreads);
             Logger.log(LogTag.JFR, LogLevel.INFO, "Sample threads set to " + sampleThreads);
-            printSampleThreads();
+            if (verbose) {
+                printSampleThreads();
+            }
             updated = true;
         }
-
+        if (!verbose) {
+            return "";
+        }
         if (!updated) {
             println("Current configuration:");
             println();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java	Fri May 08 15:34:14 2020 +0200
@@ -0,0 +1,40 @@
+package jdk.jfr.startupargs;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+/**
+ * @test
+ * @summary Checks that locale is respected when using -XX:FlightRecorderOptions
+ *          See JDK-8244508
+ * @key jfr
+ * @requires vm.hasJFR
+ * @modules jdk.jfr
+ * @library /test/lib
+ * @run main jdk.jfr.startupargs.TestOptionsWithLocale
+ */
+public class TestOptionsWithLocale {
+
+    public static class PrintDate {
+        public static void main(String... args) {
+            GregorianCalendar date = new GregorianCalendar(2020, Calendar.JANUARY, 1);
+            DateFormat formatter = DateFormat.getDateTimeInstance();
+            System.out.println(formatter.format(date.getTime()));
+        }
+    }
+
+    public static void main(String... args) throws IOException {
+        ProcessBuilder pb = ProcessTools.createTestJvm(
+                "-Duser.country=DE",
+                "-Duser.language=de",
+                "-XX:FlightRecorderOptions:stackdepth=128",
+                PrintDate.class.getName());
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("01.01.2020, 00:00:00");
+    }
+}