Array bounds checks

Boehm, Hans hans_boehm@hp.com
Thu Oct 26 13:18:00 GMT 2000


> I'm wrong in saying that even if the multiarray has been initially
> allocated rectangular, that fact can be changed later, i.e.:
Actually, you're right in saying that ...
>> double[][] array = new double[10][10];
>> later...
>> array[2] = new double[20];
>> Which poses some slight problem with this approach...
>> Cedric
>That's a good point. It means that you need an additional check to
invalidate the "contiguity" bits all the way up to the root array. But I
think the check can be fairly fast in the usual case, and it's needed only
when you're assigning an array to an array element. (I think you only need
one more flag in the array header of the subarrays. Once you know that
you're replacing a part of a contiguous array, you need to do more work, but
I think it's still not a big deal. The GC already knows how to get back to
the main array quickly.) 
Hans


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /