Primitive types are always the same size. Only links can vary in size, but you donโt need to know this at all.
You can get the size of the link with
int addressSize = Unsafe.addressSize();
Note. Even in a 64-bit JVM (on the latest Java 6+ JVMs), the links are 32-bit, but if you are not using a bunch of 32 GB or more. This is the default value for OpenJDK / Sun / Oracle JDK, however, as @ user988052 notes, the IBM JVM needs the appropriate flag to be set on the command line. Other JVMs may not support this option at all.
source share