This finishes off the GNU Classpath side of the memory pools (hopefully). Comments always welcome :)
Changelog:
2006-07-04 Andrew John Hughes <[EMAIL PROTECTED]>
* NEWS: Updated.
* doc/vmintegration.texinfo: Likewise.
* examples/gnu/classpath/examples/management/TestMemoryPool.java,
* gnu/java/lang/management/MemoryPoolMXBeanImpl.java:
New files.
* java/lang/management/ManagementFactory.java:
(getMemoryPoolMXBeans()): Implemented.
* vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
* vm/reference/java/lang/management/VMManagementFactory.java:
New files.
--
Andrew :-)
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.156
diff -u -3 -p -u -r1.156 NEWS
--- NEWS 2 Jul 2006 20:32:43 -0000 1.156
+++ NEWS 4 Jul 2006 21:30:58 -0000
@@ -69,6 +69,12 @@ Runtime interface changes:
and the number of objects eligible for garbage collection.
* VMCompilationMXBeanImpl is used to allow for optional compilation
time support for Just-In-Time compilers.
+* VMMemoryPoolMXBeanImpl is used to implement the low-level support
+ of the memory pool beans. Providing this interface requires
+ providing memory usage statistics for each supported bean.
+* VMManagementFactory provides the names of the memory pools,
+ memory managers and garbage collectors maintained by the virtual
+ machine. These are used to create the beans by the ManagementFactory.
New in release 0.91 (May 15, 2006)
Index: doc/vmintegration.texinfo
===================================================================
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.33
diff -u -3 -p -u -r1.33 vmintegration.texinfo
--- doc/vmintegration.texinfo 2 Jul 2006 20:32:43 -0000 1.33
+++ doc/vmintegration.texinfo 4 Jul 2006 21:30:58 -0000
@@ -203,6 +203,7 @@ implementation.
* java.lang.reflect::
* gnu.java.lang::
* gnu.java.lang.management::
+* java.lang.management::
* Classpath Callbacks::
@end menu
@@ -1262,7 +1263,7 @@ method calls the @code{VMInstrumentation
which must be implemented by the VM. The implementation should call the
@code{InstrumentationImpl.callTransformers} method.
[EMAIL PROTECTED] gnu.java.lang.management, Classpath Callbacks, gnu.java.lang,
Classpath Hooks
[EMAIL PROTECTED] gnu.java.lang.management, java.lang.management,
gnu.java.lang, Classpath Hooks
@section @code{gnu.java.lang.management}
@code{gnu.java.lang.management} provides the VM interfaces for the GNU
@@ -1274,6 +1275,7 @@ implementations of the management beans.
* gnu.java.lang.management.VMThreadMXBeanImpl::
* gnu.java.lang.management.VMMemoryMXBeanImpl::
* gnu.java.lang.management.VMCompilationMXBeanImpl::
+* gnu.java.lang.management.VMMemoryPoolMXBeanImpl::
@end menu
@node
gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management
@@ -1470,13 +1472,13 @@ output is turned or not, respectively.
verbose memory management output to be turned on and off.
@end itemize
[EMAIL PROTECTED]
gnu.java.lang.management.VMCompilationMXBeanImpl,,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management
[EMAIL PROTECTED]
gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMCompilationMXBeanImpl}
The @code{gnu.java.lang.management.CompilationMXBeanImpl} provides an
implementation of the optional @code{java.lang.management.CompilationMXBean}
interface, and is supported by VM functionality in the form of
[EMAIL PROTECTED] This provides a
[EMAIL PROTECTED] This provides a
single method for returning the number of milliseconds the virtual
machine's Just-In-Time (JIT) compiler has spent compiling. Even if
a JIT compiler is available and an instance of the bean supplied, this
@@ -1503,7 +1505,92 @@ Time support is implemented by the follo
number of milliseconds the JIT compiler has spent compiling.
@end itemize
[EMAIL PROTECTED] Classpath Callbacks, , gnu.java.lang.management, Classpath
Hooks
[EMAIL PROTECTED]
gnu.java.lang.management.VMMemoryPoolMXBeanImpl,,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management
[EMAIL PROTECTED] @code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}
+
+The @code{gnu.java.lang.management.MemoryPoolMXBeanImpl} provides an
+implementation of the optional @code{java.lang.management.MemoryPoolMXBean}
+interface, and is supported by VM functionality in the form of
[EMAIL PROTECTED] Providing
+this interface requires implementing a number of methods for each supported
+pool. These return statistics on memory usage, and, optionally, allows
+monitoring of when memory usage exceedes a preset threshold.
+
+Optional support is determined by the following properties:
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED]
@code{gnu.java.lang.management.CollectionUsageThresholdSupport} --
+This property should be present if the VM supports setting a collection
+usage threshold and monitoring when it is matched or exceeded. Collection
+usage thresholds are related to the remaining memory usage following a
+garbage collection cycle.
[EMAIL PROTECTED] @code{gnu.java.lang.management.UsageThresholdSupport} --
+This property should be present if the VM supports setting a
+usage threshold and monitoring when it is matched or exceeded.
[EMAIL PROTECTED] itemize
+
+The methods are as follows (all take a pool name as their
+first parameter):
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{(getCollectionUsage(String))} -- Returns a
[EMAIL PROTECTED] object, containing the
+memory usage statistics following a garbage collection cycle
+for the specified pool. This may also return @code{null} if
+the pool isn't an appropriate pool for this particular task.
[EMAIL PROTECTED] @code{(getCollectionUsageThreshold(String))} -- Returns
+the pool's collection usage threshold, if supported.
[EMAIL PROTECTED] @code{(getCollectionUsageThresholdCount(String))} -- Returns
+the number of times the specified pool has matched or exceeded
+its collection usage threshold, if supported.
[EMAIL PROTECTED] @code{(getMemoryManagerNames(String))} -- Returns a list
+of names of memory managers which manage the specified pool.
[EMAIL PROTECTED] @code{(getPeakUsage(String))} -- Returns a
[EMAIL PROTECTED] object for the peak
+usage level of the specified pool.
[EMAIL PROTECTED] @code{(getUsage(String))} -- Returns a
[EMAIL PROTECTED] object for the current
+usage level of the specified pool.
[EMAIL PROTECTED] @code{(getUsageThreshold(String))} -- Returns
+the pool's usage threshold, if supported.
[EMAIL PROTECTED] @code{(getUsageThresholdCount(String))} -- Returns
+the number of times the specified pool has matched or exceeded
+its usage threshold, if supported.
[EMAIL PROTECTED] @code{(isValid(String))} -- Returns true if the pool
+is still in use by the virtual machine.
[EMAIL PROTECTED] @code{(resetPeakUsage(String))} -- Resets the peak usage
+levels to the current usage levels for the specified pool.
[EMAIL PROTECTED] @code{(setCollectionUsageThreshold(String, long))} -- Sets
+the pool's collection usage threshold, if supported.
[EMAIL PROTECTED] @code{(setUsageThreshold(String, long))} -- Sets
+the pool's usage threshold, if supported.
[EMAIL PROTECTED] itemize
+
[EMAIL PROTECTED] java.lang.management, Classpath Callbacks,
gnu.java.lang.management, Classpath Hooks
[EMAIL PROTECTED] @code{java.lang.management}
+
[EMAIL PROTECTED] provides the VM interfaces for the GNU
+implementations of the management beans.
+
[EMAIL PROTECTED]
+* java.lang.management.VMManagementFactory::
[EMAIL PROTECTED] menu
+
[EMAIL PROTECTED]
java.lang.management.VMManagementFactory,,,java.lang.management
[EMAIL PROTECTED] @code{java.lang.management.VMManagementFactory}
+
+This VM interface provides the names of the memory pools, memory managers
+and garbage collectors for use by the
@code{java.lang.management.ManagementFactory}
+in creating lists of appropriate beans for these types of managed object.
+
+The methods are as follows:
+
[EMAIL PROTECTED] @bullet
[EMAIL PROTECTED] @code{(getMemoryPoolNames())} -- Returns a list of the names
+of the current memory pools in use by the virtual machine.
[EMAIL PROTECTED] itemize
+
[EMAIL PROTECTED] Classpath Callbacks, , java.lang.management, Classpath Hooks
Some of the classes you implement for the VM will need to call back to
package-private methods in Classpath:
Index: examples/gnu/classpath/examples/management/TestMemoryPool.java
===================================================================
RCS file: examples/gnu/classpath/examples/management/TestMemoryPool.java
diff -N examples/gnu/classpath/examples/management/TestMemoryPool.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ examples/gnu/classpath/examples/management/TestMemoryPool.java 4 Jul
2006 21:30:58 -0000
@@ -0,0 +1,93 @@
+/* TestMemoryPool.java -- Tests the memory pool 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.MemoryPoolMXBean;
+import java.lang.management.MemoryUsage;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class TestMemoryPool
+{
+
+ /**
+ * 1mb in bytes
+ */
+ private static final int MB = 1 << 20;
+
+ public static void main(String[] args)
+ {
+ Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
+ System.out.println("Bean: " + bean);
+ System.out.println("Name: " + bean.getName());
+ System.out.println("Collection usage: " + bean.getCollectionUsage());
+ boolean collectionUsage = bean.isCollectionUsageThresholdSupported();
+ System.out.println("Collection usage threshold supported: "
+ + collectionUsage);
+ if (collectionUsage)
+ {
+ System.out.println("Collection usage threshold: "
+ + bean.getCollectionUsageThreshold());
+ System.out.println("Setting collection usage threshold to 1MB ("
+ + MB + " bytes)");
+ bean.setCollectionUsageThreshold(MB);
+ System.out.println("Collection usage threshold: "
+ + bean.getCollectionUsageThreshold());
+ System.out.println("Collection usage threshold count: "
+ + bean.getCollectionUsageThresholdCount());
+ System.out.println("Collection usage threshold exceeded: "
+ + (bean.isCollectionUsageThresholdExceeded()
+ ? "yes" : "no"));
+ }
+ System.out.println("Memory manager names: "
+ + Arrays.toString(bean.getMemoryManagerNames()));
+ System.out.println("Peak usage: " + bean.getPeakUsage());
+ System.out.println("Current usage: " + bean.getUsage());
+ System.out.println("Resetting peak usage...");
+ bean.resetPeakUsage();
+ System.out.println("Peak usage: " + bean.getPeakUsage());
+ System.out.println("Current usage: " + bean.getUsage());
+ boolean usage = bean.isUsageThresholdSupported();
+ System.out.println("Usage threshold supported: " + usage);
+ if (usage)
+ {
+ System.out.println("Usage threshold: "
+ + bean.getUsageThreshold());
+ System.out.println("Setting usage threshold to 1MB ("
+ + MB + " bytes)");
+ bean.setUsageThreshold(MB);
+ System.out.println("Usage threshold: "
+ + bean.getUsageThreshold());
+ System.out.println("Usage threshold count: "
+ + bean.getUsageThresholdCount());
+ System.out.println("Usage threshold exceeded: "
+ + (bean.isUsageThresholdExceeded()
+ ? "yes" : "no"));
+ }
+ System.out.println("Valid: " + (bean.isValid() ? "yes" : "no"));
+ }
+ }
+}
Index: gnu/java/lang/management/MemoryPoolMXBeanImpl.java
===================================================================
RCS file: gnu/java/lang/management/MemoryPoolMXBeanImpl.java
diff -N gnu/java/lang/management/MemoryPoolMXBeanImpl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/lang/management/MemoryPoolMXBeanImpl.java 4 Jul 2006 21:30:58
-0000
@@ -0,0 +1,212 @@
+/* MemoryPoolMXBeanImpl.java - Implementation of a memory pool bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information about one of the memory
+ * resources or pools used by the current invocation of the
+ * virtual machine. An instance of this bean for each memory
+ * pool is obtained by calling
+ * [EMAIL PROTECTED] ManagementFactory#getMemoryPoolMXBeans()}.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public final class MemoryPoolMXBeanImpl
+ extends BeanImpl
+ implements MemoryPoolMXBean
+{
+
+ /**
+ * The name of the pool.
+ */
+ private String name;
+
+ /**
+ * Constant for collection usage threshold.
+ */
+ private static final String COLLECTION_USAGE_THRESHOLD =
+ "gnu.java.lang.management.CollectionUsageThresholdSupport";
+
+ /**
+ * Constant for thread time support.
+ */
+ private static final String USAGE_THRESHOLD =
+ "gnu.java.lang.management.UsageThresholdSupport";
+
+ /**
+ * Constructs a new <code>MemoryPoolMXBeanImpl</code>.
+ *
+ * @param name the name of the pool this bean represents.
+ */
+ public MemoryPoolMXBeanImpl(String name)
+ {
+ this.name = name;
+ }
+
+ public MemoryUsage getCollectionUsage()
+ {
+ return VMMemoryPoolMXBeanImpl.getCollectionUsage(name);
+ }
+
+ public long getCollectionUsageThreshold()
+ {
+ if (isCollectionUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getCollectionUsageThreshold(name);
+ else
+ throw new UnsupportedOperationException("A collection usage "+
+ "threshold is not supported.");
+ }
+
+ public long getCollectionUsageThresholdCount()
+ {
+ if (isCollectionUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getCollectionUsageThresholdCount(name);
+ else
+ throw new UnsupportedOperationException("A collection usage "+
+ "threshold is not supported.");
+ }
+
+ public String[] getMemoryManagerNames()
+ {
+ return VMMemoryPoolMXBeanImpl.getMemoryManagerNames(name);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public MemoryUsage getPeakUsage()
+ {
+ if (isValid())
+ return VMMemoryPoolMXBeanImpl.getPeakUsage(name);
+ else
+ return null;
+ }
+
+ public MemoryUsage getUsage()
+ {
+ if (isValid())
+ return VMMemoryPoolMXBeanImpl.getUsage(name);
+ else
+ return null;
+ }
+
+ public long getUsageThreshold()
+ {
+ if (isUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getUsageThreshold(name);
+ else
+ throw new UnsupportedOperationException("A usage threshold " +
+ "is not supported.");
+ }
+
+ public long getUsageThresholdCount()
+ {
+ if (isUsageThresholdSupported())
+ return VMMemoryPoolMXBeanImpl.getUsageThresholdCount(name);
+ else
+ throw new UnsupportedOperationException("A usage threshold " +
+ "is not supported.");
+ }
+
+ public boolean isCollectionUsageThresholdExceeded()
+ {
+ return getCollectionUsage().getUsed() >= getCollectionUsageThreshold();
+ }
+
+ public boolean isCollectionUsageThresholdSupported()
+ {
+ return SystemProperties.getProperty(COLLECTION_USAGE_THRESHOLD) != null;
+ }
+
+ public boolean isUsageThresholdExceeded()
+ {
+ return getUsage().getUsed() >= getUsageThreshold();
+ }
+
+ public boolean isUsageThresholdSupported()
+ {
+ return SystemProperties.getProperty(USAGE_THRESHOLD) != null;
+ }
+
+ public boolean isValid()
+ {
+ return VMMemoryPoolMXBeanImpl.isValid(name);
+ }
+
+ public void resetPeakUsage()
+ {
+ checkControlPermissions();
+ VMMemoryPoolMXBeanImpl.resetPeakUsage(name);
+ }
+
+ public void setCollectionUsageThreshold(long threshold)
+ {
+ checkControlPermissions();
+ if (threshold < 0)
+ throw new IllegalArgumentException("Threshold of " + threshold +
+ "is less than zero.");
+ if (isCollectionUsageThresholdSupported())
+ VMMemoryPoolMXBeanImpl.setCollectionUsageThreshold(name, threshold);
+ else
+ throw new UnsupportedOperationException("A collection usage "+
+ "threshold is not supported.");
+ }
+
+ public void setUsageThreshold(long threshold)
+ {
+ checkControlPermissions();
+ if (threshold < 0)
+ throw new IllegalArgumentException("Threshold of " + threshold +
+ "is less than zero.");
+ if (isUsageThresholdSupported())
+ VMMemoryPoolMXBeanImpl.setUsageThreshold(name, threshold);
+ else
+ throw new UnsupportedOperationException("A usage threshold " +
+ "is not supported.");
+ }
+
+}
+
Index: java/lang/management/ManagementFactory.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/java/lang/management/ManagementFactory.java,v
retrieving revision 1.8
diff -u -3 -p -u -r1.8 ManagementFactory.java
--- java/lang/management/ManagementFactory.java 2 Jul 2006 20:32:43 -0000
1.8
+++ java/lang/management/ManagementFactory.java 4 Jul 2006 21:30:59 -0000
@@ -43,9 +43,13 @@ import gnu.java.lang.management.ClassLoa
import gnu.java.lang.management.CompilationMXBeanImpl;
import gnu.java.lang.management.OperatingSystemMXBeanImpl;
import gnu.java.lang.management.MemoryMXBeanImpl;
+import gnu.java.lang.management.MemoryPoolMXBeanImpl;
import gnu.java.lang.management.RuntimeMXBeanImpl;
import gnu.java.lang.management.ThreadMXBeanImpl;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* <p>
* Provides access to the system's management beans via a series
@@ -189,4 +193,19 @@ public class ManagementFactory
return compilationBean;
}
+ /**
+ * Returns the memory pool beans for the running
+ * virtual machine. These may change during the course
+ * of execution.
+ *
+ * @return a list of memory pool beans, one for each pool.
+ */
+ public static List getMemoryPoolMXBeans()
+ {
+ List poolBeans = new ArrayList();
+ String[] names = VMManagementFactory.getMemoryPoolNames();
+ for (int a = 0; a < names.length; ++a)
+ poolBeans.add(new MemoryPoolMXBeanImpl(names[a]));
+ return poolBeans;
+ }
}
Index: vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
===================================================================
RCS file: vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
diff -N vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ vm/reference/gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java 4 Jul
2006 21:31:00 -0000
@@ -0,0 +1,186 @@
+/* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.MemoryUsage;
+
+/**
+ * Provides access to information on the memory resources or
+ * pools used by the current invocation of the virtual machine.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+final class VMMemoryPoolMXBeanImpl
+{
+
+ /**
+ * Returns memory usage statistics for the specified pool
+ * just after a best-effort attempt to free memory. This
+ * is valid only for certain garbage collectors.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a [EMAIL PROTECTED] java.lang.management.MemoryUsage} object
+ * containing the statistics or <code>null</code>
+ * if this pool does not support such statistics.
+ */
+ static native MemoryUsage getCollectionUsage(String name);
+
+ /**
+ * Returns the collection usage threshold for the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined). The value is initially zero.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the collection usage threshold.
+ */
+ static native long getCollectionUsageThreshold(String name);
+
+ /**
+ * Returns the number of times the collection usage threshold
+ * has been met or exceeded by the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the collection usage threshold count.
+ */
+ static native long getCollectionUsageThresholdCount(String name);
+
+ /**
+ * Returns an array of names of memory managers which manage
+ * the specified pool.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a list of memory managers for the pool.
+ */
+ static native String[] getMemoryManagerNames(String name);
+
+ /**
+ * Returns the peak usage level of the specified pool.
+ * This is only called if the pool is valid.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a [EMAIL PROTECTED] java.lang.management.MemoryUsage} object
+ * containing the statistics.
+ */
+ static native MemoryUsage getPeakUsage(String name);
+
+ /**
+ * Returns the current usage level of the specified pool.
+ * This is only called if the pool is valid.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return a [EMAIL PROTECTED] java.lang.management.MemoryUsage} object
+ * containing the statistics.
+ */
+ static native MemoryUsage getUsage(String name);
+
+ /**
+ * Returns the usage threshold for the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined). The value is initially defined by the
+ * virtual machine.
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the usage threshold.
+ */
+ static native long getUsageThreshold(String name);
+
+ /**
+ * Returns the number of times the usage threshold
+ * has been met or exceeded by the specified pool.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to obtain statistics on.
+ * @return the usage threshold count.
+ */
+ static native long getUsageThresholdCount(String name);
+
+ /**
+ * Returns true if the specified pool is still valid i.e.
+ * it is still in use by the virtual machine.
+ *
+ * @param name the name of the pool to check the validity of.
+ * @return true if the pool is valid.
+ */
+ static native boolean isValid(String name);
+
+ /**
+ * Resets the peak usage level to the current usage level for
+ * the specified pool.
+ *
+ * @param name the name of the pool to reset the peak usage of.
+ */
+ static native void resetPeakUsage(String name);
+
+ /**
+ * Sets the collection usage threshold for the specified
+ * pool to the supplied value.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to set the threshold of.
+ * @param threshold the new threshold level.
+ */
+ static native void setCollectionUsageThreshold(String name, long threshold);
+
+ /**
+ * Sets the usage threshold for the specified pool to the supplied value.
+ * This is only called if this functionality is supported
+ * by the virtual machine (i.e. the appropriate property,
+ * <code>gnu.java.lang.management.UsageThresholdSupport</code>,
+ * is defined).
+ *
+ * @param name the name of the pool to set the threshold of.
+ * @param threshold the new threshold level.
+ */
+ static native void setUsageThreshold(String name, long threshold);
+
+}
Index: vm/reference/java/lang/management/VMManagementFactory.java
===================================================================
RCS file: vm/reference/java/lang/management/VMManagementFactory.java
diff -N vm/reference/java/lang/management/VMManagementFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ vm/reference/java/lang/management/VMManagementFactory.java 4 Jul 2006
21:31:00 -0000
@@ -0,0 +1,59 @@
+/* VMManagementFactory.java - VM interface for obtaining system beans.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides lists of resources required by the
+ * [EMAIL PROTECTED] java.lang.management.ManagementFactory} for
+ * creating beans.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+final class VMManagementFactory
+{
+
+ /**
+ * Return a list of the names of the currently available
+ * memory pools within the virtual machine.
+ *
+ * @return a list of memory pool names.
+ */
+ static native String[] getMemoryPoolNames();
+
+}
signature.asc
Description: Digital signature
