Many books/articles I’ve read on this topic, as well as a small program I wrote using ‘Unsafe’, indicate that 1-d arrays in Java are always contiguous in memory. So is it dictated by JLS or is it an implementation convention? The question is asked to confirm this indication.
Share
No, the JVM specification does not have any such guarantees:
http://docs.oracle.com/javase/specs/jvms/se5.0/html/Concepts.doc.html#16446
In practice it is probably the case but you also have no guarantee about the word size.
Unsafe is not a standard Java class, so if your program uses this, then it is not portable anyway…