On 11/08/2015 04:43 PM, Claes Redestad wrote: > Hi, > > indy eagerly creates and initializes all integral type caches > (Byte$ByteCache, Short$ShortCache) which has a small, measurable > impact to jake startup and footprint. Exposing ZERO constants from Byte, > Character, etc which are guaranteed to be identical to what's > returned from each respective valueOf(0) enables j.l.i. to initialize > without eagerly creating these caches: > > webrev: http://cr.openjdk.java.net/~redestad/8141678/webrev.01 > bug: https://bugs.openjdk.java.net/browse/JDK-8141678
a) Pulling ZERO via Reflection: is this actually the best we can do? I have no answer, but this does look moderately ugly. I agree that exposing these constants as public is not good, as it precludes further improvements in autoboxing elimination. b) Given that startup code is probably running in interpreter, doing the compiler's job in loop splitting to avoid branch for zero seems a good tactics, so: * Byte loop should use the same idiom as Char: cache[0] = ZERO; for (int i = 1; ...) { ... } * Integer/Long/Short loops may look better if we split the loop into "negative", ZERO, and "positive" parts? Thanks, -Aleksey