8244508: JFR: FlightRecorderOptions reset date format

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2020-05-08 15:34:14 +02:00
parent e544a6afc5
commit f3519016c7
5 changed files with 80 additions and 13 deletions
src
hotspot/share/jfr
jdk.jfr/share/classes/jdk/jfr/internal/dcmd
test/jdk/jdk/jfr/startupargs

@ -563,7 +563,8 @@ JfrConfigureFlightRecorderDCmd::JfrConfigureFlightRecorderDCmd(outputStream* out
_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 @@ void JfrConfigureFlightRecorderDCmd::execute(DCmdSource source, TRAPS) {
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 @@ void JfrConfigureFlightRecorderDCmd::execute(DCmdSource source, TRAPS) {
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);

@ -151,9 +151,13 @@ class JfrConfigureFlightRecorderDCmd : public DCmdWithParser {
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";
}

@ -366,6 +366,7 @@ bool JfrOptionSet::configure(TRAPS) {
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) {

@ -32,7 +32,6 @@ import jdk.jfr.internal.LogLevel;
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 @@ final class DCmdConfigure extends AbstractDCmd {
*/
public String execute
(
boolean verbose,
String repositoryPath,
String dumpPath,
Integer stackDepth,
@ -99,66 +99,86 @@ final class DCmdConfigure extends AbstractDCmd {
} 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();

@ -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");
}
}