~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ikvm/openjdk/sun/management/VMManagementImpl.java

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
4
 *
 
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.
 
10
 *
 
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).
 
16
 *
 
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.
 
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 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;
 
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 = "1.2";
 
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
 
 
60
    // Optional supports
 
61
    public boolean isCompilationTimeMonitoringSupported() {
 
62
        return compTimeMonitoringSupport;
 
63
    }
 
64
 
 
65
    public boolean isThreadContentionMonitoringSupported() {
 
66
        return threadContentionMonitoringSupport;
 
67
    }
 
68
 
 
69
    public boolean isCurrentThreadCpuTimeSupported() {
 
70
        return currentThreadCpuTimeSupport;
 
71
    }
 
72
 
 
73
    public boolean isOtherThreadCpuTimeSupported() {
 
74
        return otherThreadCpuTimeSupport;
 
75
    }
 
76
 
 
77
    public boolean isBootClassPathSupported() {
 
78
        return bootClassPathSupport;
 
79
    }
 
80
 
 
81
    public boolean isObjectMonitorUsageSupported() {
 
82
        return objectMonitorUsageSupport;
 
83
    }
 
84
 
 
85
    public boolean isSynchronizerUsageSupported() {
 
86
        return synchronizerUsageSupport;
 
87
    }
 
88
 
 
89
    public boolean isThreadAllocatedMemorySupported() {
 
90
        return threadAllocatedMemorySupport;
 
91
    }
 
92
 
 
93
    public boolean isGcNotificationSupported() {
 
94
        return gcNotificationSupport;
 
95
    }
 
96
 
 
97
    public boolean isThreadContentionMonitoringEnabled() {
 
98
        return false;
 
99
    }
 
100
 
 
101
    public boolean isThreadCpuTimeEnabled() {
 
102
        return false;
 
103
    }
 
104
 
 
105
    public boolean isThreadAllocatedMemoryEnabled() {
 
106
        return false;
 
107
    }
 
108
 
 
109
    // Class Loading Subsystem
 
110
    public int    getLoadedClassCount() {
 
111
        long count = getTotalClassCount() - getUnloadedClassCount();
 
112
        return (int) count;
 
113
    }
 
114
    public long getTotalClassCount() {
 
115
        throw new Error("Not implemented");
 
116
    }
 
117
    public long getUnloadedClassCount() {
 
118
        throw new Error("Not implemented");
 
119
    }
 
120
 
 
121
    public boolean getVerboseClass() {
 
122
        return false;
 
123
    }
 
124
 
 
125
    // Memory Subsystem
 
126
    public boolean getVerboseGC() {
 
127
        return false;
 
128
    }
 
129
 
 
130
    // Runtime Subsystem
 
131
    public String   getManagementVersion() {
 
132
        return version;
 
133
    }
 
134
 
 
135
    public String getVmId() {
 
136
        int pid = getProcessId();
 
137
        String hostname = "localhost";
 
138
        try {
 
139
            hostname = InetAddress.getLocalHost().getHostName();
 
140
        } catch (UnknownHostException e) {
 
141
            // ignore
 
142
        }
 
143
 
 
144
        return pid + "@" + hostname;
 
145
    }
 
146
    private int getProcessId() {
 
147
        return cli.System.Diagnostics.Process.GetCurrentProcess().get_Id();
 
148
    }
 
149
 
 
150
    public String   getVmName() {
 
151
        return System.getProperty("java.vm.name");
 
152
    }
 
153
 
 
154
    public String   getVmVendor() {
 
155
        return System.getProperty("java.vm.vendor");
 
156
    }
 
157
    public String   getVmVersion() {
 
158
        return System.getProperty("java.vm.version");
 
159
    }
 
160
    public String   getVmSpecName()  {
 
161
        return System.getProperty("java.vm.specification.name");
 
162
    }
 
163
    public String   getVmSpecVendor() {
 
164
        return System.getProperty("java.vm.specification.vendor");
 
165
    }
 
166
    public String   getVmSpecVersion() {
 
167
        return System.getProperty("java.vm.specification.version");
 
168
    }
 
169
    public String   getClassPath() {
 
170
        return System.getProperty("java.class.path");
 
171
    }
 
172
    public String   getLibraryPath()  {
 
173
        return System.getProperty("java.library.path");
 
174
    }
 
175
 
 
176
    public String   getBootClassPath( ) {
 
177
        PrivilegedAction<String> pa
 
178
            = new GetPropertyAction("sun.boot.class.path");
 
179
        String result =  AccessController.doPrivileged(pa);
 
180
        return result;
 
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 String[] getVmArguments0() {
 
194
        return new String[0];
 
195
    }
 
196
 
 
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();
 
199
    }
 
200
    public int getAvailableProcessors() {
 
201
        return cli.System.Environment.get_ProcessorCount();
 
202
    }
 
203
 
 
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");
 
210
                }
 
211
            });
 
212
        return name;
 
213
    }
 
214
    public long getTotalCompileTime() {
 
215
        throw new Error("Not implemented");
 
216
    }
 
217
 
 
218
    // Thread Subsystem
 
219
    public long getTotalThreadCount() {
 
220
        throw new Error("Not implemented");
 
221
    }
 
222
    public int  getLiveThreadCount() {
 
223
        throw new Error("Not implemented");
 
224
    }
 
225
    public int  getPeakThreadCount() {
 
226
        throw new Error("Not implemented");
 
227
    }
 
228
    public int  getDaemonThreadCount() {
 
229
        throw new Error("Not implemented");
 
230
    }
 
231
 
 
232
    // Operating System
 
233
    public String getOsName() {
 
234
        return System.getProperty("os.name");
 
235
    }
 
236
    public String getOsArch() {
 
237
        return System.getProperty("os.arch");
 
238
    }
 
239
    public String getOsVersion() {
 
240
        return System.getProperty("os.version");
 
241
    }
 
242
 
 
243
    // Hotspot-specific runtime support
 
244
    public long getSafepointCount() {
 
245
        throw new Error("Not implemented");
 
246
    }
 
247
    public long getTotalSafepointTime() {
 
248
        throw new Error("Not implemented");
 
249
    }
 
250
    public long getSafepointSyncTime() {
 
251
        throw new Error("Not implemented");
 
252
    }
 
253
    public long getTotalApplicationNonStoppedTime() {
 
254
        throw new Error("Not implemented");
 
255
    }
 
256
 
 
257
    public long getLoadedClassSize() {
 
258
        throw new Error("Not implemented");
 
259
    }
 
260
    public long getUnloadedClassSize() {
 
261
        throw new Error("Not implemented");
 
262
    }
 
263
    public long getClassLoadingTime() {
 
264
        throw new Error("Not implemented");
 
265
    }
 
266
    public long getMethodDataSize() {
 
267
        throw new Error("Not implemented");
 
268
    }
 
269
    public long getInitializedClassCount() {
 
270
        throw new Error("Not implemented");
 
271
    }
 
272
    public long getClassInitializationTime() {
 
273
        throw new Error("Not implemented");
 
274
    }
 
275
    public long getClassVerificationTime() {
 
276
        throw new Error("Not implemented");
 
277
    }
 
278
 
 
279
    public List<Counter> getInternalCounters(String pattern) {
 
280
        return Collections.emptyList();
 
281
    }
 
282
}