equal
deleted
inserted
replaced
24 */ |
24 */ |
25 |
25 |
26 package java.lang; |
26 package java.lang; |
27 |
27 |
28 import jdk.internal.HotSpotIntrinsicCandidate; |
28 import jdk.internal.HotSpotIntrinsicCandidate; |
|
29 import jdk.internal.misc.VM; |
29 |
30 |
30 /** |
31 /** |
31 * The {@code Short} class wraps a value of primitive type {@code |
32 * The {@code Short} class wraps a value of primitive type {@code |
32 * short} in an object. An object of type {@code Short} contains a |
33 * short} in an object. An object of type {@code Short} contains a |
33 * single field whose type is {@code short}. |
34 * single field whose type is {@code short}. |
201 public static Short valueOf(String s) throws NumberFormatException { |
202 public static Short valueOf(String s) throws NumberFormatException { |
202 return valueOf(s, 10); |
203 return valueOf(s, 10); |
203 } |
204 } |
204 |
205 |
205 private static class ShortCache { |
206 private static class ShortCache { |
206 private ShortCache(){} |
207 private ShortCache() {} |
207 |
208 |
208 static final Short cache[] = new Short[-(-128) + 127 + 1]; |
209 static final Short[] cache; |
|
210 static Short[] archivedCache; |
209 |
211 |
210 static { |
212 static { |
211 for(int i = 0; i < cache.length; i++) |
213 int size = -(-128) + 127 + 1; |
212 cache[i] = new Short((short)(i - 128)); |
214 |
|
215 // Load and use the archived cache if it exists |
|
216 VM.initializeFromArchive(ShortCache.class); |
|
217 if (archivedCache == null || archivedCache.length != size) { |
|
218 Short[] c = new Short[size]; |
|
219 short value = -128; |
|
220 for(int i = 0; i < size; i++) { |
|
221 c[i] = new Short(value++); |
|
222 } |
|
223 archivedCache = c; |
|
224 } |
|
225 cache = archivedCache; |
213 } |
226 } |
214 } |
227 } |
215 |
228 |
216 /** |
229 /** |
217 * Returns a {@code Short} instance representing the specified |
230 * Returns a {@code Short} instance representing the specified |