summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-05 21:44:08 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-07-05 21:44:08 +0000
commitb83e32d3889ad696f36ec9832956e47d71d17107 (patch)
treebb8e41573bffcca3882084810485ccd6b4dfe9a9 /examples
parent2e2aa3c140f1a093fe940e510b58d99134dfc90e (diff)
downloadclasspath-b83e32d3889ad696f36ec9832956e47d71d17107.tar.gz
2006-07-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
* NEWS: Updated. * doc/vmintegration.texinfo: Likewise. * examples/gnu/classpath/examples/management/TestGarbageCollector.java, * examples/gnu/classpath/examples/management/TestMemoryManager.java, * gnu/java/lang/management/GarbageCollectorMXBeanImpl.java, * gnu/java/lang/management/MemoryManagerMXBeanImpl.java, * java/lang/management/GarbageCollectorMXBean.java: New files. * java/lang/management/ManagementFactory.java: (getGarbageCollectorMXBeans()): Implemented. (getMemoryManagerMXBeans()): Likewise. * vm/reference/gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, * vm/reference/gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java: New files. * vm/reference/java/lang/management/VMManagementFactory.java: (getMemoryManagerNames()): Added. (getGarbageCollectorNames()): Added.
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/management/TestGarbageCollector.java53
-rw-r--r--examples/gnu/classpath/examples/management/TestMemoryManager.java49
2 files changed, 102 insertions, 0 deletions
diff --git a/examples/gnu/classpath/examples/management/TestGarbageCollector.java b/examples/gnu/classpath/examples/management/TestGarbageCollector.java
new file mode 100644
index 000000000..5d6d56797
--- /dev/null
+++ b/examples/gnu/classpath/examples/management/TestGarbageCollector.java
@@ -0,0 +1,53 @@
+/* TestGarbageCollector.java -- Tests the garbage collector beans.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class TestGarbageCollector
+{
+
+ public static void main(String[] args)
+ {
+ Iterator beans = ManagementFactory.getGarbageCollectorMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ GarbageCollectorMXBean bean = (GarbageCollectorMXBean) beans.next();
+ System.out.println("Bean: " + bean);
+ System.out.println("Name: " + bean.getName());
+ System.out.println("Memory pool names: "
+ + Arrays.toString(bean.getMemoryPoolNames()));
+ System.out.println("Is valid: "
+ + (bean.isValid() ? "yes" : "no"));
+ System.out.println("Collection count: "
+ + bean.getCollectionCount());
+ System.out.println("Collection time: "
+ + bean.getCollectionTime() + "ms");
+ }
+ }
+}
+
+
+
diff --git a/examples/gnu/classpath/examples/management/TestMemoryManager.java b/examples/gnu/classpath/examples/management/TestMemoryManager.java
new file mode 100644
index 000000000..30a0c985b
--- /dev/null
+++ b/examples/gnu/classpath/examples/management/TestMemoryManager.java
@@ -0,0 +1,49 @@
+/* TestMemoryManager.java -- Tests the memory manager beans.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryManagerMXBean;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class TestMemoryManager
+{
+
+ public static void main(String[] args)
+ {
+ Iterator beans = ManagementFactory.getMemoryManagerMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryManagerMXBean bean = (MemoryManagerMXBean) beans.next();
+ System.out.println("Bean: " + bean);
+ System.out.println("Name: " + bean.getName());
+ System.out.println("Memory pool names: "
+ + Arrays.toString(bean.getMemoryPoolNames()));
+ System.out.println("Is valid: "
+ + (bean.isValid() ? "yes" : "no"));
+ }
+ }
+}
+
+
+