8151099: java.lang.management.ManagementFactory.getPlatformMXBeans() should work even if jdk.management is not present.
authorvtewari
Wed, 26 Oct 2016 14:58:14 +0530
changeset 42052 b3a1c6c4f86e
parent 42051 0264f170da65
child 42053 74a66849b650
8151099: java.lang.management.ManagementFactory.getPlatformMXBeans() should work even if jdk.management is not present. Summary: Removed dependency of java.management over jdk.management. Reviewed-by: mchung, dfuchs, dholmes Contributed-by: amit.sapre@oracle.com
hotspot/src/share/vm/services/management.cpp
hotspot/src/share/vm/services/management.hpp
--- a/hotspot/src/share/vm/services/management.cpp	Mon Oct 24 14:12:32 2016 -0700
+++ b/hotspot/src/share/vm/services/management.cpp	Wed Oct 26 14:58:14 2016 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -173,6 +173,20 @@
 
 Klass* Management::load_and_initialize_klass(Symbol* sh, TRAPS) {
   Klass* k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL);
+  Klass* ik = initialize_klass(k, CHECK_NULL);
+  return ik;
+}
+
+Klass* Management::load_and_initialize_klass_or_null(Symbol* sh, TRAPS) {
+  Klass* k = SystemDictionary::resolve_or_null(sh, CHECK_NULL);
+  if (k == NULL) {
+     return NULL;
+  }
+  Klass* ik = initialize_klass(k, CHECK_NULL);
+  return ik;
+}
+
+Klass* Management::initialize_klass(Klass* k, TRAPS) {
   instanceKlassHandle ik (THREAD, k);
   if (ik->should_be_initialized()) {
     ik->initialize(CHECK_NULL);
@@ -255,7 +269,8 @@
 
 Klass* Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(TRAPS) {
   if (_garbageCollectorExtImpl_klass == NULL) {
-    _garbageCollectorExtImpl_klass = load_and_initialize_klass(vmSymbols::com_sun_management_internal_GarbageCollectorExtImpl(), CHECK_NULL);
+    _garbageCollectorExtImpl_klass =
+                load_and_initialize_klass_or_null(vmSymbols::com_sun_management_internal_GarbageCollectorExtImpl(), CHECK_NULL);
   }
   return _garbageCollectorExtImpl_klass;
 }
--- a/hotspot/src/share/vm/services/management.hpp	Mon Oct 24 14:12:32 2016 -0700
+++ b/hotspot/src/share/vm/services/management.hpp	Wed Oct 26 14:58:14 2016 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,6 +53,8 @@
   static Klass*             _sensor_klass;
   static Klass*             _threadInfo_klass;
   static Klass* load_and_initialize_klass(Symbol* sh, TRAPS);
+  static Klass* load_and_initialize_klass_or_null(Symbol* sh, TRAPS);
+  static Klass* initialize_klass(Klass* k, TRAPS);
 
 public:
   static void init();