diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index 240f3604cc1..b807a42661c 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -884,21 +884,17 @@ void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) { EventLogDCmd::EventLogDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), _log("log", "Name of log to be printed. If omitted, all logs are printed.", "STRING", false, nullptr), - _max("max", "Maximum number of events to be printed (newest first). If omitted, all events are printed.", "STRING", false, nullptr) + _max("max", "Maximum number of events to be printed (newest first). If omitted or zero, all events are printed.", "INT", false, "0") { _dcmdparser.add_dcmd_option(&_log); _dcmdparser.add_dcmd_option(&_max); } void EventLogDCmd::execute(DCmdSource source, TRAPS) { - const char* max_value = _max.value(); - int max = -1; - if (max_value != nullptr) { - char* endptr = nullptr; - if (!parse_integer(max_value, &max)) { - output()->print_cr("Invalid max option: \"%s\".", max_value); - return; - } + int max = (int)_max.value(); + if (max < 0) { + output()->print_cr("Invalid max option: \"%d\".", max); + return; } const char* log_name = _log.value(); if (log_name != nullptr) { diff --git a/src/hotspot/share/services/diagnosticCommand.hpp b/src/hotspot/share/services/diagnosticCommand.hpp index c8e26504ece..92e5849cbcd 100644 --- a/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/hotspot/share/services/diagnosticCommand.hpp @@ -889,7 +889,7 @@ public: class EventLogDCmd : public DCmdWithParser { protected: DCmdArgument _log; - DCmdArgument _max; + DCmdArgument _max; public: static int num_arguments() { return 2; } EventLogDCmd(outputStream* output, bool heap); diff --git a/src/jdk.jcmd/share/man/jcmd.md b/src/jdk.jcmd/share/man/jcmd.md index 448dfdd3051..2d2e08bc9f5 100644 --- a/src/jdk.jcmd/share/man/jcmd.md +++ b/src/jdk.jcmd/share/man/jcmd.md @@ -836,7 +836,7 @@ The following commands are available: - `log`: (Optional) Name of log to be printed. If omitted, all logs are printed. (STRING, no default value) - `max`: (Optional) Maximum number of events to be printed (newest first). - If omitted, all events are printed. (STRING, no default value) + If omitted or zero, all events are printed. (INT, 0) `VM.flags` \[*options*\] : Print the VM flag options and their current values.