RFR (S) 8150180: String.value contents should be trusted

Aleksey Shipilev aleksey.shipilev at oracle.com
Fri Feb 19 14:07:57 UTC 2016

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


More information about the core-libs-dev mailing list