From a07c56d504ec51366a32f696d20e779b1bac79e6 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Sun, 2 Jul 2006 21:43:13 +0000 Subject: 2006-07-02 Andrew John Hughes * Merge of HEAD --> generics-branch for 2006/06/27 to 2006/07/02. --- java/lang/management/ManagementFactory.java | 57 +++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'java/lang/management/ManagementFactory.java') diff --git a/java/lang/management/ManagementFactory.java b/java/lang/management/ManagementFactory.java index 5f99bbe1d..6e8010089 100644 --- a/java/lang/management/ManagementFactory.java +++ b/java/lang/management/ManagementFactory.java @@ -37,11 +37,14 @@ exception statement from your version. */ package java.lang.management; -import gnu.classpath.NotImplementedException; +import gnu.classpath.SystemProperties; import gnu.java.lang.management.ClassLoadingMXBeanImpl; +import gnu.java.lang.management.CompilationMXBeanImpl; import gnu.java.lang.management.OperatingSystemMXBeanImpl; +import gnu.java.lang.management.MemoryMXBeanImpl; import gnu.java.lang.management.RuntimeMXBeanImpl; +import gnu.java.lang.management.ThreadMXBeanImpl; /** *

@@ -78,6 +81,21 @@ public class ManagementFactory */ private static ClassLoadingMXBean classLoadingBean; + /** + * The thread bean. + */ + private static ThreadMXBean threadBean; + + /** + * The memory bean. + */ + private static MemoryMXBean memoryBean; + + /** + * The compilation bean (may remain null). + */ + private static CompilationMXBean compilationBean; + /** * Private constructor to prevent instance creation. */ @@ -133,9 +151,42 @@ public class ManagementFactory * this virtual machine. */ public static ThreadMXBean getThreadMXBean() - throws NotImplementedException { - return null; + if (threadBean == null) + threadBean = new ThreadMXBeanImpl(); + return threadBean; + } + + /** + * Returns the memory management bean for the running + * virtual machine. + * + * @return an instance of {@link MemoryMXBean} for + * this virtual machine. + */ + public static MemoryMXBean getMemoryMXBean() + { + if (memoryBean == null) + memoryBean = new MemoryMXBeanImpl(); + return memoryBean; + } + + /** + * Returns the compilation bean for the running + * virtual machine, if supported. Otherwise, + * it returns null. + * + * @return an instance of {@link CompilationMXBean} for + * this virtual machine, or null + * if the virtual machine doesn't include + * a Just-In-Time (JIT) compiler. + */ + public static CompilationMXBean getCompilationMXBean() + { + if (compilationBean == null && + SystemProperties.getProperty("gnu.java.compiler.name") != null) + compilationBean = new CompilationMXBeanImpl(); + return compilationBean; } } -- cgit v1.2.1