1 /*
   2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.lang.management;
  27 
  28 /**
  29  * The management interface for the runtime system of
  30  * the Java virtual machine.
  31  *
  32  * <p> A Java virtual machine has a single instance of the implementation
  33  * class of this interface.  This instance implementing this interface is
  34  * an <a href="ManagementFactory.html#MXBean">MXBean</a>
  35  * that can be obtained by calling
  36  * the {@link ManagementFactory#getRuntimeMXBean} method or
  37  * from the {@link ManagementFactory#getPlatformMBeanServer
  38  * platform <tt>MBeanServer</tt>} method.
  39  *
  40  * <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for
  41  * the runtime system within an MBeanServer is:
  42  * <blockquote>
  43  *    {@link ManagementFactory#RUNTIME_MXBEAN_NAME
  44  *           <tt>java.lang:type=Runtime</tt>}
  45  * </blockquote>
  46  *
  47  * It can be obtained by calling the
  48  * {@link PlatformManagedObject#getObjectName} method.
  49  *
  50  * <p> This interface defines several convenient methods for accessing
  51  * system properties about the Java virtual machine.
  52  *
  53  * @see ManagementFactory#getPlatformMXBeans(Class)
  54  * @see <a href="../../../javax/management/package-summary.html">
  55  *      JMX Specification.</a>
  56  * @see <a href="package-summary.html#examples">
  57  *      Ways to Access MXBeans</a>
  58  *
  59  * @author  Mandy Chung
  60  * @since   1.5
  61  */
  62 public interface RuntimeMXBean extends PlatformManagedObject {
  63     /**
  64      * Returns the name representing the running Java virtual machine.
  65      * The returned name string can be any arbitrary string and
  66      * a Java virtual machine implementation can choose
  67      * to embed platform-specific useful information in the
  68      * returned name string.  Each running virtual machine could have
  69      * a different name.
  70      *
  71      * @return the name representing the running Java virtual machine.
  72      */
  73     public String getName();
  74 
  75     /**
  76      * Returns the Java virtual machine implementation name.
  77      * This method is equivalent to {@link System#getProperty
  78      * System.getProperty("java.vm.name")}.
  79      *
  80      * @return the Java virtual machine implementation name.
  81      *
  82      * @throws  java.lang.SecurityException
  83      *     if a security manager exists and its
  84      *     <code>checkPropertiesAccess</code> method doesn't allow access
  85      *     to this system property.
  86      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
  87      * @see java.lang.System#getProperty
  88      */
  89     public String getVmName();
  90 
  91     /**
  92      * Returns the Java virtual machine implementation vendor.
  93      * This method is equivalent to {@link System#getProperty
  94      * System.getProperty("java.vm.vendor")}.
  95      *
  96      * @return the Java virtual machine implementation vendor.
  97      *
  98      * @throws  java.lang.SecurityException
  99      *     if a security manager exists and its
 100      *     <code>checkPropertiesAccess</code> method doesn't allow access
 101      *     to this system property.
 102      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 103      * @see java.lang.System#getProperty
 104      */
 105     public String getVmVendor();
 106 
 107     /**
 108      * Returns the Java virtual machine implementation version.
 109      * This method is equivalent to {@link System#getProperty
 110      * System.getProperty("java.vm.version")}.
 111      *
 112      * @return the Java virtual machine implementation version.
 113      *
 114      * @throws  java.lang.SecurityException
 115      *     if a security manager exists and its
 116      *     <code>checkPropertiesAccess</code> method doesn't allow access
 117      *     to this system property.
 118      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 119      * @see java.lang.System#getProperty
 120      */
 121     public String getVmVersion();
 122 
 123     /**
 124      * Returns the Java virtual machine specification name.
 125      * This method is equivalent to {@link System#getProperty
 126      * System.getProperty("java.vm.specification.name")}.
 127      *
 128      * @return the Java virtual machine specification name.
 129      *
 130      * @throws  java.lang.SecurityException
 131      *     if a security manager exists and its
 132      *     <code>checkPropertiesAccess</code> method doesn't allow access
 133      *     to this system property.
 134      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 135      * @see java.lang.System#getProperty
 136      */
 137     public String getSpecName();
 138 
 139     /**
 140      * Returns the Java virtual machine specification vendor.
 141      * This method is equivalent to {@link System#getProperty
 142      * System.getProperty("java.vm.specification.vendor")}.
 143      *
 144      * @return the Java virtual machine specification vendor.
 145      *
 146      * @throws  java.lang.SecurityException
 147      *     if a security manager exists and its
 148      *     <code>checkPropertiesAccess</code> method doesn't allow access
 149      *     to this system property.
 150      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 151      * @see java.lang.System#getProperty
 152      */
 153     public String getSpecVendor();
 154 
 155     /**
 156      * Returns the Java virtual machine specification version.
 157      * This method is equivalent to {@link System#getProperty
 158      * System.getProperty("java.vm.specification.version")}.
 159      *
 160      * @return the Java virtual machine specification version.
 161      *
 162      * @throws  java.lang.SecurityException
 163      *     if a security manager exists and its
 164      *     <code>checkPropertiesAccess</code> method doesn't allow access
 165      *     to this system property.
 166      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 167      * @see java.lang.System#getProperty
 168      */
 169     public String getSpecVersion();
 170 
 171 
 172     /**
 173      * Returns the version of the specification for the management interface
 174      * implemented by the running Java virtual machine.
 175      *
 176      * @return the version of the specification for the management interface
 177      * implemented by the running Java virtual machine.
 178      */
 179     public String getManagementSpecVersion();
 180 
 181     /**
 182      * Returns the Java class path that is used by the system class loader
 183      * to search for class files.
 184      * This method is equivalent to {@link System#getProperty
 185      * System.getProperty("java.class.path")}.
 186      *
 187      * <p> Multiple paths in the Java class path are separated by the
 188      * path separator character of the platform of the Java virtual machine
 189      * being monitored.
 190      *
 191      * @return the Java class path.
 192      *
 193      * @throws  java.lang.SecurityException
 194      *     if a security manager exists and its
 195      *     <code>checkPropertiesAccess</code> method doesn't allow access
 196      *     to this system property.
 197      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 198      * @see java.lang.System#getProperty
 199      */
 200     public String getClassPath();
 201 
 202     /**
 203      * Returns the Java library path.
 204      * This method is equivalent to {@link System#getProperty
 205      * System.getProperty("java.library.path")}.
 206      *
 207      * <p> Multiple paths in the Java library path are separated by the
 208      * path separator character of the platform of the Java virtual machine
 209      * being monitored.
 210      *
 211      * @return the Java library path.
 212      *
 213      * @throws  java.lang.SecurityException
 214      *     if a security manager exists and its
 215      *     <code>checkPropertiesAccess</code> method doesn't allow access
 216      *     to this system property.
 217      * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
 218      * @see java.lang.System#getProperty
 219      */
 220     public String getLibraryPath();
 221 
 222     /**
 223      * Tests if the Java virtual machine supports the boot class path
 224      * mechanism used by the bootstrap class loader to search for class
 225      * files.
 226      *
 227      * @return <tt>true</tt> if the Java virtual machine supports the
 228      * class path mechanism; <tt>false</tt> otherwise.
 229      */
 230     public boolean isBootClassPathSupported();
 231 
 232     /**
 233      * Returns the boot class path that is used by the bootstrap class loader
 234      * to search for class files.
 235      *
 236      * <p> Multiple paths in the boot class path are separated by the
 237      * path separator character of the platform on which the Java
 238      * virtual machine is running.
 239      *
 240      * <p>A Java virtual machine implementation may not support
 241      * the boot class path mechanism for the bootstrap class loader
 242      * to search for class files.
 243      * The {@link #isBootClassPathSupported} method can be used
 244      * to determine if the Java virtual machine supports this method.
 245      *
 246      * @return the boot class path.
 247      *
 248      * @throws java.lang.UnsupportedOperationException
 249      *     if the Java virtual machine does not support this operation.
 250      *
 251      * @throws  java.lang.SecurityException
 252      *     if a security manager exists and the caller does not have
 253      *     ManagementPermission("monitor").
 254      */
 255     public String getBootClassPath();
 256 
 257     /**
 258      * Returns the input arguments passed to the Java virtual machine
 259      * which does not include the arguments to the <tt>main</tt> method.
 260      * This method returns an empty list if there is no input argument
 261      * to the Java virtual machine.
 262      * <p>
 263      * Some Java virtual machine implementations may take input arguments
 264      * from multiple different sources: for examples, arguments passed from
 265      * the application that launches the Java virtual machine such as
 266      * the 'java' command, environment variables, configuration files, etc.
 267      * <p>
 268      * Typically, not all command-line options to the 'java' command
 269      * are passed to the Java virtual machine.
 270      * Thus, the returned input arguments may not
 271      * include all command-line options.
 272      *
 273      * <p>
 274      * <b>MBeanServer access</b>:<br>
 275      * The mapped type of <tt>List<String></tt> is <tt>String[]</tt>.
 276      *
 277      * @return a list of <tt>String</tt> objects; each element
 278      * is an argument passed to the Java virtual machine.
 279      *
 280      * @throws  java.lang.SecurityException
 281      *     if a security manager exists and the caller does not have
 282      *     ManagementPermission("monitor").
 283      */
 284     public java.util.List<String> getInputArguments();
 285 
 286     /**
 287      * Returns the uptime of the Java virtual machine in milliseconds.
 288      *
 289      * @return uptime of the Java virtual machine in milliseconds.
 290      */
 291     public long getUptime();
 292 
 293     /**
 294      * Returns the start time of the Java virtual machine in milliseconds.
 295      * This method returns the approximate time when the Java virtual
 296      * machine started.
 297      *
 298      * @return start time of the Java virtual machine in milliseconds.
 299      *
 300      */
 301     public long getStartTime();
 302 
 303     /**
 304      * Returns a map of names and values of all system properties.
 305      * This method calls {@link System#getProperties} to get all
 306      * system properties.  Properties whose name or value is not
 307      * a <tt>String</tt> are omitted.
 308      *
 309      * <p>
 310      * <b>MBeanServer access</b>:<br>
 311      * The mapped type of {@code Map<String,String>} is
 312      * {@link javax.management.openmbean.TabularData TabularData}
 313      * with two items in each row as follows:
 314      * <blockquote>
 315      * <table border>
 316      * <tr>
 317      *   <th>Item Name</th>
 318      *   <th>Item Type</th>
 319      *   </tr>
 320      * <tr>
 321      *   <td><tt>key</tt></td>
 322      *   <td><tt>String</tt></td>
 323      *   </tr>
 324      * <tr>
 325      *   <td><tt>value</tt></td>
 326      *   <td><tt>String</tt></td>
 327      *   </tr>
 328      * </table>
 329      * </blockquote>
 330      *
 331      * @return a map of names and values of all system properties.
 332      *
 333      * @throws  java.lang.SecurityException
 334      *     if a security manager exists and its
 335      *     <code>checkPropertiesAccess</code> method doesn't allow access
 336      *     to the system properties.
 337      */
 338     public java.util.Map<String, String> getSystemProperties();
 339 }