RFR (S) 8150465: Unsafe methods to produce uninitialized arrays

Andrew Haley aph at redhat.com
Thu Feb 25 14:13:46 UTC 2016


On 02/25/2016 01:44 PM, Aleksey Shipilev wrote:
> Of course, you will still see garbage data if after storing the array
> elements into the uninitialized array you would publish it racily. But
> the same is true for the "regular" allocations and subsequent writes.
> The only difference is whether you see "real" garbage, or some
> "synthetic" garbage like zeros. It is, of course, a caller
> responsibility to publish array safely in both cases, if garbage is
> unwanted.

Of course, my worry with this optimization assumes that programmers
make mistakes.  But you did say "complicated processing is done after
the allocation."  And that's where programmers make mistakes.

Andrew.



More information about the jdk9-dev mailing list