8042901: Allow com.sun.management to be in a different module to java.lang.management
Reviewed-by: mchung, dfuchs, erikj, jbachorik
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Apr 17 10:53:31 2015 +0200
@@ -531,18 +531,17 @@
template(java_lang_management_ThreadState, "java/lang/management/ThreadState") \
template(java_lang_management_MemoryUsage, "java/lang/management/MemoryUsage") \
template(java_lang_management_ThreadInfo, "java/lang/management/ThreadInfo") \
- template(sun_management_ManagementFactory, "sun/management/ManagementFactory") \
template(sun_management_Sensor, "sun/management/Sensor") \
template(sun_management_Agent, "sun/management/Agent") \
- template(sun_management_DiagnosticCommandImpl, "sun/management/DiagnosticCommandImpl") \
- template(sun_management_GarbageCollectorImpl, "sun/management/GarbageCollectorImpl") \
+ template(com_sun_management_internal_DiagnosticCommandImpl, "com/sun/management/internal/DiagnosticCommandImpl") \
+ template(com_sun_management_internal_GarbageCollectorExtImpl,"com/sun/management/internal/GarbageCollectorExtImpl") \
template(sun_management_ManagementFactoryHelper, "sun/management/ManagementFactoryHelper") \
template(getDiagnosticCommandMBean_name, "getDiagnosticCommandMBean") \
template(getDiagnosticCommandMBean_signature, "()Lcom/sun/management/DiagnosticCommandMBean;") \
template(getGcInfoBuilder_name, "getGcInfoBuilder") \
- template(getGcInfoBuilder_signature, "()Lsun/management/GcInfoBuilder;") \
+ template(getGcInfoBuilder_signature, "()Lcom/sun/management/internal/GcInfoBuilder;") \
template(com_sun_management_GcInfo, "com/sun/management/GcInfo") \
- template(com_sun_management_GcInfo_constructor_signature, "(Lsun/management/GcInfoBuilder;JJJ[Ljava/lang/management/MemoryUsage;[Ljava/lang/management/MemoryUsage;[Ljava/lang/Object;)V") \
+ template(com_sun_management_GcInfo_constructor_signature, "(Lcom/sun/management/internal/GcInfoBuilder;JJJ[Ljava/lang/management/MemoryUsage;[Ljava/lang/management/MemoryUsage;[Ljava/lang/Object;)V") \
template(createGCNotification_name, "createGCNotification") \
template(createGCNotification_signature, "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/sun/management/GcInfo;)V") \
template(createDiagnosticFrameworkNotification_name, "createDiagnosticFrameworkNotification") \
--- a/hotspot/src/share/vm/services/diagnosticFramework.cpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/services/diagnosticFramework.cpp Fri Apr 17 10:53:31 2015 +0200
@@ -455,12 +455,12 @@
}
if (notif) {
- Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK);
- instanceKlassHandle mgmt_factory_helper_klass(THREAD, k);
+ Klass* k = Management::com_sun_management_internal_DiagnosticCommandImpl_klass(CHECK);
+ instanceKlassHandle dcmd_mbean_klass(THREAD, k);
JavaValue result(T_OBJECT);
JavaCalls::call_static(&result,
- mgmt_factory_helper_klass,
+ dcmd_mbean_klass,
vmSymbols::getDiagnosticCommandMBean_name(),
vmSymbols::getDiagnosticCommandMBean_signature(),
CHECK);
@@ -468,12 +468,9 @@
instanceOop m = (instanceOop) result.get_jobject();
instanceHandle dcmd_mbean_h(THREAD, m);
- Klass* k2 = Management::sun_management_DiagnosticCommandImpl_klass(CHECK);
- instanceKlassHandle dcmd_mbean_klass(THREAD, k2);
-
- if (!dcmd_mbean_h->is_a(k2)) {
+ if (!dcmd_mbean_h->is_a(k)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
- "ManagementFactory.getDiagnosticCommandMBean didn't return a DiagnosticCommandMBean instance");
+ "DiagnosticCommandImpl.getDiagnosticCommandMBean didn't return a DiagnosticCommandMBean instance");
}
JavaValue result2(T_VOID);
--- a/hotspot/src/share/vm/services/gcNotifier.cpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/services/gcNotifier.cpp Fri Apr 17 10:53:31 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, 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
@@ -77,7 +77,7 @@
static Handle getGcInfoBuilder(GCMemoryManager *gcManager,TRAPS) {
- Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK_NH);
+ Klass* k = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK_NH);
instanceKlassHandle gcMBeanKlass (THREAD, k);
instanceOop i = gcManager->get_memory_manager_instance(THREAD);
@@ -214,8 +214,8 @@
Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
Handle objCause = java_lang_String::create_from_str(request->gcCause, CHECK);
+ Klass* k = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK);
- Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
instanceKlassHandle gc_mbean_klass(THREAD, k);
instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
--- a/hotspot/src/share/vm/services/management.cpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/services/management.cpp Fri Apr 17 10:53:31 2015 +0200
@@ -64,18 +64,16 @@
PerfVariable* Management::_end_vm_creation_time = NULL;
PerfVariable* Management::_vm_init_done_time = NULL;
+Klass* Management::_diagnosticCommandImpl_klass = NULL;
+Klass* Management::_garbageCollectorExtImpl_klass = NULL;
+Klass* Management::_garbageCollectorMXBean_klass = NULL;
+Klass* Management::_gcInfo_klass = NULL;
+Klass* Management::_managementFactoryHelper_klass = NULL;
+Klass* Management::_memoryManagerMXBean_klass = NULL;
+Klass* Management::_memoryPoolMXBean_klass = NULL;
+Klass* Management::_memoryUsage_klass = NULL;
Klass* Management::_sensor_klass = NULL;
Klass* Management::_threadInfo_klass = NULL;
-Klass* Management::_memoryUsage_klass = NULL;
-Klass* Management::_memoryPoolMXBean_klass = NULL;
-Klass* Management::_memoryManagerMXBean_klass = NULL;
-Klass* Management::_garbageCollectorMXBean_klass = NULL;
-Klass* Management::_managementFactory_klass = NULL;
-Klass* Management::_garbageCollectorImpl_klass = NULL;
-Klass* Management::_gcInfo_klass = NULL;
-Klass* Management::_diagnosticCommandImpl_klass = NULL;
-Klass* Management::_managementFactoryHelper_klass = NULL;
-
jmmOptionalSupport Management::_optional_support = {0};
TimeStamp Management::_stamp;
@@ -255,18 +253,18 @@
return _sensor_klass;
}
-Klass* Management::sun_management_ManagementFactory_klass(TRAPS) {
- if (_managementFactory_klass == NULL) {
- _managementFactory_klass = load_and_initialize_klass(vmSymbols::sun_management_ManagementFactory(), CHECK_NULL);
+Klass* Management::sun_management_ManagementFactoryHelper_klass(TRAPS) {
+ if (_managementFactoryHelper_klass == NULL) {
+ _managementFactoryHelper_klass = load_and_initialize_klass(vmSymbols::sun_management_ManagementFactoryHelper(), CHECK_NULL);
}
- return _managementFactory_klass;
+ return _managementFactoryHelper_klass;
}
-Klass* Management::sun_management_GarbageCollectorImpl_klass(TRAPS) {
- if (_garbageCollectorImpl_klass == NULL) {
- _garbageCollectorImpl_klass = load_and_initialize_klass(vmSymbols::sun_management_GarbageCollectorImpl(), CHECK_NULL);
+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);
}
- return _garbageCollectorImpl_klass;
+ return _garbageCollectorExtImpl_klass;
}
Klass* Management::com_sun_management_GcInfo_klass(TRAPS) {
@@ -276,20 +274,13 @@
return _gcInfo_klass;
}
-Klass* Management::sun_management_DiagnosticCommandImpl_klass(TRAPS) {
+Klass* Management::com_sun_management_internal_DiagnosticCommandImpl_klass(TRAPS) {
if (_diagnosticCommandImpl_klass == NULL) {
- _diagnosticCommandImpl_klass = load_and_initialize_klass(vmSymbols::sun_management_DiagnosticCommandImpl(), CHECK_NULL);
+ _diagnosticCommandImpl_klass = load_and_initialize_klass(vmSymbols::com_sun_management_internal_DiagnosticCommandImpl(), CHECK_NULL);
}
return _diagnosticCommandImpl_klass;
}
-Klass* Management::sun_management_ManagementFactoryHelper_klass(TRAPS) {
- if (_managementFactoryHelper_klass == NULL) {
- _managementFactoryHelper_klass = load_and_initialize_klass(vmSymbols::sun_management_ManagementFactoryHelper(), CHECK_NULL);
- }
- return _managementFactoryHelper_klass;
-}
-
static void initialize_ThreadInfo_constructor_arguments(JavaCallArguments* args, ThreadSnapshot* snapshot, TRAPS) {
Handle snapshot_thread(THREAD, snapshot->threadObj());
--- a/hotspot/src/share/vm/services/management.hpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/services/management.hpp Fri Apr 17 10:53:31 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -42,18 +42,16 @@
static TimeStamp _stamp; // Timestamp since vm init done time
// Management klasses
+ static Klass* _diagnosticCommandImpl_klass;
+ static Klass* _garbageCollectorExtImpl_klass;
+ static Klass* _garbageCollectorMXBean_klass;
+ static Klass* _gcInfo_klass;
+ static Klass* _managementFactoryHelper_klass;
+ static Klass* _memoryManagerMXBean_klass;
+ static Klass* _memoryPoolMXBean_klass;
+ static Klass* _memoryUsage_klass;
static Klass* _sensor_klass;
static Klass* _threadInfo_klass;
- static Klass* _memoryUsage_klass;
- static Klass* _memoryPoolMXBean_klass;
- static Klass* _memoryManagerMXBean_klass;
- static Klass* _garbageCollectorMXBean_klass;
- static Klass* _managementFactory_klass;
- static Klass* _garbageCollectorImpl_klass;
- static Klass* _diagnosticCommandImpl_klass;
- static Klass* _managementFactoryHelper_klass;
- static Klass* _gcInfo_klass;
-
static Klass* load_and_initialize_klass(Symbol* sh, TRAPS);
public:
@@ -93,17 +91,15 @@
static Klass* java_lang_management_MemoryPoolMXBean_klass(TRAPS);
static Klass* java_lang_management_MemoryManagerMXBean_klass(TRAPS);
static Klass* java_lang_management_GarbageCollectorMXBean_klass(TRAPS);
+ static Klass* sun_management_ManagementFactoryHelper_klass(TRAPS)
+ NOT_MANAGEMENT_RETURN_(NULL);
static Klass* sun_management_Sensor_klass(TRAPS)
NOT_MANAGEMENT_RETURN_(NULL);
- static Klass* sun_management_ManagementFactory_klass(TRAPS)
- NOT_MANAGEMENT_RETURN_(NULL);
- static Klass* sun_management_GarbageCollectorImpl_klass(TRAPS)
+ static Klass* com_sun_management_internal_GarbageCollectorExtImpl_klass(TRAPS)
NOT_MANAGEMENT_RETURN_(NULL);
static Klass* com_sun_management_GcInfo_klass(TRAPS)
NOT_MANAGEMENT_RETURN_(NULL);
- static Klass* sun_management_DiagnosticCommandImpl_klass(TRAPS)
- NOT_MANAGEMENT_RETURN_(NULL);
- static Klass* sun_management_ManagementFactoryHelper_klass(TRAPS)
+ static Klass* com_sun_management_internal_DiagnosticCommandImpl_klass(TRAPS)
NOT_MANAGEMENT_RETURN_(NULL);
static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, TRAPS);
--- a/hotspot/src/share/vm/services/memoryManager.cpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/services/memoryManager.cpp Fri Apr 17 10:53:31 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -98,8 +98,7 @@
if (mgr_obj == NULL) {
// It's ok for more than one thread to execute the code up to the locked region.
// Extra manager instances will just be gc'ed.
- Klass* k = Management::sun_management_ManagementFactory_klass(CHECK_0);
- instanceKlassHandle ik(THREAD, k);
+ Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0);
Handle mgr_name = java_lang_String::create_from_str(name(), CHECK_0);
@@ -110,7 +109,14 @@
Symbol* method_name = NULL;
Symbol* signature = NULL;
if (is_gc_memory_manager()) {
+ Klass* extKlass = Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(CHECK_0);
+ // com.sun.management.GarbageCollectorMXBean is in jdk.management module which may not be present.
+ if (extKlass != NULL) {
+ k = extKlass;
+ }
+
method_name = vmSymbols::createGarbageCollector_name();
+
signature = vmSymbols::createGarbageCollector_signature();
args.push_oop(Handle()); // Argument 2 (for future extension)
} else {
@@ -118,6 +124,8 @@
signature = vmSymbols::createMemoryManager_signature();
}
+ instanceKlassHandle ik(THREAD, k);
+
JavaCalls::call_static(&result,
ik,
method_name,
--- a/hotspot/src/share/vm/services/memoryPool.cpp Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/src/share/vm/services/memoryPool.cpp Fri Apr 17 10:53:31 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -86,7 +86,7 @@
if (pool_obj == NULL) {
// It's ok for more than one thread to execute the code up to the locked region.
// Extra pool instances will just be gc'ed.
- Klass* k = Management::sun_management_ManagementFactory_klass(CHECK_NULL);
+ Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_NULL);
instanceKlassHandle ik(THREAD, k);
Handle pool_name = java_lang_String::create_from_str(_name, CHECK_NULL);
--- a/hotspot/test/gc/TestSmallHeap.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/TestSmallHeap.java Fri Apr 17 10:53:31 2015 +0200
@@ -58,9 +58,11 @@
*/
import com.oracle.java.testlibrary.*;
+import com.sun.management.HotSpotDiagnosticMXBean;
+import java.lang.management.ManagementFactory;
import static com.oracle.java.testlibrary.Asserts.*;
+
import sun.hotspot.WhiteBox;
-import sun.management.ManagementFactoryHelper;
public class TestSmallHeap {
@@ -69,7 +71,9 @@
int pageSize = wb.getVMPageSize();
int heapBytesPerCard = 512;
long expectedMaxHeap = pageSize * heapBytesPerCard;
- String maxHeap = ManagementFactoryHelper.getDiagnosticMXBean().getVMOption("MaxHeapSize").getValue();
+ String maxHeap
+ = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption("MaxHeapSize").getValue();
assertEQ(Long.parseLong(maxHeap), expectedMaxHeap);
}
}
--- a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java Fri Apr 17 10:53:31 2015 +0200
@@ -33,14 +33,15 @@
* @run main/othervm -XX:G1HeapRegionSize=64m -Xmx256m TestG1HeapRegionSize 33554432
*/
-import sun.management.ManagementFactoryHelper;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
+import java.lang.management.ManagementFactory;
public class TestG1HeapRegionSize {
public static void main(String[] args) {
- HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
+ HotSpotDiagnosticMXBean diagnostic =
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
String expectedValue = getExpectedValue(args);
VMOption option = diagnostic.getVMOption("UseG1GC");
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java Fri Apr 17 10:53:31 2015 +0200
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015,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
@@ -21,7 +21,6 @@
* questions.
*/
-import sun.management.ManagementFactoryHelper;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
@@ -31,6 +30,7 @@
import java.util.Arrays;
import com.oracle.java.testlibrary.*;
+import java.lang.management.ManagementFactory;
import sun.hotspot.WhiteBox;
class DetermineMaxHeapForCompressedOops {
@@ -43,7 +43,8 @@
class TestUseCompressedOopsErgoTools {
private static long getCompressedClassSpaceSize() {
- HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
+ HotSpotDiagnosticMXBean diagnostic =
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
return Long.parseLong(option.getValue());
@@ -174,4 +175,3 @@
return expect(flags, false, false, 0);
}
}
-
--- a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java Fri Apr 17 10:53:31 2015 +0200
@@ -34,11 +34,11 @@
* TestHumongousShrinkHeap
*/
+import com.sun.management.HotSpotDiagnosticMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;
import java.util.ArrayList;
import java.util.List;
-import sun.management.ManagementFactoryHelper;
import static com.oracle.java.testlibrary.Asserts.*;
public class TestHumongousShrinkHeap {
@@ -83,9 +83,11 @@
"committed free heap size is not less than committed full heap size, heap hasn't been shrunk?%n"
+ "%s = %s%n%s = %s",
MIN_FREE_RATIO_FLAG_NAME,
- ManagementFactoryHelper.getDiagnosticMXBean().getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
MAX_FREE_RATIO_FLAG_NAME,
- ManagementFactoryHelper.getDiagnosticMXBean().getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
));
}
--- a/hotspot/test/gc/g1/TestShrinkDefragmentedHeap.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/g1/TestShrinkDefragmentedHeap.java Fri Apr 17 10:53:31 2015 +0200
@@ -39,10 +39,10 @@
import java.lang.management.MemoryUsage;
import java.util.ArrayList;
import java.util.List;
-import sun.management.ManagementFactoryHelper;
import static com.oracle.java.testlibrary.Asserts.*;
import com.oracle.java.testlibrary.ProcessTools;
import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.sun.management.HotSpotDiagnosticMXBean;
public class TestShrinkDefragmentedHeap {
// Since we store all the small objects, they become old and old regions are also allocated at the bottom of the heap
@@ -144,9 +144,11 @@
"committed free heap size is not less than committed full heap size, heap hasn't been shrunk?%n"
+ "%s = %s%n%s = %s",
MIN_FREE_RATIO_FLAG_NAME,
- ManagementFactoryHelper.getDiagnosticMXBean().getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
MAX_FREE_RATIO_FLAG_NAME,
- ManagementFactoryHelper.getDiagnosticMXBean().getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
);
}
--- a/hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java Fri Apr 17 10:53:31 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -25,14 +25,11 @@
* Common helpers for TestSummarizeRSetStats* tests
*/
-import sun.management.ManagementFactoryHelper;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
import com.oracle.java.testlibrary.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.lang.Thread;
+import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Arrays;
@@ -74,7 +71,8 @@
// the VM is currently run using G1GC, i.e. trying to test G1 functionality.
public static boolean testingG1GC() {
- HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
+ HotSpotDiagnosticMXBean diagnostic =
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
VMOption option = diagnostic.getVMOption("UseG1GC");
if (option.getValue().equals("false")) {
@@ -150,4 +148,3 @@
}
}
}
-
--- a/hotspot/test/gc/parallelScavenge/TestDynShrinkHeap.java Thu Apr 16 19:27:43 2015 +0000
+++ b/hotspot/test/gc/parallelScavenge/TestDynShrinkHeap.java Fri Apr 17 10:53:31 2015 +0200
@@ -33,8 +33,8 @@
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;
import java.util.ArrayList;
-import sun.management.ManagementFactoryHelper;
import static com.oracle.java.testlibrary.Asserts.assertLessThan;
+import com.sun.management.HotSpotDiagnosticMXBean;
public class TestDynShrinkHeap {
@@ -63,9 +63,11 @@
"committed free heap size is not less than committed full heap size, heap hasn't been shrunk?%n"
+ "%s = %s%n%s = %s",
MIN_FREE_RATIO_FLAG_NAME,
- ManagementFactoryHelper.getDiagnosticMXBean().getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption(MIN_FREE_RATIO_FLAG_NAME).getValue(),
MAX_FREE_RATIO_FLAG_NAME,
- ManagementFactoryHelper.getDiagnosticMXBean().getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
+ ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class)
+ .getVMOption(MAX_FREE_RATIO_FLAG_NAME).getValue()
));
}