< prev index next >
src/hotspot/share/services/diagnosticCommand.cpp
Print this page
rev 49501 : 8200384: jcmd help output should be sorted
Reviewed-by:
@@ -135,13 +135,19 @@
"STRING", false) {
_dcmdparser.add_dcmd_option(&_all);
_dcmdparser.add_dcmd_argument(&_cmd);
};
+
+static int compare_strings(const char** s1, const char** s2) {
+ return ::strcmp(*s1, *s2);
+}
+
void HelpDCmd::execute(DCmdSource source, TRAPS) {
if (_all.value()) {
GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list(source);
+ cmd_list->sort(compare_strings);
for (int i = 0; i < cmd_list->length(); i++) {
DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
strlen(cmd_list->at(i)));
output()->print_cr("%s%s", factory->name(),
factory->is_enabled() ? "" : " [disabled]");
@@ -178,10 +184,11 @@
output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
}
} else {
output()->print_cr("The following commands are available:");
GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list(source);
+ cmd_list->sort(compare_strings);
for (int i = 0; i < cmd_list->length(); i++) {
DCmdFactory* factory = DCmdFactory::factory(source, cmd_list->at(i),
strlen(cmd_list->at(i)));
output()->print_cr("%s%s", factory->name(),
factory->is_enabled() ? "" : " [disabled]");
< prev index next >