summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--NEWS8
-rw-r--r--doc/vmintegration.texinfo30
-rw-r--r--gnu/java/lang/management/ClassLoadingMXBeanImpl.java85
-rw-r--r--java/lang/management/ClassLoadingMXBean.java103
-rw-r--r--java/lang/management/ManagementFactory.java20
-rw-r--r--vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java89
7 files changed, 346 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3aea971f4..2e7698e93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2006-06-24 Andrew John Hughes <gnu_andrew@member.fsf.org>
+ * NEWS,
+ * doc/vmintegration.texinfo:
+ Updated with information on new VM interface.
+ * gnu/java/lang/management/ClassLoadingMXBeanImpl.java,
+ * java/lang/management/ClassLoadingMXBean.java:
+ New files implementing the class loading bean.
+ * java/lang/management/ManagementFactory.java:
+ (getClassLoadingMXBean()): Implemented.
+ * vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java:
+ New VM interface file.
+
+2006-06-24 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
* gnu/java/lang/management/RuntimeMXBeanImpl.java:
(isBootClassPathSupported()): Use SystemProperties
rather than System.getProperty.
diff --git a/NEWS b/NEWS
index fc226a5fe..a36224864 100644
--- a/NEWS
+++ b/NEWS
@@ -38,7 +38,7 @@ Runtime interface changes:
* The method gnu.java.io.PlatformHelper.toCanonicalForm() has been
replaced with a JNI implementation of VMFile.toCanonicalForm() for
GNU/Posix systems.
-* An new class, VMRuntimeMXBeanImpl, is used to implement
+* A new class, VMRuntimeMXBeanImpl, is used to implement
the low-level support of the runtime management bean.
VMs should use it to supply the input arguments and start
time of the VM. In addition, one of sun.boot.class.path
@@ -48,6 +48,12 @@ Runtime interface changes:
reference implementation. We've also added a couple other new VM
classes to support the JSR 166 code -- sun.reflect.Reflection and
sun.reflect.misc.ReflectUtil.
+* Another new class, VMClassLoadingMXBeanImpl, is used to implement
+ the low-level support of the class loading management bean.
+ VMs need to supply it with information about how many classes
+ are currently loaded, how many have been unloaded and whether
+ verbose class loading output is on or off. Provision should also
+ be made for the latter to be toggled at runtime.
New in release 0.91 (May 15, 2006)
diff --git a/doc/vmintegration.texinfo b/doc/vmintegration.texinfo
index d0e628311..7c0c0b521 100644
--- a/doc/vmintegration.texinfo
+++ b/doc/vmintegration.texinfo
@@ -1267,9 +1267,10 @@ implementations of the management beans.
@menu
* gnu.java.lang.management.VMRuntimeMXBeanImpl::
+* gnu.java.lang.management.VMClassLoadingMXBeanImpl::
@end menu
-@node gnu.java.lang.management.VMRuntimeMXBeanImpl,,,gnu.java.lang.management
+@node gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMRuntimeMXBeanImpl}
The @code{gnu.java.lang.management.RuntimeMXBeanImpl} provides an
@@ -1311,6 +1312,33 @@ The virtual machine also needs to provide either the
property in order to support the optional boot class path
retrieval functionality.
+@node gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management
+@subsection @code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}
+
+The @code{gnu.java.lang.management.ClassLoadingMXBeanImpl} provides an
+implementation of the @code{java.lang.management.ClassLoadingMXBean} interface,
+and is supported by VM functionality in the form of
+@code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}. This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean. Implementing
+this bean requires the VM to monitor when classes are loaded and unloaded,
+and provide the option of verbose class loading output.
+
+The methods are as follows:
+
+@itemize @bullet
+@item @code{(getLoadedClassCount())} -- This should return
+the number of classes that are currently loaded by the VM.
+@item @code{(getUnloadedClassCount())} -- This should return
+the number of classes that have been loaded by the VM, but
+have since been unloaded.
+@item @code{(isVerbose())} -- This should return @code{true}
+or @code{false}, depending on whether verbose class loading
+output is turned or not, respectively.
+@item @code{(setVerbose(boolean))} -- This should allow the
+verbose class loading output to be turned on and off.
+@end itemize
+
@node Classpath Callbacks, , gnu.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:
diff --git a/gnu/java/lang/management/ClassLoadingMXBeanImpl.java b/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
new file mode 100644
index 000000000..8c488f130
--- /dev/null
+++ b/gnu/java/lang/management/ClassLoadingMXBeanImpl.java
@@ -0,0 +1,85 @@
+/* ClassLoadingMXBeanImpl.java - Implementation of a class loading 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 java.lang.management.ClassLoadingMXBean;
+import java.lang.management.ManagementPermission;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class ClassLoadingMXBeanImpl
+ implements ClassLoadingMXBean
+{
+
+ public int getLoadedClassCount()
+ {
+ return VMClassLoadingMXBeanImpl.getLoadedClassCount();
+ }
+
+ public int getTotalLoadedClassCount()
+ {
+ return getLoadedClassCount() + getUnloadedClassCount();
+ }
+
+ public int getUnloadedClassCount()
+ {
+ return VMClassLoadingMXBeanImpl.getUnloadedClassCount();
+ }
+
+ public boolean isVerbose()
+ {
+ return VMClassLoadingMXBeanImpl.isVerbose();
+ }
+
+ public void setVerbose(boolean verbose)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new ManagementPermission("control"));
+ VMClassLoadingMXBeanImpl.setVerbose(verbose);
+ }
+
+}
+
diff --git a/java/lang/management/ClassLoadingMXBean.java b/java/lang/management/ClassLoadingMXBean.java
new file mode 100644
index 000000000..a0914e891
--- /dev/null
+++ b/java/lang/management/ClassLoadingMXBean.java
@@ -0,0 +1,103 @@
+/* ClassLoadingMXBean.java - Interface for a class loading 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 java.lang.management;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface ClassLoadingMXBean
+{
+
+ /**
+ * Returns the number of classes currently loaded by
+ * the virtual machine.
+ *
+ * @return the number of loaded classes.
+ */
+ int getLoadedClassCount();
+
+ /**
+ * Returns the total number of classes loaded by the
+ * virtual machine since it was started. This is the
+ * sum of the currently loaded classes and those that
+ * have been unloaded.
+ *
+ * @return the total number of classes that have been
+ * loaded by the virtual machine since it started.
+ */
+ int getTotalLoadedClassCount();
+
+ /**
+ * Returns the number of classes that have been unloaded
+ * by the virtual machine since it was started.
+ *
+ * @return the number of unloaded classes.
+ */
+ int getUnloadedClassCount();
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when classes are loaded and unloaded. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ boolean isVerbose();
+
+ /**
+ * Turns on or off the emission of additional information
+ * when classes are loaded and unloaded. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ * @throws SecurityException if a security manager exists and
+ * denies ManagementPermission("control").
+ */
+ void setVerbose(boolean verbose);
+
+}
+
diff --git a/java/lang/management/ManagementFactory.java b/java/lang/management/ManagementFactory.java
index b3db1b96d..a5a2d6acf 100644
--- a/java/lang/management/ManagementFactory.java
+++ b/java/lang/management/ManagementFactory.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package java.lang.management;
+import gnu.java.lang.management.ClassLoadingMXBeanImpl;
import gnu.java.lang.management.OperatingSystemMXBeanImpl;
import gnu.java.lang.management.RuntimeMXBeanImpl;
@@ -71,6 +72,11 @@ public class ManagementFactory
private static RuntimeMXBean runtimeBean;
/**
+ * The class loading management bean.
+ */
+ private static ClassLoadingMXBean classLoadingBean;
+
+ /**
* Private constructor to prevent instance creation.
*/
private ManagementFactory() {}
@@ -103,4 +109,18 @@ public class ManagementFactory
return runtimeBean;
}
+ /**
+ * Returns the class loading management bean for the
+ * running virtual machine.
+ *
+ * @return an instance of {@link ClassLoadingMXBean} for
+ * this virtual machine.
+ */
+ public static ClassLoadingMXBean getClassLoadingMXBean()
+ {
+ if (classLoadingBean == null)
+ classLoadingBean = new ClassLoadingMXBeanImpl();
+ return classLoadingBean;
+ }
+
}
diff --git a/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java b/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
new file mode 100644
index 000000000..9e90e86c8
--- /dev/null
+++ b/vm/reference/gnu/java/lang/management/VMClassLoadingMXBeanImpl.java
@@ -0,0 +1,89 @@
+/* VMClassLoadingMXBeanImpl.java - VM impl. of a class loading 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;
+
+/**
+ * Provides access to information about the class loading
+ * behaviour of the current invocation of the virtual
+ * machine. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+final class VMClassLoadingMXBeanImpl
+{
+
+ /**
+ * Returns the number of classes currently loaded by
+ * the virtual machine.
+ *
+ * @return the number of loaded classes.
+ */
+ static native int getLoadedClassCount();
+
+ /**
+ * Returns the number of classes that have been unloaded
+ * by the virtual machine since it was started.
+ *
+ * @return the number of unloaded classes.
+ */
+ static native int getUnloadedClassCount();
+
+ /**
+ * Returns true if the virtual machine will emit additional
+ * information when classes are loaded and unloaded. The
+ * format of the output is left up to the virtual machine.
+ *
+ * @return true if verbose class loading output is on.
+ */
+ static native boolean isVerbose();
+
+ /**
+ * Turns on or off the emission of additional information
+ * when classes are loaded and unloaded. The format of the
+ * output is left up to the virtual machine. This method
+ * may be called by multiple threads concurrently, but there
+ * is only one global setting of verbosity that is affected.
+ *
+ * @param verbose the new setting for verbose class loading
+ * output.
+ */
+ static native void setVerbose(boolean verbose);
+
+}