commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-cp] classpath ChangeLog NEWS doc/vmintegration.texi...


From: Andrew John Hughes
Subject: [commit-cp] classpath ChangeLog NEWS doc/vmintegration.texi...
Date: Sun, 11 Jun 2006 21:57:15 +0000

CVSROOT:        /cvsroot/classpath
Module name:    classpath
Changes by:     Andrew John Hughes <gnu_andrew> 06/06/11 21:57:15

Modified files:
        .              : ChangeLog NEWS 
        doc            : vmintegration.texinfo 
        java/lang/management: ManagementFactory.java RuntimeMXBean.java 
Added files:
        gnu/java/lang/management: RuntimeMXBeanImpl.java 
        vm/reference/gnu/java/lang/management: VMRuntimeMXBeanImpl.java 

Log message:
        2006-06-11  Andrew John Hughes  <address@hidden>
        
                * NEWS:
                Mention new VM interface and use of properties.
                * doc/vmintegration.texinfo:
                Update with new gnu.java.lang.management section.
                * gnu/java/lang/management/RuntimeMXBeanImpl.java:
                New file.
                * java/lang/management/ManagementFactory.java:
                (getRuntimeMXBean()): Implemented.
                * vm/reference/gnu/java/lang/management/RuntimeMXBeanImpl.java:
                New VM interface file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7771&r2=1.7772
http://cvs.savannah.gnu.org/viewcvs/classpath/NEWS?cvsroot=classpath&r1=1.148&r2=1.149
http://cvs.savannah.gnu.org/viewcvs/classpath/doc/vmintegration.texinfo?cvsroot=classpath&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/lang/management/RuntimeMXBeanImpl.java?cvsroot=classpath&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/java/lang/management/ManagementFactory.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/java/lang/management/RuntimeMXBean.java?cvsroot=classpath&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java?cvsroot=classpath&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7771
retrieving revision 1.7772
diff -u -b -r1.7771 -r1.7772
--- ChangeLog   11 Jun 2006 12:14:45 -0000      1.7771
+++ ChangeLog   11 Jun 2006 21:57:14 -0000      1.7772
@@ -1,3 +1,16 @@
+2006-06-11  Andrew John Hughes  <address@hidden>
+
+       * NEWS:
+       Mention new VM interface and use of properties.
+       * doc/vmintegration.texinfo:
+       Update with new gnu.java.lang.management section.
+       * gnu/java/lang/management/RuntimeMXBeanImpl.java:
+       New file.
+       * java/lang/management/ManagementFactory.java:
+       (getRuntimeMXBean()): Implemented.
+       * vm/reference/gnu/java/lang/management/RuntimeMXBeanImpl.java:
+       New VM interface file.
+       
 2006-06-11  Raif S. Naffah  <address@hidden>
 
        PR Classpath/26065

Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -b -r1.148 -r1.149
--- NEWS        7 Jun 2006 15:09:40 -0000       1.148
+++ NEWS        11 Jun 2006 21:57:14 -0000      1.149
@@ -30,6 +30,12 @@
 * 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
+  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
+  or java.boot.class.path should be defined by the VM to
+  support the optional boot class path access functionality.
 
 New in release 0.91 (May 15, 2006)
 

Index: doc/vmintegration.texinfo
===================================================================
RCS file: /cvsroot/classpath/classpath/doc/vmintegration.texinfo,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- doc/vmintegration.texinfo   22 Apr 2006 21:52:18 -0000      1.28
+++ doc/vmintegration.texinfo   11 Jun 2006 21:57:15 -0000      1.29
@@ -202,6 +202,7 @@
 * gnu.java.nio::
 * java.lang.reflect::
 * gnu.java.lang::
+* gnu.java.lang.management::
 * Classpath Callbacks::
 @end menu
 
@@ -1206,7 +1207,7 @@
 particular class and size.  The default implementation simply passes
 the job down to the standard JNI function, @code{NewObjectArray}.
 
address@hidden gnu.java.lang, Classpath Callbacks, java.lang.reflect, Classpath 
Hooks
address@hidden gnu.java.lang, gnu.java.lang.management, java.lang.reflect, 
Classpath Hooks
 @section @code{gnu.java.lang}
 
 @code{gnu.java.lang} provides VM interfaces for the GNU
@@ -1258,7 +1259,59 @@
 which must be implemented by the VM. The implementation should call the
 @code{InstrumentationImpl.callTransformers} method.
 
address@hidden Classpath Callbacks, , gnu.java.lang, Classpath Hooks
address@hidden gnu.java.lang.management, Classpath Callbacks, gnu.java.lang, 
Classpath Hooks
address@hidden @code{gnu.java.lang.management}
+
address@hidden provides the VM interfaces for the GNU
+implementations of the management beans.  
+
address@hidden
+* gnu.java.lang.management.VMRuntimeMXBeanImpl::
address@hidden menu
+
address@hidden 
gnu.java.lang.management.VMRuntimeMXBeanImpl,,,gnu.java.lang.management
address@hidden @code{gnu.java.lang.management.VMRuntimeMXBeanImpl}
+
+The @code{gnu.java.lang.management.RuntimeMXBeanImpl} provides an
+implementation of the @code{java.lang.management.RuntimeMXBean} interface,
+and is supported by VM functionality in the form of
address@hidden  This provides a
+series of methods, which should be implemented by the virtual machine
+in order to provide the required information for the bean.  The VM
+methods are generally representative of information that is only
+available from the virtual machine, such as the command-line arguments
+it was given at startup.
+
+The methods are as follows:
+
address@hidden @bullet
address@hidden @code{(getInputArguments())} -- The VM should supply
+a @code{String} array containing each of the command-line
+arguments, excluding those that are directed at the
address@hidden()} method.  The reference implementation expects
+this to be a native method.
address@hidden @code{(getName())} -- The VM developer should choose
+an appropriate name for the virtual machine.  This name can
+be instance-specific e.g. it can include things like the
+process identifier or host name of the machine, which only
+apply to the current running instance.  Thus, the intention is
+that this name refers to the entity that the other information
+refers to, rather than the VM in general.  The reference
+implementation supplies a default concatenation of the VM
+name and version.
address@hidden @code{(getStartTime())} -- This should return the number
+of milliseconds at which the virtual machine was started.
+The uptime property of the bean is provided relative to this
+value.  Again, the reference implementation also expects
+this method to be native.
address@hidden itemize
+
+The virtual machine also needs to provide either the
address@hidden or @code{java.boot.class.path}
+property in order to support the optional boot class path
+retrieval functionality.
+
address@hidden 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:
 

Index: java/lang/management/ManagementFactory.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/lang/management/ManagementFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- java/lang/management/ManagementFactory.java 28 May 2006 15:04:15 -0000      
1.1
+++ java/lang/management/ManagementFactory.java 11 Jun 2006 21:57:15 -0000      
1.2
@@ -38,6 +38,7 @@
 package java.lang.management;
 
 import gnu.java.lang.management.OperatingSystemMXBeanImpl;
+import gnu.java.lang.management.RuntimeMXBeanImpl;
 
 /**
  * <p>
@@ -65,6 +66,11 @@
   private static OperatingSystemMXBean osBean;
 
   /**
+   * The runtime management bean.
+   */
+  private static RuntimeMXBean runtimeBean;
+
+  /**
    * Returns the operating system management bean for the
    * operating system on which the virtual machine is running.
    *
@@ -78,4 +84,18 @@
     return osBean;
   }
 
+  /**
+   * Returns the runtime management bean for the
+   * running virtual machine.
+   *
+   * @return an instance of address@hidden RuntimeMXBean} for
+   *         this virtual machine.
+   */
+  public static RuntimeMXBean getRuntimeMXBean()
+  {
+    if (runtimeBean == null)
+      runtimeBean = new RuntimeMXBeanImpl();
+    return runtimeBean;
+  }
+
 }

Index: java/lang/management/RuntimeMXBean.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/management/RuntimeMXBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- java/lang/management/RuntimeMXBean.java     8 Jun 2006 23:11:58 -0000       
1.1
+++ java/lang/management/RuntimeMXBean.java     11 Jun 2006 21:57:15 -0000      
1.2
@@ -140,7 +140,11 @@
    * virtual machine.  It may include a number of system
    * attributes and may differ between instances of the
    * same virtual machine (for example, it might include
-   * the process identifier).
+   * the process identifier or the host name of the machine
+   * on which it is running).  The intention is that this
+   * name refers to the precise entity that the other data 
+   * supplied by this bean refers to, rather than the VM
+   * in general.
    *
    * @return the name of this virtual machine.
    */

Index: gnu/java/lang/management/RuntimeMXBeanImpl.java
===================================================================
RCS file: gnu/java/lang/management/RuntimeMXBeanImpl.java
diff -N gnu/java/lang/management/RuntimeMXBeanImpl.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/java/lang/management/RuntimeMXBeanImpl.java     11 Jun 2006 21:57:15 
-0000      1.1
@@ -0,0 +1,188 @@
+/* RuntimeMXBeanImpl.java - Implementation of an runtime 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.ManagementPermission;
+import java.lang.management.RuntimeMXBean;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (address@hidden)
+ * @since 1.5
+ */
+public final class RuntimeMXBeanImpl
+  implements RuntimeMXBean
+{
+
+  private static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";
+  private static final String JAVA_BOOT_CLASS_PATH = "java.boot.class.path";
+
+  private long startTime = -1;
+
+  private String bootClassPath = null;
+
+  private boolean bootClassPathSupported = true;
+
+  void checkMonitorPermissions()
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new ManagementPermission("monitor"));
+  }
+
+  public String getBootClassPath()
+  {
+    checkMonitorPermissions();
+    if (isBootClassPathSupported())
+      return bootClassPath;
+    else
+      throw
+       new UnsupportedOperationException("Retrieving the boot " +
+                                         "classpath is not supported.");
+  }
+
+  public String getClassPath()
+  {
+    return System.getProperty("java.class.path");
+  }
+
+  public List getInputArguments()
+  {
+    checkMonitorPermissions();
+    return Arrays.asList(VMRuntimeMXBeanImpl.getInputArguments());
+  }
+
+  public String getLibraryPath()
+  {
+    return System.getProperty("java.library.path");
+  }
+
+  public String getManagementSpecVersion()
+  {
+    return "1.0";
+  }
+
+  public String getName()
+  {
+    return VMRuntimeMXBeanImpl.getName();
+  }
+
+  public String getSpecName()
+  {
+    return System.getProperty("java.vm.specification.name");
+  }
+
+  public String getSpecVendor()
+  {
+    return System.getProperty("java.vm.specification.vendor");
+  }
+
+  public String getSpecVersion()
+  {
+    return System.getProperty("java.vm.specification.version");
+  }
+
+  public long getStartTime()
+  {
+    if (startTime == -1)
+      startTime = VMRuntimeMXBeanImpl.getStartTime();
+    return startTime;
+  }
+
+  public Map getSystemProperties()
+  {
+    Map map = new HashMap();
+    Properties props = System.getProperties();
+    Iterator entries = props.entrySet().iterator();
+    while (entries.hasNext())
+      {
+       Map.Entry next = (Map.Entry) entries.next();
+       Object key = next.getKey();
+       Object value = next.getValue();
+       if (key instanceof String &&
+           value instanceof String)
+         map.put(key, value);
+      }
+    return map;
+  }
+  
+  public long getUptime()
+  {
+    return new Date().getTime() - getStartTime();
+  }
+
+  public String getVmName()
+  {
+    return System.getProperty("java.vm.name");
+  }
+
+  public String getVmVendor()
+  {
+    return System.getProperty("java.vm.vendor");
+  }
+
+  public String getVmVersion()
+  {
+    return System.getProperty("java.vm.version");
+  }
+
+  public boolean isBootClassPathSupported()
+  {
+    if (bootClassPath == null)
+      {
+       bootClassPath = System.getProperty(JAVA_BOOT_CLASS_PATH);
+       if (bootClassPath == null)
+         bootClassPath = System.getProperty(SUN_BOOT_CLASS_PATH);
+       if (bootClassPath == null)
+         bootClassPathSupported = false;
+      }
+    return bootClassPathSupported;
+  }
+
+}

Index: vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
===================================================================
RCS file: vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
diff -N vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java      11 Jun 
2006 21:57:15 -0000      1.1
@@ -0,0 +1,89 @@
+/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime 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;
+
+/**
+ * Provides access to information about the virtual machine.
+ *
+ * @author Andrew John Hughes (address@hidden)
+ * @since 1.5
+ */
+final class VMRuntimeMXBeanImpl
+{
+
+  /**
+   * Returns the command-line arguments supplied
+   * to the virtual machine, excluding those supplied
+   * to <code>main()</code>.
+   *
+   * @return the command-line arguments.
+   */
+  static native String[] getInputArguments();
+
+  /**
+   * Returns a developer-chosen name for the virtual
+   * machine, which may differ over different running
+   * instances of the same virtual machine binary.
+   * For example, this may include the particular
+   * process identifier used by this instance or
+   * the host name of the machine on which it is
+   * running.  The intention is that this name refers
+   * to the precise entity that the other data supplied
+   * by the bean refers to, rather than the VM in general.
+   *
+   * @return the custom name of the VM.
+   */
+  static String getName()
+  {
+    return SystemProperties.getProperty("java.vm.name") + " " +
+      SystemProperties.getProperty("java.vm.version");
+  }
+
+  /**
+   * The time in milliseconds at which the virtual
+   * machine was started.  This method is only executed
+   * once (for efficency), as the value is not expected
+   * to change.
+   *
+   * @return the VM start time.
+   */
+  static native long getStartTime();
+
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]