equal
deleted
inserted
replaced
25 |
25 |
26 package jdk.internal.misc; |
26 package jdk.internal.misc; |
27 |
27 |
28 import static java.lang.Thread.State.*; |
28 import static java.lang.Thread.State.*; |
29 import java.util.Map; |
29 import java.util.Map; |
30 import java.util.HashMap; |
|
31 import java.util.Properties; |
30 import java.util.Properties; |
32 import java.util.Collections; |
|
33 |
31 |
34 public class VM { |
32 public class VM { |
35 |
33 |
36 // the init level when the VM is fully initialized |
34 // the init level when the VM is fully initialized |
37 private static final int JAVA_LANG_SYSTEM_INITED = 1; |
35 private static final int JAVA_LANG_SYSTEM_INITED = 1; |
38 private static final int MODULE_SYSTEM_INITED = 2; |
36 private static final int MODULE_SYSTEM_INITED = 2; |
39 private static final int SYSTEM_LOADER_INITIALIZING = 3; |
37 private static final int SYSTEM_LOADER_INITIALIZING = 3; |
40 private static final int SYSTEM_BOOTED = 4; |
38 private static final int SYSTEM_BOOTED = 4; |
|
39 private static final int SYSTEM_SHUTDOWN = 5; |
|
40 |
41 |
41 |
42 // 0, 1, 2, ... |
42 // 0, 1, 2, ... |
43 private static volatile int initLevel; |
43 private static volatile int initLevel; |
44 private static final Object lock = new Object(); |
44 private static final Object lock = new Object(); |
45 |
45 |
50 * @see java.lang.System#initPhase2 |
50 * @see java.lang.System#initPhase2 |
51 * @see java.lang.System#initPhase3 |
51 * @see java.lang.System#initPhase3 |
52 */ |
52 */ |
53 public static void initLevel(int value) { |
53 public static void initLevel(int value) { |
54 synchronized (lock) { |
54 synchronized (lock) { |
55 if (value <= initLevel || value > SYSTEM_BOOTED) |
55 if (value <= initLevel || value > SYSTEM_SHUTDOWN) |
56 throw new InternalError("Bad level: " + value); |
56 throw new InternalError("Bad level: " + value); |
57 initLevel = value; |
57 initLevel = value; |
58 lock.notifyAll(); |
58 lock.notifyAll(); |
59 } |
59 } |
60 } |
60 } |
90 /** |
90 /** |
91 * Returns {@code true} if the VM is fully initialized. |
91 * Returns {@code true} if the VM is fully initialized. |
92 */ |
92 */ |
93 public static boolean isBooted() { |
93 public static boolean isBooted() { |
94 return initLevel >= SYSTEM_BOOTED; |
94 return initLevel >= SYSTEM_BOOTED; |
|
95 } |
|
96 |
|
97 /** |
|
98 * Set shutdown state. Shutdown completes when all registered shutdown |
|
99 * hooks have been run. |
|
100 * |
|
101 * @see java.lang.Shutdown |
|
102 */ |
|
103 public static void shutdown() { |
|
104 initLevel(SYSTEM_SHUTDOWN); |
|
105 } |
|
106 |
|
107 /** |
|
108 * Returns {@code true} if the VM has been shutdown |
|
109 */ |
|
110 public static boolean isShutdown() { |
|
111 return initLevel == SYSTEM_SHUTDOWN; |
95 } |
112 } |
96 |
113 |
97 // A user-settable upper limit on the maximum amount of allocatable direct |
114 // A user-settable upper limit on the maximum amount of allocatable direct |
98 // buffer memory. This value may be changed during VM initialization if |
115 // buffer memory. This value may be changed during VM initialization if |
99 // "java" is launched with "-XX:MaxDirectMemorySize=<size>". |
116 // "java" is launched with "-XX:MaxDirectMemorySize=<size>". |