Path: blob/master/src/java.management/share/classes/sun/management/RuntimeImpl.java
41152 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() {98throw new UnsupportedOperationException(99"Boot class path mechanism is not supported");100}101102public List<String> getInputArguments() {103Util.checkMonitorAccess();104return jvm.getVmArguments();105}106107public long getUptime() {108return jvm.getUptime();109}110111public long getStartTime() {112return vmStartupTime;113}114115public boolean isBootClassPathSupported() {116return false;117}118119public Map<String,String> getSystemProperties() {120Properties sysProps = System.getProperties();121Map<String,String> map = new HashMap<>();122123// Properties.entrySet() does not include the entries in124// the default properties. So use Properties.stringPropertyNames()125// to get the list of property keys including the default ones.126Set<String> keys = sysProps.stringPropertyNames();127for (String k : keys) {128String value = sysProps.getProperty(k);129map.put(k, value);130}131132return map;133}134135public ObjectName getObjectName() {136return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);137}138139}140141142