< prev index next >

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

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

*** 74,83 **** --- 74,88 ---- */ @SuppressWarnings("unchecked") public static final Class<Long> TYPE = (Class<Long>) Class.getPrimitiveClass("long"); /** + * Zero {@code Long} constant. + */ + private static final Long ZERO = new Long(0L); + + /** * Returns a string representation of the first argument in the * radix specified by the second argument. * * <p>If the radix is smaller than {@code Character.MIN_RADIX} * or larger than {@code Character.MAX_RADIX}, then the radix
*** 1050,1061 **** private LongCache(){} static final Long cache[] = new Long[-(-128) + 127 + 1]; static { ! for(int i = 0; i < cache.length; i++) ! cache[i] = new Long(i - 128); } } /** * Returns a {@code Long} instance representing the specified --- 1055,1068 ---- private LongCache(){} static final Long cache[] = new Long[-(-128) + 127 + 1]; static { ! for(int i = 0; i < cache.length; i++) { ! int val = i - 128; ! cache[i] = (val == 0) ? ZERO : new Long(val); ! } } } /** * Returns a {@code Long} instance representing the specified
< prev index next >