Proposal: Large arrays

Joseph D. Darcy Joe.Darcy at Sun.COM
Tue Mar 24 10:52:56 PDT 2009


james lowden wrote:
> Proposal: Large arrays
>
> AUTHOR(S):
>
> J. Lowden
>
> VERSION:
>
> 1.0    Initial version.
>
>
> OVERVIEW
>
> FEATURE SUMMARY:
>
> Java arrays are accessed via 32-bit ints, resulting in a maximum theoretical array size of 2147483647 elements.  While 
>
> this is enough for most uses, some applications that need to handle large sequential data sets in memory would benefit 
>
> from the ability to work with arrays indexed using 64-bit indices.  As "simply" changing the current array syntax to use 
>
> longs as indices rather than ints would have the potential to break a large amount of existing code, 

I don't think the source compatibility impact is that large actually.  
Let's say *all* arrays can potentially be 64-bit now.  The existing code 
that uses an int expression to index into the array will still index 
into the same element and negative indexes will still cause an 
exception.  Now, how should the length field be set?  I'd guess it 
should saturate to Integer.MAX_VALUE for oversize arrays and a new "long 
size()" method could be added to return the full length.

The JVM would need to be modified to handle the long indexes of course; 
perhaps the wide bytecode prefix could be put to use here.

[snip]

> ALTERNATIVES:
>
> Build your own class for storing long-indexes sequences, possibly as an array-or-arrays.
>   

This would be eased if the bracket operator could be used for 
user-defined types too since today functionally an array is just a 
fixed-length map from int to some other type.

-Joe




More information about the coin-dev mailing list