< prev index next >

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

Print this page
rev 58228 : 8238665: Add JFR event for direct memory statistics

*** 37,48 **** import javax.management.RuntimeOperationsException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; - import jdk.internal.access.JavaNioAccess; import jdk.internal.access.SharedSecrets; import java.util.ArrayList; import java.util.List; import java.lang.reflect.UndeclaredThrowableException; --- 37,49 ---- import javax.management.RuntimeOperationsException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import jdk.internal.access.SharedSecrets; + import jdk.internal.misc.VM; + import jdk.internal.misc.VM.BufferPool; import java.util.ArrayList; import java.util.List; import java.lang.reflect.UndeclaredThrowableException;
*** 50,59 **** --- 51,61 ---- import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Optional; + import java.util.stream.Collectors; /** * ManagementFactoryHelper provides static factory methods to create * instances of the management interface. */
*** 335,365 **** } static final PlatformLoggingMXBean MBEAN = getInstance(); } ! private static List<BufferPoolMXBean> bufferPools = null; ! public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() { if (bufferPools == null) { ! bufferPools = new ArrayList<>(2); ! bufferPools.add(createBufferPoolMXBean(SharedSecrets.getJavaNioAccess() ! .getDirectBufferPool())); ! bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl ! .getMappedBufferPool())); ! bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl ! .getSyncMappedBufferPool())); } return bufferPools; } private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool"; /** * Creates management interface for the given buffer pool. */ private static BufferPoolMXBean ! createBufferPoolMXBean(final JavaNioAccess.BufferPool pool) { return new BufferPoolMXBean() { private volatile ObjectName objname; // created lazily @Override public ObjectName getObjectName() { --- 337,367 ---- } static final PlatformLoggingMXBean MBEAN = getInstance(); } ! private static volatile List<BufferPoolMXBean> bufferPools; ! public static List<BufferPoolMXBean> getBufferPoolMXBeans() { if (bufferPools == null) { ! synchronized (ManagementFactoryHelper.class) { ! if (bufferPools == null) { ! bufferPools = VM.getBufferPools().stream() ! .map(ManagementFactoryHelper::createBufferPoolMXBean) ! .collect(Collectors.toList()); ! } ! } } return bufferPools; } private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool"; /** * Creates management interface for the given buffer pool. */ private static BufferPoolMXBean ! createBufferPoolMXBean(final BufferPool pool) { return new BufferPoolMXBean() { private volatile ObjectName objname; // created lazily @Override public ObjectName getObjectName() {
< prev index next >