commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael A. Smith" <>
Subject Re: [Collections] Map.size problem on 64 bit JVM
Date Fri, 16 Aug 2002 13:35:13 GMT
Juozas Baliuka wrote:
> Hi,
> Some map implementations in [Collections] use int field to store map size
> (SUN's implementations has the same problems too)

don't see that as a "problem".

> I am not 64 bit JVM user, but I believe it is always sizeof(int) == 32/8  in

I don't know what the 32/8 is supposed to mean, but the JVM 
specification specifices that an int is always 32 bits (4 bytes) and a 
long is always 64 bites (8 bytes).  Doesn't matter what platform you are on.

> It is not a problem on 32bit JVM, because it will throw OutOfMemoryErro
> first,


> but it is possible to have negatyve map size on 64 bit JVM.

it would be possible to have a negative map size an a 32-bit VM too if 
the size field overflows...  doesn't matter what platform you are on.

> Map documentation says size must be in range : 0 <= size <= Integer.MAX_INT

ok, I believe Collection.size() says the same thing, but I'm too lazy to 

> The most trivial solution is to use "long" field to store map size and to
> return
> MIN(size,  Integer.MAX_INT); It will be problem for 128 bit JVM in the
> future :)

I still don't see why the platform makes many difference.  how does that 
matter?   And honestly, I don't see this size overflow "problem" as much 
of a problem.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message