Path: blob/master/jcl/src/java.management/share/classes/java/lang/management/RuntimeMXBean.java
12511 views
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/1/*2*******************************************************************************3* Copyright (c) 2005, 2022 IBM Corp. and others4*5* This program and the accompanying materials are made available under6* the terms of the Eclipse Public License 2.0 which accompanies this7* distribution and is available at https://www.eclipse.org/legal/epl-2.0/8* or the Apache License, Version 2.0 which accompanies this distribution and9* is available at https://www.apache.org/licenses/LICENSE-2.0.10*11* This Source Code may also be made available under the following12* Secondary Licenses when the conditions for such availability set13* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU14* General Public License, version 2 with the GNU Classpath15* Exception [1] and GNU General Public License, version 2 with the16* OpenJDK Assembly Exception [2].17*18* [1] https://www.gnu.org/software/classpath/license.html19* [2] http://openjdk.java.net/legal/assembly-exception.html20*21* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception22*******************************************************************************/23package java.lang.management;2425import java.security.AccessController;26import java.security.PrivilegedAction;27import java.util.List;28import java.util.Map;2930/**31* The management and monitoring interface for the runtime system of the virtual32* machine.33* <p>34* Precisely one instance of this interface will be made available to management35* clients.36* </p>37* <p>38* Accessing this <code>MXBean</code> can be done in one of three ways.39* <ol>40* <li>Invoking the static ManagementFactory.getRuntimeMXBean() method.</li>41* <li>Using a javax.management.MBeanServerConnection.</li>42* <li>Obtaining a proxy MXBean from the static43* {@link ManagementFactory#newPlatformMXBeanProxy} method, passing in44* "java.lang:type=Runtime" for the value of the second parameter.45* </li>46* </ol>47*48* @since 1.549*/50/*[IF JAVA_SPEC_VERSION >= 17]*/51@SuppressWarnings("removal")52/*[ENDIF] JAVA_SPEC_VERSION >= 17 */53public interface RuntimeMXBean extends PlatformManagedObject {5455/**56* If bootstrap class loading is supported by the virtual machine, returns a57* string containing the full bootstrap class path used by the boot class58* loader to locate and load class files.59* <p>60* An indication of whether or not the virtual machine supports a boot class61* loader mechanism can be found from invoking the62* {@link #isBootClassPathSupported()} method.63* </p>64*65* @return the bootstrap classpath with each entry separated by the path66* separator character corresponding to the underlying operating67* system.68* @throws UnsupportedOperationException69* if the virtual machine does not support boot class loading.70* @throws SecurityException71* if there is a security manager in effect and the caller does72* not have {@link ManagementPermission} of "monitor".73*/74public String getBootClassPath();7576/**77* Returns the class path string used by the system class loader to locate78* and load class files. The value is identical to that which would be79* obtained from a call to {@link System#getProperty(java.lang.String)}80* supplying the value "java.class.path" for the key.81*82* @return the system classpath with each entry separated by the path83* separator character corresponding to the underlying operating84* system.85* @throws SecurityException86* if there is a security manager in operation and the caller87* does not have permission to check system properties.88* @see System#getProperty(java.lang.String)89*/90public String getClassPath();9192/**93* Returns a list of all of the input arguments passed to the virtual94* machine on start-up. This will <i>not </i> include any input arguments95* that are passed into the application's <code>main(String[] args)</code>96* method.97*98* @return a list of strings, each one containing an argument to the virtual99* machine. If no virtual machine arguments were passed in at100* start-up time then this will be an empty list.101*/102public List<String> getInputArguments();103104/**105* Returns the Java library path that will be used by the virtual machine to106* locate and load libraries. The value is identical to that which would be107* obtained from a call to {@link System#getProperty(java.lang.String)}108* supplying the value "java.library.path" for the key.109*110* @return the Java library path with each entry separated by the path111* separator character corresponding to the underlying operating112* system.113* @throws SecurityException114* if there is a security manager in operation and the caller115* does not have permission to check system properties.116* @see System#getProperty(java.lang.String)117*/118public String getLibraryPath();119120/**121* Returns a string containing the management interface specification122* version that the virtual machine meets.123*124* @return the version of the management interface specification adhered to125* by the virtual machine.126*/127public String getManagementSpecVersion();128129/**130* Returns the string name of this virtual machine. This value may be131* different for each particular running virtual machine.132*133* @return the name of this running virtual machine.134*/135public String getName();136137/*[IF JAVA_SPEC_VERSION >= 10]*/138/**139* Returns the process ID (PID) of the current running Java virtual machine.140*141* @return the process ID of the current running JVM142*143* @since 10144*/145@SuppressWarnings("boxing")146default long getPid() {147return AccessController.doPrivileged(new PrivilegedAction<Long>() {148public Long run() {149return ProcessHandle.current().pid();150}151});152}153/*[ENDIF] JAVA_SPEC_VERSION >= 10 */154155/**156* Returns the name of the Java virtual machine specification followed by157* this virtual machine. The value is identical to that which would be158* obtained from a call to {@link System#getProperty(java.lang.String)}159* supplying the value "java.vm.specification.name" for the key.160*161* @return the name of the Java virtual machine specification.162* @throws SecurityException163* if there is a security manager in operation and the caller164* does not have permission to check system properties.165* @see System#getProperty(java.lang.String)166*/167public String getSpecName();168169/**170* Returns the name of the Java virtual machine specification vendor. The171* value is identical to that which would be obtained from a call to172* {@link System#getProperty(java.lang.String)} supplying the value173* "java.vm.specification.vendor" for the key.174*175* @return the name of the Java virtual machine specification vendor.176* @throws SecurityException177* if there is a security manager in operation and the caller178* does not have permission to check system properties.179* @see System#getProperty(java.lang.String)180*/181public String getSpecVendor();182183/**184* Returns the name of the Java virtual machine specification version. The185* value is identical to that which would be obtained from a call to186* {@link System#getProperty(java.lang.String)} supplying the value187* "java.vm.specification.version" for the key.188*189* @return the Java virtual machine specification version.190* @throws SecurityException191* if there is a security manager in operation and the caller192* does not have permission to check system properties.193* @see System#getProperty(java.lang.String)194*/195public String getSpecVersion();196197/**198* Returns the time, in milliseconds, when the virtual machine was started.199*200* @return the virtual machine start time in milliseconds.201*/202public long getStartTime();203204/**205* Returns a map of the names and values of every system property known to206* the virtual machine.207*208* @return a map containing the names and values of every system property.209* @throws SecurityException210* if there is a security manager in operation and the caller211* does not have permission to check system properties.212*/213public Map<String, String> getSystemProperties();214215/**216* Returns the lifetime of the virtual machine in milliseconds.217*218* @return the number of milliseconds the virtual machine has been running.219*/220public long getUptime();221222/**223* Returns the name of the Java virtual machine implementation. The value is224* identical to that which would be obtained from a call to225* {@link System#getProperty(java.lang.String)} supplying the value226* "java.vm.name" for the key.227*228* @return the name of the Java virtual machine implementation.229* @throws SecurityException230* if there is a security manager in operation and the caller231* does not have permission to check system properties.232* @see System#getProperty(java.lang.String)233*/234public String getVmName();235236/**237* Returns the name of the Java virtual machine implementation vendor. The238* value is identical to that which would be obtained from a call to239* {@link System#getProperty(java.lang.String)} supplying the value240* "java.vm.vendor" for the key.241*242* @return the name of the Java virtual machine implementation vendor.243* @throws SecurityException244* if there is a security manager in operation and the caller245* does not have permission to check system properties.246* @see System#getProperty(java.lang.String)247*/248public String getVmVendor();249250/**251* Returns the version of the Java virtual machine implementation. The value252* is identical to that which would be obtained from a call to253* {@link System#getProperty(java.lang.String)} supplying the value254* "java.vm.version" for the key.255*256* @return the version of the Java virtual machine implementation.257* @throws SecurityException258* if there is a security manager in operation and the caller259* does not have permission to check system properties.260* @see System#getProperty(java.lang.String)261*/262public String getVmVersion();263264/**265* Returns a boolean indication of whether or not the virtual machine266* supports a bootstrap class loading mechanism.267*268* @return <code>true</code> if supported, <code>false</code> otherwise.269*/270public boolean isBootClassPathSupported();271272}273274275