Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/management/RuntimeImpl.java
38827 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.management;2627import java.lang.management.RuntimeMXBean;28import java.lang.management.ManagementFactory;2930import java.util.List;31import java.util.HashMap;32import java.util.Map;33import java.util.Set;34import java.util.Properties;35import javax.management.ObjectName;3637/**38* Implementation class for the runtime subsystem.39* Standard and committed hotspot-specific metrics if any.40*41* ManagementFactory.getRuntimeMXBean() returns an instance42* of this class.43*/44class RuntimeImpl implements RuntimeMXBean {4546private final VMManagement jvm;47private final long vmStartupTime;4849/**50* Constructor of RuntimeImpl class.51*/52RuntimeImpl(VMManagement vm) {53this.jvm = vm;54this.vmStartupTime = jvm.getStartupTime();55}5657public String getName() {58return jvm.getVmId();59}6061public String getManagementSpecVersion() {62return jvm.getManagementVersion();63}6465public String getVmName() {66return jvm.getVmName();67}6869public String getVmVendor() {70return jvm.getVmVendor();71}7273public String getVmVersion() {74return jvm.getVmVersion();75}7677public String getSpecName() {78return jvm.getVmSpecName();79}8081public String getSpecVendor() {82return jvm.getVmSpecVendor();83}8485public String getSpecVersion() {86return jvm.getVmSpecVersion();87}8889public String getClassPath() {90return jvm.getClassPath();91}9293public String getLibraryPath() {94return jvm.getLibraryPath();95}9697public String getBootClassPath() {98if (!isBootClassPathSupported()) {99throw new UnsupportedOperationException(100"Boot class path mechanism is not supported");101}102Util.checkMonitorAccess();103return jvm.getBootClassPath();104}105106public List<String> getInputArguments() {107Util.checkMonitorAccess();108return jvm.getVmArguments();109}110111public long getUptime() {112return jvm.getUptime();113}114115public long getStartTime() {116return vmStartupTime;117}118119public boolean isBootClassPathSupported() {120return jvm.isBootClassPathSupported();121}122123public Map<String,String> getSystemProperties() {124Properties sysProps = System.getProperties();125Map<String,String> map = new HashMap<>();126127// Properties.entrySet() does not include the entries in128// the default properties. So use Properties.stringPropertyNames()129// to get the list of property keys including the default ones.130Set<String> keys = sysProps.stringPropertyNames();131for (String k : keys) {132String value = sysProps.getProperty(k);133map.put(k, value);134}135136return map;137}138139public ObjectName getObjectName() {140return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);141}142143}144145146