> De: "John Rose" <john.r.r...@oracle.com> > À: "Remi Forax" <fo...@univ-mlv.fr> > Cc: "Claes Redestad" <claes.redes...@oracle.com>, "core-libs-dev" > <core-libs-dev@openjdk.java.net> > Envoyé: Samedi 11 Janvier 2020 02:23:50 > Objet: Re: RFR: 8236850: Operations on constant List/Set.of(element) instances > does not consistently constant fold
> On Jan 10, 2020, at 10:47 AM, Remi Forax < [ mailto:fo...@univ-mlv.fr | > fo...@univ-mlv.fr ] > wrote: >> Seem to be a JIT bug to me, >> the fields of Set12 are declared final not @Stable (even if the field storing >> the instanceof of Set&2 itself is marked @Stable) so there is no reason not >> not >> let the constant folding happen. > It’s part of the contract of @Stable that default values (null) are not > inlined. The reason for this is that some @Stable variables are lazy, > and the JIT needs to avoid assuming that default values stay that > way forever. My bad, reading the patch i've not seen that the fields were both annotated with final *and* @Shared. So it's another occurrence of final not meaning true final but instead of having an annotation @TrueScottmanFinal, this patch try to use @Stable but it doesn't work if the field is null, so the code is twisted to consider 'this' as a marker for null. In my opinion, it's better to introduce an annotation @TrueScottmanFinal instead of using @Stable in a way it was not designed to be used. cheers, Rémi