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 jdk.internal.misc;
27
28 import static java.lang.Thread.State.*;
29
30 import java.util.Collections;
31 import java.util.Map;
32 import java.util.Properties;
33
34 public class VM {
35
36 // the init level when the VM is fully initialized
37 private static final int JAVA_LANG_SYSTEM_INITED = 1;
38 private static final int MODULE_SYSTEM_INITED = 2;
39 private static final int SYSTEM_LOADER_INITIALIZING = 3;
40 private static final int SYSTEM_BOOTED = 4;
41 private static final int SYSTEM_SHUTDOWN = 5;
42
43
44 // 0, 1, 2, ...
45 private static volatile int initLevel;
46 private static final Object lock = new Object();
47
48 /**
49 * Sets the init level.
50 *
51 * @see java.lang.System#initPhase1
52 * @see java.lang.System#initPhase2
53 * @see java.lang.System#initPhase3
397 * If VM options file is specified via -XX:VMOptionsFile, the vm options
398 * file is read and expanded in place of -XX:VMOptionFile option.
399 */
400 public static native String[] getRuntimeArguments();
401
402 static {
403 initialize();
404 }
405 private static native void initialize();
406
407 /**
408 * Initialize archived static fields in the given Class using archived
409 * values from CDS dump time. Also initialize the classes of objects in
410 * the archived graph referenced by those fields.
411 *
412 * Those static fields remain as uninitialized if there is no mapped CDS
413 * java heap data or there is any error during initialization of the
414 * object class in the archived graph.
415 */
416 public static native void initializeFromArchive(Class<?> c);
417 }
|
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 jdk.internal.misc;
27
28 import static java.lang.Thread.State.*;
29
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.List;
33 import java.util.Map;
34 import java.util.Properties;
35
36 import jdk.internal.access.SharedSecrets;
37
38 import sun.nio.ch.FileChannelImpl;
39
40 public class VM {
41
42 // the init level when the VM is fully initialized
43 private static final int JAVA_LANG_SYSTEM_INITED = 1;
44 private static final int MODULE_SYSTEM_INITED = 2;
45 private static final int SYSTEM_LOADER_INITIALIZING = 3;
46 private static final int SYSTEM_BOOTED = 4;
47 private static final int SYSTEM_SHUTDOWN = 5;
48
49
50 // 0, 1, 2, ...
51 private static volatile int initLevel;
52 private static final Object lock = new Object();
53
54 /**
55 * Sets the init level.
56 *
57 * @see java.lang.System#initPhase1
58 * @see java.lang.System#initPhase2
59 * @see java.lang.System#initPhase3
403 * If VM options file is specified via -XX:VMOptionsFile, the vm options
404 * file is read and expanded in place of -XX:VMOptionFile option.
405 */
406 public static native String[] getRuntimeArguments();
407
408 static {
409 initialize();
410 }
411 private static native void initialize();
412
413 /**
414 * Initialize archived static fields in the given Class using archived
415 * values from CDS dump time. Also initialize the classes of objects in
416 * the archived graph referenced by those fields.
417 *
418 * Those static fields remain as uninitialized if there is no mapped CDS
419 * java heap data or there is any error during initialization of the
420 * object class in the archived graph.
421 */
422 public static native void initializeFromArchive(Class<?> c);
423
424 /**
425 * Provides access to information on buffer usage.
426 */
427 public interface BufferPool {
428 String getName();
429 long getCount();
430 long getTotalCapacity();
431 long getMemoryUsed();
432 }
433
434 private static class BufferPoolsHolder {
435 static final List<BufferPool> BUFFER_POOLS;
436
437 static {
438 ArrayList<BufferPool> bufferPools = new ArrayList<>(3);
439 bufferPools.add(SharedSecrets.getJavaNioAccess().getDirectBufferPool());
440 bufferPools.add(FileChannelImpl.getMappedBufferPool());
441 bufferPools.add(FileChannelImpl.getSyncMappedBufferPool());
442
443 BUFFER_POOLS = Collections.unmodifiableList(bufferPools);
444 }
445 }
446
447 /**
448 * @return the list of buffer pools.
449 */
450 public static List<BufferPool> getBufferPools() {
451 return BufferPoolsHolder.BUFFER_POOLS;
452 }
453 }
|