< prev index next >

src/java.base/share/classes/java/lang/Short.java

Print this page
rev 13019 : 8141678: sun.invoke.util.Wrapper eagerly initializes all integral type caches
Reviewed-by: TBD

*** 61,70 **** --- 61,72 ---- * {@code short}. */ @SuppressWarnings("unchecked") public static final Class<Short> TYPE = (Class<Short>) Class.getPrimitiveClass("short"); + private static final Short ZERO = new Short((short)0); + /** * Returns a new {@code String} object representing the * specified {@code short}. The radix is assumed to be 10. * * @param s the {@code short} to be converted
*** 206,217 **** private ShortCache(){} static final Short cache[] = new Short[-(-128) + 127 + 1]; static { ! for(int i = 0; i < cache.length; i++) ! cache[i] = new Short((short)(i - 128)); } } /** * Returns a {@code Short} instance representing the specified --- 208,221 ---- private ShortCache(){} static final Short cache[] = new Short[-(-128) + 127 + 1]; static { ! for(int i = 0; i < cache.length; i++) { ! int val = i - 128; ! cache[i] = (val == 0) ? ZERO : new Short((short)val); ! } } } /** * Returns a {@code Short} instance representing the specified
< prev index next >