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 sun.management;
27
28 import sun.misc.Perf;
29 import sun.management.counter.*;
30 import sun.management.counter.perf.*;
31 import java.nio.ByteBuffer;
32 import java.io.IOException;
33 import java.net.InetAddress;
34 import java.net.UnknownHostException;
35 import java.util.List;
36 import java.util.Arrays;
37 import java.util.Collections;
38 import java.security.AccessController;
39 import java.security.PrivilegedAction;
40 import sun.security.action.GetPropertyAction;
41
42 /**
43 * Implementation of VMManagement interface that accesses the management
44 * attributes and operations locally within the same Java virtual
45 * machine.
46 */
47 class VMManagementImpl implements VMManagement {
48
49 private static String version;
50
51 private static boolean compTimeMonitoringSupport;
52 private static boolean threadContentionMonitoringSupport;
53 private static boolean currentThreadCpuTimeSupport;
54 private static boolean otherThreadCpuTimeSupport;
55 private static boolean bootClassPathSupport;
56 private static boolean objectMonitorUsageSupport;
57 private static boolean synchronizerUsageSupport;
58 private static boolean threadAllocatedMemorySupport;
59 private static boolean gcNotificationSupport;
60 private static boolean remoteDiagnosticCommandsSupport;
156 public String getVmVersion() {
157 return System.getProperty("java.vm.version");
158 }
159 public String getVmSpecName() {
160 return System.getProperty("java.vm.specification.name");
161 }
162 public String getVmSpecVendor() {
163 return System.getProperty("java.vm.specification.vendor");
164 }
165 public String getVmSpecVersion() {
166 return System.getProperty("java.vm.specification.version");
167 }
168 public String getClassPath() {
169 return System.getProperty("java.class.path");
170 }
171 public String getLibraryPath() {
172 return System.getProperty("java.library.path");
173 }
174
175 public String getBootClassPath( ) {
176 PrivilegedAction<String> pa
177 = new GetPropertyAction("sun.boot.class.path");
178 String result = AccessController.doPrivileged(pa);
179 return result;
180 }
181
182 public long getUptime() {
183 return getUptime0();
184 }
185
186 private List<String> vmArgs = null;
187 public synchronized List<String> getVmArguments() {
188 if (vmArgs == null) {
189 String[] args = getVmArguments0();
190 List<String> l = ((args != null && args.length != 0) ? Arrays.asList(args) :
191 Collections.<String>emptyList());
192 vmArgs = Collections.unmodifiableList(l);
193 }
194 return vmArgs;
195 }
196 public native String[] getVmArguments0();
197
198 public native long getStartupTime();
199 private native long getUptime0();
|
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 sun.management;
27
28 import sun.misc.Perf;
29 import sun.management.counter.*;
30 import sun.management.counter.perf.*;
31 import java.nio.ByteBuffer;
32 import java.io.IOException;
33 import java.net.InetAddress;
34 import java.net.UnknownHostException;
35 import java.util.List;
36 import java.util.Arrays;
37 import java.util.Collections;
38 import java.security.AccessController;
39 import java.security.PrivilegedAction;
40
41 /**
42 * Implementation of VMManagement interface that accesses the management
43 * attributes and operations locally within the same Java virtual
44 * machine.
45 */
46 class VMManagementImpl implements VMManagement {
47
48 private static String version;
49
50 private static boolean compTimeMonitoringSupport;
51 private static boolean threadContentionMonitoringSupport;
52 private static boolean currentThreadCpuTimeSupport;
53 private static boolean otherThreadCpuTimeSupport;
54 private static boolean bootClassPathSupport;
55 private static boolean objectMonitorUsageSupport;
56 private static boolean synchronizerUsageSupport;
57 private static boolean threadAllocatedMemorySupport;
58 private static boolean gcNotificationSupport;
59 private static boolean remoteDiagnosticCommandsSupport;
155 public String getVmVersion() {
156 return System.getProperty("java.vm.version");
157 }
158 public String getVmSpecName() {
159 return System.getProperty("java.vm.specification.name");
160 }
161 public String getVmSpecVendor() {
162 return System.getProperty("java.vm.specification.vendor");
163 }
164 public String getVmSpecVersion() {
165 return System.getProperty("java.vm.specification.version");
166 }
167 public String getClassPath() {
168 return System.getProperty("java.class.path");
169 }
170 public String getLibraryPath() {
171 return System.getProperty("java.library.path");
172 }
173
174 public String getBootClassPath( ) {
175 return AccessController.doPrivileged(
176 (PrivilegedAction<String>) () -> System.getProperty("sun.boot.class.path"));
177 }
178
179 public long getUptime() {
180 return getUptime0();
181 }
182
183 private List<String> vmArgs = null;
184 public synchronized List<String> getVmArguments() {
185 if (vmArgs == null) {
186 String[] args = getVmArguments0();
187 List<String> l = ((args != null && args.length != 0) ? Arrays.asList(args) :
188 Collections.<String>emptyList());
189 vmArgs = Collections.unmodifiableList(l);
190 }
191 return vmArgs;
192 }
193 public native String[] getVmArguments0();
194
195 public native long getStartupTime();
196 private native long getUptime0();
|