Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.management/share/classes/java/lang/management/RuntimeMXBean.java
41159 views
1
/*
2
* Copyright (c) 2003, 2021, 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 java.lang.management;
27
28
import java.security.AccessController;
29
import java.security.PrivilegedAction;
30
31
/**
32
* The management interface for the runtime system of
33
* the Java virtual machine.
34
*
35
* <p> A Java virtual machine has a single instance of the implementation
36
* class of this interface. This instance implementing this interface is
37
* an <a href="ManagementFactory.html#MXBean">MXBean</a>
38
* that can be obtained by calling
39
* the {@link ManagementFactory#getRuntimeMXBean} method or
40
* from the {@link ManagementFactory#getPlatformMBeanServer
41
* platform MBeanServer} method.
42
*
43
* <p>The {@code ObjectName} for uniquely identifying the MXBean for
44
* the runtime system within an MBeanServer is:
45
* <blockquote>
46
* {@link ManagementFactory#RUNTIME_MXBEAN_NAME
47
* java.lang:type=Runtime}
48
* </blockquote>
49
*
50
* It can be obtained by calling the
51
* {@link PlatformManagedObject#getObjectName} method.
52
*
53
* <p> This interface defines several convenient methods for accessing
54
* system properties about the Java virtual machine.
55
*
56
* @see ManagementFactory#getPlatformMXBeans(Class)
57
* @see <a href="../../../javax/management/package-summary.html">
58
* JMX Specification.</a>
59
* @see <a href="package-summary.html#examples">
60
* Ways to Access MXBeans</a>
61
*
62
* @author Mandy Chung
63
* @since 1.5
64
*/
65
public interface RuntimeMXBean extends PlatformManagedObject {
66
/**
67
* Returns the {@linkplain ProcessHandle#pid process ID} representing
68
* the running Java virtual machine.
69
*
70
* @implSpec The default implementation returns {@link ProcessHandle#pid process ID}
71
* of the {@linkplain ProcessHandle#current current process}.
72
*
73
* @return the process ID representing the running Java virtual machine.
74
*
75
* @since 10
76
*/
77
@SuppressWarnings("removal")
78
public default long getPid() {
79
return AccessController.doPrivileged((PrivilegedAction<Long>)
80
() -> ProcessHandle.current().pid());
81
}
82
83
/**
84
* Returns the name representing the running Java virtual machine.
85
* The returned name string can be any arbitrary string and
86
* a Java virtual machine implementation can choose
87
* to embed platform-specific useful information in the
88
* returned name string. Each running virtual machine could have
89
* a different name.
90
*
91
* @return the name representing the running Java virtual machine.
92
*/
93
public String getName();
94
95
/**
96
* Returns the Java virtual machine implementation name.
97
* This method is equivalent to {@link System#getProperty
98
* System.getProperty("java.vm.name")}.
99
*
100
* @return the Java virtual machine implementation name.
101
*
102
* @throws java.lang.SecurityException
103
* if a security manager exists and its
104
* {@code checkPropertiesAccess} method doesn't allow access
105
* to this system property.
106
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
107
* @see java.lang.System#getProperty
108
*/
109
public String getVmName();
110
111
/**
112
* Returns the Java virtual machine implementation vendor.
113
* This method is equivalent to {@link System#getProperty
114
* System.getProperty("java.vm.vendor")}.
115
*
116
* @return the Java virtual machine implementation vendor.
117
*
118
* @throws java.lang.SecurityException
119
* if a security manager exists and its
120
* {@code checkPropertiesAccess} method doesn't allow access
121
* to this system property.
122
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
123
* @see java.lang.System#getProperty
124
*/
125
public String getVmVendor();
126
127
/**
128
* Returns the Java virtual machine implementation version.
129
* This method is equivalent to {@link System#getProperty
130
* System.getProperty("java.vm.version")}.
131
*
132
* @return the Java virtual machine implementation version.
133
*
134
* @throws java.lang.SecurityException
135
* if a security manager exists and its
136
* {@code checkPropertiesAccess} method doesn't allow access
137
* to this system property.
138
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
139
* @see java.lang.System#getProperty
140
*/
141
public String getVmVersion();
142
143
/**
144
* Returns the Java virtual machine specification name.
145
* This method is equivalent to {@link System#getProperty
146
* System.getProperty("java.vm.specification.name")}.
147
*
148
* @return the Java virtual machine specification name.
149
*
150
* @throws java.lang.SecurityException
151
* if a security manager exists and its
152
* {@code checkPropertiesAccess} method doesn't allow access
153
* to this system property.
154
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
155
* @see java.lang.System#getProperty
156
*/
157
public String getSpecName();
158
159
/**
160
* Returns the Java virtual machine specification vendor.
161
* This method is equivalent to {@link System#getProperty
162
* System.getProperty("java.vm.specification.vendor")}.
163
*
164
* @return the Java virtual machine specification vendor.
165
*
166
* @throws java.lang.SecurityException
167
* if a security manager exists and its
168
* {@code checkPropertiesAccess} method doesn't allow access
169
* to this system property.
170
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
171
* @see java.lang.System#getProperty
172
*/
173
public String getSpecVendor();
174
175
/**
176
* Returns the Java virtual machine specification version.
177
* This method is equivalent to {@link System#getProperty
178
* System.getProperty("java.vm.specification.version")}.
179
*
180
* @return the Java virtual machine specification version.
181
*
182
* @throws java.lang.SecurityException
183
* if a security manager exists and its
184
* {@code checkPropertiesAccess} method doesn't allow access
185
* to this system property.
186
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
187
* @see java.lang.System#getProperty
188
*/
189
public String getSpecVersion();
190
191
192
/**
193
* Returns the version of the specification for the management interface
194
* implemented by the running Java virtual machine.
195
*
196
* @return the version of the specification for the management interface
197
* implemented by the running Java virtual machine.
198
*/
199
public String getManagementSpecVersion();
200
201
/**
202
* Returns the Java class path that is used by the system class loader
203
* to search for class files.
204
* This method is equivalent to {@link System#getProperty
205
* System.getProperty("java.class.path")}.
206
*
207
* <p> Multiple paths in the Java class path are separated by the
208
* path separator character of the platform of the Java virtual machine
209
* being monitored.
210
*
211
* @return the Java class path.
212
*
213
* @throws java.lang.SecurityException
214
* if a security manager exists and its
215
* {@code checkPropertiesAccess} method doesn't allow access
216
* to this system property.
217
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
218
* @see java.lang.System#getProperty
219
*/
220
public String getClassPath();
221
222
/**
223
* Returns the Java library path.
224
* This method is equivalent to {@link System#getProperty
225
* System.getProperty("java.library.path")}.
226
*
227
* <p> Multiple paths in the Java library path are separated by the
228
* path separator character of the platform of the Java virtual machine
229
* being monitored.
230
*
231
* @return the Java library path.
232
*
233
* @throws java.lang.SecurityException
234
* if a security manager exists and its
235
* {@code checkPropertiesAccess} method doesn't allow access
236
* to this system property.
237
* @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
238
* @see java.lang.System#getProperty
239
*/
240
public String getLibraryPath();
241
242
/**
243
* Tests if the Java virtual machine supports the boot class path
244
* mechanism used by the bootstrap class loader to search for class
245
* files.
246
*
247
* @return {@code true} if the Java virtual machine supports the
248
* class path mechanism; {@code false} otherwise.
249
*/
250
public boolean isBootClassPathSupported();
251
252
/**
253
* Returns the boot class path that is used by the bootstrap class loader
254
* to search for class files.
255
*
256
* <p> Multiple paths in the boot class path are separated by the
257
* path separator character of the platform on which the Java
258
* virtual machine is running.
259
*
260
* <p>A Java virtual machine implementation may not support
261
* the boot class path mechanism for the bootstrap class loader
262
* to search for class files.
263
* The {@link #isBootClassPathSupported} method can be used
264
* to determine if the Java virtual machine supports this method.
265
*
266
* @return the boot class path.
267
*
268
* @throws java.lang.UnsupportedOperationException
269
* if the Java virtual machine does not support this operation.
270
*
271
* @throws java.lang.SecurityException
272
* if a security manager exists and the caller does not have
273
* ManagementPermission("monitor").
274
*/
275
public String getBootClassPath();
276
277
/**
278
* Returns the input arguments passed to the Java virtual machine
279
* which does not include the arguments to the {@code main} method.
280
* This method returns an empty list if there is no input argument
281
* to the Java virtual machine.
282
* <p>
283
* Some Java virtual machine implementations may take input arguments
284
* from multiple different sources: for examples, arguments passed from
285
* the application that launches the Java virtual machine such as
286
* the 'java' command, environment variables, configuration files, etc.
287
* <p>
288
* Typically, not all command-line options to the 'java' command
289
* are passed to the Java virtual machine.
290
* Thus, the returned input arguments may not
291
* include all command-line options.
292
*
293
* <p>
294
* <b>MBeanServer access</b>:<br>
295
* The mapped type of {@code List<String>} is {@code String[]}.
296
*
297
* @return a list of {@code String} objects; each element
298
* is an argument passed to the Java virtual machine.
299
*
300
* @throws java.lang.SecurityException
301
* if a security manager exists and the caller does not have
302
* ManagementPermission("monitor").
303
*/
304
public java.util.List<String> getInputArguments();
305
306
/**
307
* Returns the uptime of the Java virtual machine in milliseconds.
308
*
309
* @return uptime of the Java virtual machine in milliseconds.
310
*/
311
public long getUptime();
312
313
/**
314
* Returns the start time of the Java virtual machine in milliseconds.
315
* This method returns the approximate time when the Java virtual
316
* machine started.
317
*
318
* @return start time of the Java virtual machine in milliseconds.
319
*
320
*/
321
public long getStartTime();
322
323
/**
324
* Returns a map of names and values of all system properties.
325
* This method calls {@link System#getProperties} to get all
326
* system properties. Properties whose name or value is not
327
* a {@code String} are omitted.
328
*
329
* <p>
330
* <b>MBeanServer access</b>:<br>
331
* The mapped type of {@code Map<String,String>} is
332
* {@link javax.management.openmbean.TabularData TabularData}
333
* with two items in each row as follows:
334
* <table class="striped" style="margin-left:2em">
335
* <caption style="display:none">Name and Type for each item</caption>
336
* <thead>
337
* <tr>
338
* <th scope="col">Item Name</th>
339
* <th scope="col">Item Type</th>
340
* </tr>
341
* </thead>
342
* <tbody>
343
* <tr style="text-align:left">
344
* <th scope="row">{@code key}</th>
345
* <td>{@code String}</td>
346
* </tr>
347
* <tr>
348
* <th scope="row">{@code value}</th>
349
* <td>{@code String}</td>
350
* </tr>
351
* </tbody>
352
* </table>
353
*
354
* @return a map of names and values of all system properties.
355
*
356
* @throws java.lang.SecurityException
357
* if a security manager exists and its
358
* {@code checkPropertiesAccess} method doesn't allow access
359
* to the system properties.
360
*/
361
public java.util.Map<String, String> getSystemProperties();
362
}
363
364