Merge
authorjbachorik
Thu, 02 Apr 2015 07:44:55 +0000
changeset 30135 bbb14e0a0c79
parent 30133 232561e6df52 (current diff)
parent 30134 ecd7b08105e9 (diff)
child 30136 1c5202fa105b
child 30137 effb5513d392
child 30139 a2ae06b774e5
Merge
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Apr 02 02:20:54 2015 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Apr 02 07:44:55 2015 +0000
@@ -559,6 +559,7 @@
   template(startRemoteAgent_name,                      "startRemoteManagementAgent")                              \
   template(startLocalAgent_name,                       "startLocalManagementAgent")                               \
   template(stopRemoteAgent_name,                       "stopRemoteManagementAgent")                               \
+  template(getAgentStatus_name,                        "getManagementAgentStatus")                                \
   template(java_lang_management_ThreadInfo_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;)V") \
   template(java_lang_management_ThreadInfo_with_locks_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;[Ljava/lang/Object;[I[Ljava/lang/Object;)V") \
   template(long_long_long_long_void_signature,         "(JJJJ)V")                                                 \
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp	Thu Apr 02 02:20:54 2015 +0000
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp	Thu Apr 02 07:44:55 2015 +0000
@@ -81,6 +81,7 @@
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
+  DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false));
 
 }
 
@@ -708,6 +709,38 @@
     JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
 }
 
+JMXStatusDCmd::JMXStatusDCmd(outputStream *output, bool heap_allocated) :
+  DCmd(output, heap_allocated) {
+  // do nothing
+}
+
+void JMXStatusDCmd::execute(DCmdSource source, TRAPS) {
+  ResourceMark rm(THREAD);
+  HandleMark hm(THREAD);
+
+  // Load and initialize the sun.management.Agent class
+  // invoke getManagementAgentStatus() method to generate the status info
+  // throw java.lang.NoSuchMethodError if method doesn't exist
+
+  Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+  instanceKlassHandle ik (THREAD, k);
+
+  JavaValue result(T_OBJECT);
+  JavaCalls::call_static(&result, ik, vmSymbols::getAgentStatus_name(), vmSymbols::void_string_signature(), CHECK);
+
+  jvalue* jv = (jvalue*) result.get_value_addr();
+  oop str = (oop) jv->l;
+  if (str != NULL) {
+      char* out = java_lang_String::as_utf8_string(str);
+      if (out) {
+          output()->print_cr("%s", out);
+          return;
+      }
+  }
+  output()->print_cr("Error obtaining management agent status");
+}
+
 VMDynamicLibrariesDCmd::VMDynamicLibrariesDCmd(outputStream *output, bool heap_allocated) :
   DCmd(output, heap_allocated) {
   // do nothing
--- a/hotspot/src/share/vm/services/diagnosticCommand.hpp	Thu Apr 02 02:20:54 2015 +0000
+++ b/hotspot/src/share/vm/services/diagnosticCommand.hpp	Thu Apr 02 07:44:55 2015 +0000
@@ -452,6 +452,29 @@
   virtual void execute(DCmdSource source, TRAPS);
 };
 
+// Print the JMX system status
+class JMXStatusDCmd : public DCmd {
+public:
+  JMXStatusDCmd(outputStream *output, bool heap_allocated);
+
+  static const char *name() {
+    return "ManagementAgent.status";
+  }
+
+  static const char *description() {
+    return "Print the management agent status.";
+  }
+
+  static const JavaPermission permission() {
+    JavaPermission p = {"java.lang.management.ManagementPermission",
+                        "monitor", NULL};
+    return p;
+  }
+
+  virtual void execute(DCmdSource source, TRAPS);
+
+};
+
 class RotateGCLogDCmd : public DCmd {
 public:
   RotateGCLogDCmd(outputStream* output, bool heap) : DCmd(output, heap) {}