changeset 12239:0207c729b674

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
author vtewari
date Wed, 26 Oct 2016 14:58:14 +0530
parents dbbfe9e68ad9
children 95c6654fa2ee
files src/share/vm/services/management.cpp src/share/vm/services/management.hpp
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/services/management.cpp	Mon Oct 24 14:12:32 2016 -0700
+++ b/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/src/share/vm/services/management.hpp	Mon Oct 24 14:12:32 2016 -0700
+++ b/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();