2
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
package sun.management;
29
import sun.management.counter.*;
30
import java.nio.ByteBuffer;
31
import java.io.IOException;
32
import java.net.InetAddress;
33
import java.net.UnknownHostException;
34
import java.util.List;
35
import java.util.Arrays;
36
import java.util.Collections;
37
import java.security.AccessController;
38
import java.security.PrivilegedAction;
39
import sun.security.action.GetPropertyAction;
42
* Implementation of VMManagement interface that accesses the management
43
* attributes and operations locally within the same Java virtual
46
class VMManagementImpl implements VMManagement {
48
private static String version = "1.2";
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;
61
public boolean isCompilationTimeMonitoringSupported() {
62
return compTimeMonitoringSupport;
65
public boolean isThreadContentionMonitoringSupported() {
66
return threadContentionMonitoringSupport;
69
public boolean isCurrentThreadCpuTimeSupported() {
70
return currentThreadCpuTimeSupport;
73
public boolean isOtherThreadCpuTimeSupported() {
74
return otherThreadCpuTimeSupport;
77
public boolean isBootClassPathSupported() {
78
return bootClassPathSupport;
81
public boolean isObjectMonitorUsageSupported() {
82
return objectMonitorUsageSupport;
85
public boolean isSynchronizerUsageSupported() {
86
return synchronizerUsageSupport;
89
public boolean isThreadAllocatedMemorySupported() {
90
return threadAllocatedMemorySupport;
93
public boolean isGcNotificationSupported() {
94
return gcNotificationSupport;
97
public boolean isThreadContentionMonitoringEnabled() {
101
public boolean isThreadCpuTimeEnabled() {
105
public boolean isThreadAllocatedMemoryEnabled() {
109
// Class Loading Subsystem
110
public int getLoadedClassCount() {
111
long count = getTotalClassCount() - getUnloadedClassCount();
114
public long getTotalClassCount() {
115
throw new Error("Not implemented");
117
public long getUnloadedClassCount() {
118
throw new Error("Not implemented");
121
public boolean getVerboseClass() {
126
public boolean getVerboseGC() {
131
public String getManagementVersion() {
135
public String getVmId() {
136
int pid = getProcessId();
137
String hostname = "localhost";
139
hostname = InetAddress.getLocalHost().getHostName();
140
} catch (UnknownHostException e) {
144
return pid + "@" + hostname;
146
private int getProcessId() {
147
return cli.System.Diagnostics.Process.GetCurrentProcess().get_Id();
150
public String getVmName() {
151
return System.getProperty("java.vm.name");
154
public String getVmVendor() {
155
return System.getProperty("java.vm.vendor");
157
public String getVmVersion() {
158
return System.getProperty("java.vm.version");
160
public String getVmSpecName() {
161
return System.getProperty("java.vm.specification.name");
163
public String getVmSpecVendor() {
164
return System.getProperty("java.vm.specification.vendor");
166
public String getVmSpecVersion() {
167
return System.getProperty("java.vm.specification.version");
169
public String getClassPath() {
170
return System.getProperty("java.class.path");
172
public String getLibraryPath() {
173
return System.getProperty("java.library.path");
176
public String getBootClassPath( ) {
177
PrivilegedAction<String> pa
178
= new GetPropertyAction("sun.boot.class.path");
179
String result = AccessController.doPrivileged(pa);
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);
193
public String[] getVmArguments0() {
194
return new String[0];
197
public long getStartupTime() {
198
return (long)(cli.System.Diagnostics.Process.GetCurrentProcess().get_StartTime().ToUniversalTime().Subtract(new cli.System.DateTime(1970, 1, 1))).get_TotalMilliseconds();
200
public int getAvailableProcessors() {
201
return cli.System.Environment.get_ProcessorCount();
204
// Compilation Subsystem
205
public String getCompilerName() {
206
String name = AccessController.doPrivileged(
207
new PrivilegedAction<String>() {
208
public String run() {
209
return System.getProperty("sun.management.compiler");
214
public long getTotalCompileTime() {
215
throw new Error("Not implemented");
219
public long getTotalThreadCount() {
220
throw new Error("Not implemented");
222
public int getLiveThreadCount() {
223
throw new Error("Not implemented");
225
public int getPeakThreadCount() {
226
throw new Error("Not implemented");
228
public int getDaemonThreadCount() {
229
throw new Error("Not implemented");
233
public String getOsName() {
234
return System.getProperty("os.name");
236
public String getOsArch() {
237
return System.getProperty("os.arch");
239
public String getOsVersion() {
240
return System.getProperty("os.version");
243
// Hotspot-specific runtime support
244
public long getSafepointCount() {
245
throw new Error("Not implemented");
247
public long getTotalSafepointTime() {
248
throw new Error("Not implemented");
250
public long getSafepointSyncTime() {
251
throw new Error("Not implemented");
253
public long getTotalApplicationNonStoppedTime() {
254
throw new Error("Not implemented");
257
public long getLoadedClassSize() {
258
throw new Error("Not implemented");
260
public long getUnloadedClassSize() {
261
throw new Error("Not implemented");
263
public long getClassLoadingTime() {
264
throw new Error("Not implemented");
266
public long getMethodDataSize() {
267
throw new Error("Not implemented");
269
public long getInitializedClassCount() {
270
throw new Error("Not implemented");
272
public long getClassInitializationTime() {
273
throw new Error("Not implemented");
275
public long getClassVerificationTime() {
276
throw new Error("Not implemented");
279
public List<Counter> getInternalCounters(String pattern) {
280
return Collections.emptyList();