src/java.management/share/classes/sun/management/ManagementFactoryHelper.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke


  34 import javax.management.ObjectName;
  35 import javax.management.RuntimeOperationsException;
  36 import java.security.AccessController;
  37 import java.security.PrivilegedActionException;
  38 import java.security.PrivilegedExceptionAction;
  39 
  40 import jdk.internal.misc.JavaNioAccess;
  41 import jdk.internal.misc.SharedSecrets;
  42 import sun.util.logging.LoggingSupport;
  43 import java.util.ArrayList;
  44 import java.util.List;
  45 
  46 /**
  47  * ManagementFactoryHelper provides static factory methods to create
  48  * instances of the management interface.
  49  */
  50 public class ManagementFactoryHelper {
  51     static {
  52         // make sure that the management lib is loaded within
  53         // java.lang.management.ManagementFactory
  54         sun.misc.Unsafe.getUnsafe().ensureClassInitialized(ManagementFactory.class);
  55     }
  56 
  57     private static final VMManagement jvm = new VMManagementImpl();
  58 
  59     private ManagementFactoryHelper() {};
  60 
  61     public static VMManagement getVMManagement() {
  62         return jvm;
  63     }
  64 
  65     private static ClassLoadingImpl    classMBean = null;
  66     private static MemoryImpl          memoryMBean = null;
  67     private static ThreadImpl          threadMBean = null;
  68     private static RuntimeImpl         runtimeMBean = null;
  69     private static CompilationImpl     compileMBean = null;
  70     private static BaseOperatingSystemImpl osMBean = null;
  71 
  72     public static synchronized ClassLoadingMXBean getClassLoadingMXBean() {
  73         if (classMBean == null) {
  74             classMBean = new ClassLoadingImpl(jvm);




  34 import javax.management.ObjectName;
  35 import javax.management.RuntimeOperationsException;
  36 import java.security.AccessController;
  37 import java.security.PrivilegedActionException;
  38 import java.security.PrivilegedExceptionAction;
  39 
  40 import jdk.internal.misc.JavaNioAccess;
  41 import jdk.internal.misc.SharedSecrets;
  42 import sun.util.logging.LoggingSupport;
  43 import java.util.ArrayList;
  44 import java.util.List;
  45 
  46 /**
  47  * ManagementFactoryHelper provides static factory methods to create
  48  * instances of the management interface.
  49  */
  50 public class ManagementFactoryHelper {
  51     static {
  52         // make sure that the management lib is loaded within
  53         // java.lang.management.ManagementFactory
  54         jdk.internal.misc.Unsafe.getUnsafe().ensureClassInitialized(ManagementFactory.class);
  55     }
  56 
  57     private static final VMManagement jvm = new VMManagementImpl();
  58 
  59     private ManagementFactoryHelper() {};
  60 
  61     public static VMManagement getVMManagement() {
  62         return jvm;
  63     }
  64 
  65     private static ClassLoadingImpl    classMBean = null;
  66     private static MemoryImpl          memoryMBean = null;
  67     private static ThreadImpl          threadMBean = null;
  68     private static RuntimeImpl         runtimeMBean = null;
  69     private static CompilationImpl     compileMBean = null;
  70     private static BaseOperatingSystemImpl osMBean = null;
  71 
  72     public static synchronized ClassLoadingMXBean getClassLoadingMXBean() {
  73         if (classMBean == null) {
  74             classMBean = new ClassLoadingImpl(jvm);