Hi Peter, On 02/19/2016 05:05 PM, Peter Levart wrote: > Your comment in String: > > 140 * @implNote Note this field is not {@link Stable}, because we > want > 141 * LATIN1 (0) coder to fold too. {@link Stable} would not allow > that, > 142 * as it reserves the default value as "not initialized" value. > 143 * Constant-folding this field is handled internally in VM. > 144 */ > 145 private final byte coder; > > > Couldn't @Stable final instance fields constant-fold the default value > too in general? I mean can't it be assumed that the final field has been > set before JIT kicks in?
We've been over this multiple times, actually. @Stable is not designed to fold default value -- it is a part of its design to ignore final fields with default values. Because @Stable is used largely for lazy initialization, and default value is the important marker in field's lifecycles. Cheers, -Aleksey