author | alanb |
Tue, 08 Feb 2011 19:31:44 +0000 | |
changeset 8189 | 5fd29d2cbc4b |
parent 8174 | 89e3a22d4cd7 |
child 9035 | 1255eb81cc2f |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7668 | 2 |
* Copyright (c) 1996, 2010, 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 |
||
51 |
public static boolean allowThreadSuspension(ThreadGroup g, boolean b) { |
|
52 |
return g.allowThreadSuspension(b); |
|
53 |
} |
|
54 |
||
55 |
/** @deprecated */ |
|
56 |
@Deprecated |
|
57 |
public static boolean suspendThreads() { |
|
58 |
suspended = true; |
|
59 |
return true; |
|
60 |
} |
|
61 |
||
62 |
// Causes any suspended threadgroups to be resumed. |
|
63 |
/** @deprecated */ |
|
64 |
@Deprecated |
|
65 |
public static void unsuspendThreads() { |
|
66 |
suspended = false; |
|
67 |
} |
|
68 |
||
69 |
// Causes threadgroups no longer marked suspendable to be resumed. |
|
70 |
/** @deprecated */ |
|
71 |
@Deprecated |
|
72 |
public static void unsuspendSomeThreads() { |
|
73 |
} |
|
74 |
||
75 |
/* Deprecated fields and methods -- Memory advice not supported in 1.2 */ |
|
76 |
||
77 |
/** @deprecated */ |
|
78 |
@Deprecated |
|
79 |
public static final int STATE_GREEN = 1; |
|
80 |
||
81 |
/** @deprecated */ |
|
82 |
@Deprecated |
|
83 |
public static final int STATE_YELLOW = 2; |
|
84 |
||
85 |
/** @deprecated */ |
|
86 |
@Deprecated |
|
87 |
public static final int STATE_RED = 3; |
|
88 |
||
89 |
/** @deprecated */ |
|
90 |
@Deprecated |
|
91 |
public static final int getState() { |
|
92 |
return STATE_GREEN; |
|
93 |
} |
|
94 |
||
95 |
/** @deprecated */ |
|
96 |
@Deprecated |
|
97 |
public static void registerVMNotification(VMNotification n) { } |
|
98 |
||
99 |
/** @deprecated */ |
|
100 |
@Deprecated |
|
101 |
public static void asChange(int as_old, int as_new) { } |
|
102 |
||
103 |
/** @deprecated */ |
|
104 |
@Deprecated |
|
105 |
public static void asChange_otherthread(int as_old, int as_new) { } |
|
106 |
||
107 |
/* |
|
108 |
* Not supported in 1.2 because these will have to be exported as |
|
109 |
* JVM functions, and we are not sure we want do that. Leaving |
|
110 |
* here so it can be easily resurrected -- just remove the // |
|
111 |
* comments. |
|
112 |
*/ |
|
113 |
||
114 |
/** |
|
115 |
* Resume Java profiling. All profiling data is added to any |
|
116 |
* earlier profiling, unless <code>resetJavaProfiler</code> is |
|
117 |
* called in between. If profiling was not started from the |
|
118 |
* command line, <code>resumeJavaProfiler</code> will start it. |
|
119 |
* <p> |
|
120 |
* |
|
121 |
* NOTE: Profiling must be enabled from the command line for a |
|
122 |
* java.prof report to be automatically generated on exit; if not, |
|
123 |
* writeJavaProfilerReport must be invoked to write a report. |
|
124 |
* |
|
125 |
* @see resetJavaProfiler |
|
126 |
* @see writeJavaProfilerReport |
|
127 |
*/ |
|
128 |
||
129 |
// public native static void resumeJavaProfiler(); |
|
130 |
||
131 |
/** |
|
132 |
* Suspend Java profiling. |
|
133 |
*/ |
|
134 |
// public native static void suspendJavaProfiler(); |
|
135 |
||
136 |
/** |
|
137 |
* Initialize Java profiling. Any accumulated profiling |
|
138 |
* information is discarded. |
|
139 |
*/ |
|
140 |
// public native static void resetJavaProfiler(); |
|
141 |
||
142 |
/** |
|
143 |
* Write the current profiling contents to the file "java.prof". |
|
144 |
* If the file already exists, it will be overwritten. |
|
145 |
*/ |
|
146 |
// public native static void writeJavaProfilerReport(); |
|
147 |
||
148 |
||
149 |
private static volatile boolean booted = false; |
|
150 |
||
151 |
// Invoked by by System.initializeSystemClass just before returning. |
|
152 |
// Subsystems that are invoked during initialization can check this |
|
153 |
// property in order to avoid doing things that should wait until the |
|
154 |
// application class loader has been set up. |
|
155 |
// |
|
156 |
public static void booted() { |
|
157 |
booted = true; |
|
158 |
} |
|
159 |
||
160 |
public static boolean isBooted() { |
|
161 |
return booted; |
|
162 |
} |
|
163 |
||
164 |
// A user-settable upper limit on the maximum amount of allocatable direct |
|
165 |
// buffer memory. This value may be changed during VM initialization if |
|
166 |
// "java" is launched with "-XX:MaxDirectMemorySize=<size>". |
|
167 |
// |
|
168 |
// The initial value of this field is arbitrary; during JRE initialization |
|
169 |
// it will be reset to the value specified on the command line, if any, |
|
170 |
// otherwise to Runtime.getRuntime.maxDirectMemory(). |
|
171 |
// |
|
172 |
private static long directMemory = 64 * 1024 * 1024; |
|
173 |
||
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
174 |
// 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
|
175 |
// The directMemory variable is initialized during system initialization |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
176 |
// in the saveAndRemoveProperties method. |
2 | 177 |
// |
178 |
public static long maxDirectMemory() { |
|
179 |
return directMemory; |
|
180 |
} |
|
181 |
||
6902
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
182 |
// User-controllable flag that determines if direct buffers should be page |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
183 |
// aligned. The "-XX:+PageAlignDirectMemory" option can be used to force |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
184 |
// buffers, allocated by ByteBuffer.allocateDirect, to be page aligned. |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
185 |
private static boolean pageAlignDirectMemory; |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
186 |
|
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
187 |
// 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
|
188 |
// variable is initialized by saveAndRemoveProperties. |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
189 |
public static boolean isDirectMemoryPageAligned() { |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
190 |
return pageAlignDirectMemory; |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
191 |
} |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
192 |
|
2 | 193 |
// A user-settable boolean to determine whether ClassLoader.loadClass should |
194 |
// accept array syntax. This value may be changed during VM initialization |
|
195 |
// via the system property "sun.lang.ClassLoader.allowArraySyntax". |
|
196 |
// |
|
197 |
// The default for 1.5 is "true", array syntax is allowed. In 1.6, the |
|
198 |
// default will be "false". The presence of this system property to |
|
199 |
// control array syntax allows applications the ability to preview this new |
|
200 |
// behaviour. |
|
201 |
// |
|
202 |
private static boolean defaultAllowArraySyntax = false; |
|
203 |
private static boolean allowArraySyntax = defaultAllowArraySyntax; |
|
204 |
||
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
205 |
// The allowArraySyntax boolean is initialized during system initialization |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
206 |
// in the saveAndRemoveProperties method. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
207 |
// |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
208 |
// It is initialized based on the value of the system property |
2 | 209 |
// "sun.lang.ClassLoader.allowArraySyntax". If the system property is not |
210 |
// provided, the default for 1.5 is "true". In 1.6, the default will be |
|
211 |
// "false". If the system property is provided, then the value of |
|
212 |
// allowArraySyntax will be equal to "true" if Boolean.parseBoolean() |
|
213 |
// returns "true". Otherwise, the field will be set to "false". |
|
214 |
// |
|
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
215 |
public static boolean allowArraySyntax() { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
216 |
return allowArraySyntax; |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
217 |
} |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
218 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
219 |
/** |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
220 |
* 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
|
221 |
* 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
|
222 |
* 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
|
223 |
* 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
|
224 |
* 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
|
225 |
* cause the library to deadlock. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
226 |
* |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
227 |
* 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
|
228 |
* the ones set by sun.misc.Version.init(). |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
229 |
* |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
230 |
*/ |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
231 |
public static String getSavedProperty(String key) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
232 |
if (savedProps.isEmpty()) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
233 |
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
|
234 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
235 |
return savedProps.getProperty(key); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
236 |
} |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
237 |
|
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
238 |
// TODO: the Property Management needs to be refactored and |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
239 |
// the appropriate prop keys need to be accessible to the |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
240 |
// calling classes to avoid duplication of keys. |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
241 |
private static final Properties savedProps = new Properties(); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
242 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
243 |
// 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
|
244 |
// the system properties that are not intended for public access. |
2 | 245 |
// |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
246 |
// 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
|
247 |
public static void saveAndRemoveProperties(Properties props) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
248 |
if (booted) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
249 |
throw new IllegalStateException("System initialization has completed"); |
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 |
savedProps.putAll(props); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
252 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
253 |
// 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
|
254 |
// by the vm option -XX:MaxDirectMemorySize=<size>. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
255 |
// 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
|
256 |
// 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
|
257 |
// The system property will be removed. |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
258 |
String s = (String)props.remove("sun.nio.MaxDirectMemorySize"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
259 |
if (s != null) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
260 |
if (s.equals("-1")) { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
261 |
// -XX:MaxDirectMemorySize not given, take default |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
262 |
directMemory = Runtime.getRuntime().maxMemory(); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
263 |
} else { |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
264 |
long l = Long.parseLong(s); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
265 |
if (l > -1) |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
266 |
directMemory = l; |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
267 |
} |
2 | 268 |
} |
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
269 |
|
6902
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
270 |
// Check if direct buffers should be page aligned |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
271 |
s = (String)props.remove("sun.nio.PageAlignDirectMemory"); |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
272 |
if ("true".equals(s)) |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
273 |
pageAlignDirectMemory = true; |
3352f8839320
4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents:
6882
diff
changeset
|
274 |
|
6882
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
275 |
// Set a boolean to determine whether ClassLoader.loadClass accepts |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
276 |
// array syntax. This value is controlled by the system property |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
277 |
// "sun.lang.ClassLoader.allowArraySyntax". |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
278 |
s = props.getProperty("sun.lang.ClassLoader.allowArraySyntax"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
279 |
allowArraySyntax = (s == null |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
280 |
? defaultAllowArraySyntax |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
281 |
: Boolean.parseBoolean(s)); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
282 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
283 |
// Remove other private system properties |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
284 |
// used by java.lang.Integer.IntegerCache |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
285 |
props.remove("java.lang.Integer.IntegerCache.high"); |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
286 |
|
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
287 |
// used by java.util.zip.ZipFile |
637546039be3
6977738: Deadlock between java.lang.ClassLoader and java.util.Properties
mchung
parents:
5506
diff
changeset
|
288 |
props.remove("sun.zip.disableMemoryMapping"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
289 |
|
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
290 |
// used by sun.launcher.LauncherHelper |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7668
diff
changeset
|
291 |
props.remove("sun.java.launcher.diag"); |
2 | 292 |
} |
293 |
||
294 |
// Initialize any miscellenous operating system settings that need to be |
|
295 |
// set for the class libraries. |
|
296 |
// |
|
297 |
public static void initializeOSEnvironment() { |
|
298 |
if (!booted) { |
|
299 |
OSEnvironment.initialize(); |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
/* Current count of objects pending for finalization */ |
|
304 |
private static volatile int finalRefCount = 0; |
|
305 |
||
306 |
/* Peak count of objects pending for finalization */ |
|
307 |
private static volatile int peakFinalRefCount = 0; |
|
308 |
||
309 |
/* |
|
310 |
* Gets the number of objects pending for finalization. |
|
311 |
* |
|
312 |
* @return the number of objects pending for finalization. |
|
313 |
*/ |
|
314 |
public static int getFinalRefCount() { |
|
315 |
return finalRefCount; |
|
316 |
} |
|
317 |
||
318 |
/* |
|
319 |
* Gets the peak number of objects pending for finalization. |
|
320 |
* |
|
321 |
* @return the peak number of objects pending for finalization. |
|
322 |
*/ |
|
323 |
public static int getPeakFinalRefCount() { |
|
324 |
return peakFinalRefCount; |
|
325 |
} |
|
326 |
||
327 |
/* |
|
328 |
* Add <tt>n</tt> to the objects pending for finalization count. |
|
329 |
* |
|
330 |
* @param n an integer value to be added to the objects pending |
|
331 |
* for finalization count |
|
332 |
*/ |
|
333 |
public static void addFinalRefCount(int n) { |
|
334 |
// The caller must hold lock to synchronize the update. |
|
335 |
||
336 |
finalRefCount += n; |
|
337 |
if (finalRefCount > peakFinalRefCount) { |
|
338 |
peakFinalRefCount = finalRefCount; |
|
339 |
} |
|
340 |
} |
|
341 |
||
7540 | 342 |
/** |
343 |
* Returns Thread.State for the given threadStatus |
|
344 |
*/ |
|
2 | 345 |
public static Thread.State toThreadState(int threadStatus) { |
7540 | 346 |
if ((threadStatus & JVMTI_THREAD_STATE_RUNNABLE) != 0) { |
347 |
return RUNNABLE; |
|
348 |
} else if ((threadStatus & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) { |
|
349 |
return BLOCKED; |
|
350 |
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) != 0) { |
|
351 |
return WAITING; |
|
352 |
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) != 0) { |
|
353 |
return TIMED_WAITING; |
|
354 |
} else if ((threadStatus & JVMTI_THREAD_STATE_TERMINATED) != 0) { |
|
355 |
return TERMINATED; |
|
356 |
} else if ((threadStatus & JVMTI_THREAD_STATE_ALIVE) == 0) { |
|
357 |
return NEW; |
|
358 |
} else { |
|
359 |
return RUNNABLE; |
|
2 | 360 |
} |
361 |
} |
|
362 |
||
7540 | 363 |
/* The threadStatus field is set by the VM at state transition |
364 |
* in the hotspot implementation. Its value is set according to |
|
365 |
* the JVM TI specification GetThreadState function. |
|
366 |
*/ |
|
367 |
private final static int JVMTI_THREAD_STATE_ALIVE = 0x0001; |
|
368 |
private final static int JVMTI_THREAD_STATE_TERMINATED = 0x0002; |
|
369 |
private final static int JVMTI_THREAD_STATE_RUNNABLE = 0x0004; |
|
370 |
private final static int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400; |
|
371 |
private final static int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010; |
|
372 |
private final static int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020; |
|
2 | 373 |
|
374 |
static { |
|
375 |
initialize(); |
|
376 |
} |
|
377 |
private native static void initialize(); |
|
378 |
} |