author | martin |
Tue, 15 Sep 2015 21:56:04 -0700 | |
changeset 32649 | 2ee9017c7597 |
parent 30655 | d83f50188ca9 |
child 34525 | 14d2d84cae6d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
28765
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
2 |
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.misc; |
|
27 |
||
7540 | 28 |
import static java.lang.Thread.State.*; |
2 | 29 |
import java.util.Properties; |
30 |
import java.util.HashMap; |
|
31 |
import java.util.Map; |
|
32 |
import java.util.Set; |
|
33 |
||
34 |
public class VM { |
|
35 |
||
36 |
/* The following methods used to be native methods that instruct |
|
37 |
* the VM to selectively suspend certain threads in low-memory |
|
38 |
* situations. They are inherently dangerous and not implementable |
|
39 |
* on native threads. We removed them in JDK 1.2. The skeletons |
|
40 |
* remain so that existing applications that use these methods |
|
41 |
* will still work. |
|
42 |
*/ |
|
43 |
private static boolean suspended = false; |
|
44 |
||
45 |
/** @deprecated */ |
|
46 |
@Deprecated |
|
47 |
public static boolean threadsSuspended() { |
|
48 |
return suspended; |
|
49 |
} |
|
50 |
||
11117
b6e68b1344d4
7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents:
10797
diff
changeset
|
51 |
@SuppressWarnings("deprecation") |
2 | 52 |
public static boolean allowThreadSuspension(ThreadGroup g, boolean b) { |
53 |
return g.allowThreadSuspension(b); |
|
54 |
} |
|
55 |
||
56 |
/** @deprecated */ |
|
57 |
@Deprecated |
|
58 |
public static boolean suspendThreads() { |
|
59 |
suspended = true; |
|
60 |
return true; |
|
61 |
} |
|
62 |
||
63 |
// Causes any suspended threadgroups to be resumed. |
|
64 |
/** @deprecated */ |
|
65 |
@Deprecated |
|
66 |
public static void unsuspendThreads() { |
|
67 |
suspended = false; |
|
68 |
} |
|
69 |
||
70 |
// Causes threadgroups no longer marked suspendable to be resumed. |
|
71 |
/** @deprecated */ |
|
72 |
@Deprecated |
|
73 |
public static void unsuspendSomeThreads() { |
|
74 |
} |
|
75 |
||
76 |
/* Deprecated fields and methods -- Memory advice not supported in 1.2 */ |
|
77 |
||
78 |
/** @deprecated */ |
|
79 |
@Deprecated |
|
80 |
public static final int STATE_GREEN = 1; |
|
81 |
||
82 |
/** @deprecated */ |
|
83 |
@Deprecated |
|
84 |
public static final int STATE_YELLOW = 2; |
|
85 |
||
86 |
/** @deprecated */ |
|
87 |
@Deprecated |
|
88 |
public static final int STATE_RED = 3; |
|
89 |
||
90 |
/** @deprecated */ |
|
91 |
@Deprecated |
|
92 |
public static final int getState() { |
|
93 |
return STATE_GREEN; |
|
94 |
} |
|
95 |
||
96 |
/** @deprecated */ |
|
97 |
@Deprecated |
|
98 |
public static void registerVMNotification(VMNotification n) { } |
|
99 |
||
100 |
/** @deprecated */ |
|
101 |
@Deprecated |
|
102 |
public static void asChange(int as_old, int as_new) { } |
|
103 |
||
104 |
/** @deprecated */ |
|
105 |
@Deprecated |
|
106 |
public static void asChange_otherthread(int as_old, int as_new) { } |
|
107 |
||
108 |
/* |
|
109 |
* Not supported in 1.2 because these will have to be exported as |
|
110 |
* JVM functions, and we are not sure we want do that. Leaving |
|
111 |
* here so it can be easily resurrected -- just remove the // |
|
112 |
* comments. |
|
113 |
*/ |
|
114 |
||
115 |
/** |
|
116 |
* Resume Java profiling. All profiling data is added to any |
|
117 |
* earlier profiling, unless <code>resetJavaProfiler</code> is |
|
118 |
* called in between. If profiling was not started from the |
|
119 |
* command line, <code>resumeJavaProfiler</code> will start it. |
|
120 |
* <p> |
|
121 |
* |
|
122 |
* NOTE: Profiling must be enabled from the command line for a |
|
123 |
* java.prof report to be automatically generated on exit; if not, |
|
124 |
* writeJavaProfilerReport must be invoked to write a report. |
|
125 |
* |
|
126 |
* @see resetJavaProfiler |
|
127 |
* @see writeJavaProfilerReport |
|
128 |
*/ |
|
129 |
||
130 |
// public native static void resumeJavaProfiler(); |
|
131 |
||
132 |
/** |
|
133 |
* Suspend Java profiling. |
|
134 |
*/ |
|
135 |
// public native static void suspendJavaProfiler(); |
|
136 |
||
137 |
/** |
|
138 |
* Initialize Java profiling. Any accumulated profiling |
|
139 |
* information is discarded. |
|
140 |
*/ |
|
141 |
// public native static void resetJavaProfiler(); |
|
142 |
||
143 |
/** |
|
144 |
* Write the current profiling contents to the file "java.prof". |
|
145 |
* If the file already exists, it will be overwritten. |
|
146 |
*/ |
|
147 |
// public native static void writeJavaProfilerReport(); |
|
148 |
||
149 |
||
150 |
private static volatile boolean booted = false; |
|
21628
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
151 |
private static final Object lock = new Object(); |
2 | 152 |
|
28059
e576535359cc
8067377: My hobby: caning, then then canning, the the can-can
martin
parents:
25859
diff
changeset
|
153 |
// Invoked by System.initializeSystemClass just before returning. |
2 | 154 |
// Subsystems that are invoked during initialization can check this |
155 |
// property in order to avoid doing things that should wait until the |
|
156 |
// application class loader has been set up. |
|
157 |
// |
|
158 |
public static void booted() { |
|
21628
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
159 |
synchronized (lock) { |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
160 |
booted = true; |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
161 |
lock.notifyAll(); |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
162 |
} |
2 | 163 |
} |
164 |
||
165 |
public static boolean isBooted() { |
|
166 |
return booted; |
|
167 |
} |
|
168 |
||
21628
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
169 |
// Waits until VM completes initialization |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
170 |
// |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
171 |
// This method is invoked by the Finalizer thread |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
172 |
public static void awaitBooted() throws InterruptedException { |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
173 |
synchronized (lock) { |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
174 |
while (!booted) { |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
175 |
lock.wait(); |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
176 |
} |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
177 |
} |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
178 |
} |
50fd58446d64
8027351: (ref) Private finalize method invoked in preference to protected superclass method
mchung
parents:
14342
diff
changeset
|
179 |
|
2 | 180 |
// A user-settable upper limit on the maximum amount of allocatable direct |
181 |
// buffer memory. This value may be changed during VM initialization if |
|
182 |
// "java" is launched with "-XX:MaxDirectMemorySize=<size>". |
|
183 |
// |
|
184 |
// The initial value of this field is arbitrary; during JRE initialization |
|
185 |
// it will be reset to the value specified on the command line, if any, |
|
11515
841d5f796b28
7128584: Typo in sun.misc.VM's private directMemory field comment
chegar
parents:
11117
diff
changeset
|
186 |
// otherwise to Runtime.getRuntime().maxMemory(). |
2 | 187 |
// |
188 |
private static long directMemory = 64 * 1024 * 1024; |
|
189 |
||
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
190 |
// Returns the maximum amount of allocatable direct buffer memory. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
191 |
// The directMemory variable is initialized during system initialization |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
192 |
// in the saveAndRemoveProperties method. |
2 | 193 |
// |
194 |
public static long maxDirectMemory() { |
|
195 |
return directMemory; |
|
196 |
} |
|
197 |
||
6902
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
198 |
// User-controllable flag that determines if direct buffers should be page |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
199 |
// aligned. The "-XX:+PageAlignDirectMemory" option can be used to force |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
200 |
// buffers, allocated by ByteBuffer.allocateDirect, to be page aligned. |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
201 |
private static boolean pageAlignDirectMemory; |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
202 |
|
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
203 |
// Returns {@code true} if the direct buffers should be page aligned. This |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
204 |
// variable is initialized by saveAndRemoveProperties. |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
205 |
public static boolean isDirectMemoryPageAligned() { |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
206 |
return pageAlignDirectMemory; |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
207 |
} |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
208 |
|
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
209 |
/** |
13589
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
210 |
* Returns true if the given class loader is in the system domain |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
211 |
* in which all permissions are granted. |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
212 |
*/ |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
213 |
public static boolean isSystemDomainLoader(ClassLoader loader) { |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
214 |
return loader == null; |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
215 |
} |
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
216 |
|
da4cb574f4a6
7193339: Prepare system classes be defined by a non-null module loader
mchung
parents:
11515
diff
changeset
|
217 |
/** |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
218 |
* Returns the system property of the specified key saved at |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
219 |
* system initialization time. This method should only be used |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
220 |
* for the system properties that are not changed during runtime. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
221 |
* It accesses a private copy of the system properties so |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
222 |
* that user's locking of the system properties object will not |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
223 |
* cause the library to deadlock. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
224 |
* |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
225 |
* Note that the saved system properties do not include |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
226 |
* the ones set by sun.misc.Version.init(). |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
227 |
* |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
228 |
*/ |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
229 |
public static String getSavedProperty(String key) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
230 |
if (savedProps.isEmpty()) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
231 |
throw new IllegalStateException("Should be non-empty if initialized"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
232 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
233 |
return savedProps.getProperty(key); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
234 |
} |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
235 |
|
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
236 |
// TODO: the Property Management needs to be refactored and |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
237 |
// the appropriate prop keys need to be accessible to the |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
238 |
// calling classes to avoid duplication of keys. |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
239 |
private static final Properties savedProps = new Properties(); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
240 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
241 |
// Save a private copy of the system properties and remove |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
242 |
// the system properties that are not intended for public access. |
2 | 243 |
// |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
244 |
// This method can only be invoked during system initialization. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
245 |
public static void saveAndRemoveProperties(Properties props) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
246 |
if (booted) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
247 |
throw new IllegalStateException("System initialization has completed"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
248 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
249 |
savedProps.putAll(props); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
250 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
251 |
// Set the maximum amount of direct memory. This value is controlled |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
252 |
// by the vm option -XX:MaxDirectMemorySize=<size>. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
253 |
// The maximum amount of allocatable direct buffer memory (in bytes) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
254 |
// from the system property sun.nio.MaxDirectMemorySize set by the VM. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
255 |
// The system property will be removed. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
256 |
String s = (String)props.remove("sun.nio.MaxDirectMemorySize"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
257 |
if (s != null) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
258 |
if (s.equals("-1")) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
259 |
// -XX:MaxDirectMemorySize not given, take default |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
260 |
directMemory = Runtime.getRuntime().maxMemory(); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
261 |
} else { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
262 |
long l = Long.parseLong(s); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
263 |
if (l > -1) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
264 |
directMemory = l; |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
265 |
} |
2 | 266 |
} |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
267 |
|
6902
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
268 |
// Check if direct buffers should be page aligned |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
269 |
s = (String)props.remove("sun.nio.PageAlignDirectMemory"); |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
270 |
if ("true".equals(s)) |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
271 |
pageAlignDirectMemory = true; |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
272 |
|
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
273 |
// Remove other private system properties |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
274 |
// used by java.lang.Integer.IntegerCache |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
275 |
props.remove("java.lang.Integer.IntegerCache.high"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
276 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
277 |
// used by java.util.zip.ZipFile |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
278 |
props.remove("sun.zip.disableMemoryMapping"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
279 |
|
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
280 |
// used by sun.launcher.LauncherHelper |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
281 |
props.remove("sun.java.launcher.diag"); |
2 | 282 |
} |
283 |
||
284 |
// Initialize any miscellenous operating system settings that need to be |
|
285 |
// set for the class libraries. |
|
286 |
// |
|
287 |
public static void initializeOSEnvironment() { |
|
288 |
if (!booted) { |
|
289 |
OSEnvironment.initialize(); |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
/* Current count of objects pending for finalization */ |
|
294 |
private static volatile int finalRefCount = 0; |
|
295 |
||
296 |
/* Peak count of objects pending for finalization */ |
|
297 |
private static volatile int peakFinalRefCount = 0; |
|
298 |
||
299 |
/* |
|
300 |
* Gets the number of objects pending for finalization. |
|
301 |
* |
|
302 |
* @return the number of objects pending for finalization. |
|
303 |
*/ |
|
304 |
public static int getFinalRefCount() { |
|
305 |
return finalRefCount; |
|
306 |
} |
|
307 |
||
308 |
/* |
|
309 |
* Gets the peak number of objects pending for finalization. |
|
310 |
* |
|
311 |
* @return the peak number of objects pending for finalization. |
|
312 |
*/ |
|
313 |
public static int getPeakFinalRefCount() { |
|
314 |
return peakFinalRefCount; |
|
315 |
} |
|
316 |
||
317 |
/* |
|
30655 | 318 |
* Add {@code n} to the objects pending for finalization count. |
2 | 319 |
* |
320 |
* @param n an integer value to be added to the objects pending |
|
321 |
* for finalization count |
|
322 |
*/ |
|
323 |
public static void addFinalRefCount(int n) { |
|
324 |
// The caller must hold lock to synchronize the update. |
|
325 |
||
326 |
finalRefCount += n; |
|
327 |
if (finalRefCount > peakFinalRefCount) { |
|
328 |
peakFinalRefCount = finalRefCount; |
|
329 |
} |
|
330 |
} |
|
331 |
||
7540 | 332 |
/** |
333 |
* Returns Thread.State for the given threadStatus |
|
334 |
*/ |
|
2 | 335 |
public static Thread.State toThreadState(int threadStatus) { |
7540 | 336 |
if ((threadStatus & JVMTI_THREAD_STATE_RUNNABLE) != 0) { |
337 |
return RUNNABLE; |
|
338 |
} else if ((threadStatus & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) { |
|
339 |
return BLOCKED; |
|
340 |
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) != 0) { |
|
341 |
return WAITING; |
|
342 |
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) != 0) { |
|
343 |
return TIMED_WAITING; |
|
344 |
} else if ((threadStatus & JVMTI_THREAD_STATE_TERMINATED) != 0) { |
|
345 |
return TERMINATED; |
|
346 |
} else if ((threadStatus & JVMTI_THREAD_STATE_ALIVE) == 0) { |
|
347 |
return NEW; |
|
348 |
} else { |
|
349 |
return RUNNABLE; |
|
2 | 350 |
} |
351 |
} |
|
352 |
||
7540 | 353 |
/* The threadStatus field is set by the VM at state transition |
354 |
* in the hotspot implementation. Its value is set according to |
|
355 |
* the JVM TI specification GetThreadState function. |
|
356 |
*/ |
|
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
357 |
private static final int JVMTI_THREAD_STATE_ALIVE = 0x0001; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
358 |
private static final int JVMTI_THREAD_STATE_TERMINATED = 0x0002; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
359 |
private static final int JVMTI_THREAD_STATE_RUNNABLE = 0x0004; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
360 |
private static final int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
361 |
private static final int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
362 |
private static final int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020; |
2 | 363 |
|
10797
f51518b30c84
7104209: Cleanup and remove librmi (native library)
chegar
parents:
9035
diff
changeset
|
364 |
/* |
f51518b30c84
7104209: Cleanup and remove librmi (native library)
chegar
parents:
9035
diff
changeset
|
365 |
* Returns the first non-null class loader up the execution stack, |
f51518b30c84
7104209: Cleanup and remove librmi (native library)
chegar
parents:
9035
diff
changeset
|
366 |
* or null if only code from the null class loader is on the stack. |
f51518b30c84
7104209: Cleanup and remove librmi (native library)
chegar
parents:
9035
diff
changeset
|
367 |
*/ |
f51518b30c84
7104209: Cleanup and remove librmi (native library)
chegar
parents:
9035
diff
changeset
|
368 |
public static native ClassLoader latestUserDefinedLoader(); |
f51518b30c84
7104209: Cleanup and remove librmi (native library)
chegar
parents:
9035
diff
changeset
|
369 |
|
22951
5fd21112b2b6
8034043: Native methods for preferences API should not be in libjava
alanb
parents:
22571
diff
changeset
|
370 |
/** |
5fd21112b2b6
8034043: Native methods for preferences API should not be in libjava
alanb
parents:
22571
diff
changeset
|
371 |
* Returns {@code true} if we are in a set UID program. |
5fd21112b2b6
8034043: Native methods for preferences API should not be in libjava
alanb
parents:
22571
diff
changeset
|
372 |
*/ |
24506
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
373 |
public static boolean isSetUID() { |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
374 |
long uid = getuid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
375 |
long euid = geteuid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
376 |
long gid = getgid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
377 |
long egid = getegid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
378 |
return uid != euid || gid != egid; |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
379 |
} |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
380 |
|
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
381 |
/** |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
382 |
* Returns the real user ID of the calling process, |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
383 |
* or -1 if the value is not available. |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
384 |
*/ |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
385 |
public static native long getuid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
386 |
|
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
387 |
/** |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
388 |
* Returns the effective user ID of the calling process, |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
389 |
* or -1 if the value is not available. |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
390 |
*/ |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
391 |
public static native long geteuid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
392 |
|
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
393 |
/** |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
394 |
* Returns the real group ID of the calling process, |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
395 |
* or -1 if the value is not available. |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
396 |
*/ |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
397 |
public static native long getgid(); |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
398 |
|
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
399 |
/** |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
400 |
* Returns the effective group ID of the calling process, |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
401 |
* or -1 if the value is not available. |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
402 |
*/ |
abb4cc4647ee
8043537: Changes for JDK-8039951 introduced circular dependency between Kerberos and com.sun.security.auth
weijun
parents:
23010
diff
changeset
|
403 |
public static native long getegid(); |
22951
5fd21112b2b6
8034043: Native methods for preferences API should not be in libjava
alanb
parents:
22571
diff
changeset
|
404 |
|
28765
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
405 |
/** |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
406 |
* Get a nanosecond time stamp adjustment in the form of a single long. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
407 |
* |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
408 |
* This value can be used to create an instant using |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
409 |
* {@link java.time.Instant#ofEpochSecond(long, long) |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
410 |
* java.time.Instant.ofEpochSecond(offsetInSeconds, |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
411 |
* getNanoTimeAdjustment(offsetInSeconds))}. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
412 |
* <p> |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
413 |
* The value returned has the best resolution available to the JVM on |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
414 |
* the current system. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
415 |
* This is usually down to microseconds - or tenth of microseconds - |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
416 |
* depending on the OS/Hardware and the JVM implementation. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
417 |
* |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
418 |
* @param offsetInSeconds The offset in seconds from which the nanosecond |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
419 |
* time stamp should be computed. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
420 |
* |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
421 |
* @apiNote The offset should be recent enough - so that |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
422 |
* {@code offsetInSeconds} is within {@code +/- 2^32} seconds of the |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
423 |
* current UTC time. If the offset is too far off, {@code -1} will be |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
424 |
* returned. As such, {@code -1} must not be considered as a valid |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
425 |
* nano time adjustment, but as an exception value indicating |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
426 |
* that an offset closer to the current time should be used. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
427 |
* |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
428 |
* @return A nanosecond time stamp adjustment in the form of a single long. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
429 |
* If the offset is too far off the current time, this method returns -1. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
430 |
* In that case, the caller should call this method again, passing a |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
431 |
* more accurate offset. |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
432 |
*/ |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
433 |
public static native long getNanoTimeAdjustment(long offsetInSeconds); |
8878e8455f2a
8068730: Increase the precision of the implementation of java.time.Clock.systemUTC()
dfuchs
parents:
28059
diff
changeset
|
434 |
|
2 | 435 |
static { |
436 |
initialize(); |
|
437 |
} |
|
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30655
diff
changeset
|
438 |
private static native void initialize(); |
2 | 439 |
} |