It’s not an implementation specific bug. The size is defined in the FileChannel.map as long, but…
size – The size of the region to be mapped; must be non-negative and no greater than Integer.MAX_VALUE
All compliant JVM implementations will be this way. I suspect the reason is a combination of history (who would need to access a file larger than 2GB? 😉 and trying to push things forward in later versions of Java (it will be easier to allow values larger than Integer.MAX
than it will be to change the data type from int
to long
.)
A lot of people find this int-based thinking in the Java API regarding anything File very confounding and short sighted. But remember, Java start development in 1995! I’m sure 2GB seemed like a relatively safe value at the time.