RFR: 8236850: Operations on constant List/Set.of(element) instances does not consistently constant fold

Paul Sandoz paul.sandoz at oracle.com
Mon Jan 13 21:18:06 UTC 2020



> On Jan 13, 2020, at 1:12 PM, Claes Redestad <claes.redestad at oracle.com> wrote:
> 
> On 2020-01-13 20:49, Paul Sandoz wrote:
>> Looks good.
> 
> Thanks!
> 
>>   78     private static final Object[] EMPTY;
>> Is there a specific reason related to archiving that this is Object[] and not Object and instead assigned a value of new Object() ?
> 
> No, this was part of an experiment I did to have EMPTY_LIST etc use the
> EMPTY backing array, but that didn't pan out to anything but more code.
> I thought I backed out all changes, but must've slipped.
> 

Ok.


>> --
>> For information purposes: an alternative salt might be to use mix32 from Splittable random:
>> /**
>>  * Returns the 32 high bits of Stafford variant 4 mix64 function as int.
>>  */
>> private static int mix32(long z) {
>>     z = (z ^ (z >>> 33)) * 0x62a9d9ed799705f5L;
>>     return (int)(((z ^ (z >>> 28)) * 0xcb24d0a5c88c35b3L) >>> 32);
>> }
>> as in:
>> SALT = mix32(System.nanoTime());
> 
> Interesting - but as John points out we don't need a _really_ good salt
> for this, and I don't want to pull in SplittableRandom since we'd
> distort the bootstrap sequence if we did so here.
> 

That’s fine, it was really for informational purposes in case it comes in handy later on.

Speculating: if we had such a public method (with minimal dependencies) I suspect we would reach for it in this case even if overkill.  It reduces the cognitive load, but as a downside it would not afford us the opportunity of a slice Pi :-)

Paul.


More information about the core-libs-dev mailing list